某种业务场景下,将一个工作区的多个字段整理到一个内表中

 1 DATA:num TYPE i.
 2 CONSTANTS: times TYPE i VALUE 29.
 3 DATA: BEGIN OF ih_lgty,
 4   lgty TYPE lgtyp,
 5 END OF ih_lgty,
 6 it_lgty LIKE TABLE OF ih_lgty.
 7 FIELD-SYMBOLS: <lgty> TYPE any,
 8                <t334t> LIKE t334t.
 9 
10 DATA:lh_t334t LIKE t334t,
11      lt_t334t LIKE TABLE OF t334t.
12 
13 SELECT SINGLE
14   *
15   INTO  lh_t334t
16   FROM t334t
17   WHERE lgnum = 'NJ1'
18   AND kzear = 'A'
19   AND lgtkz = 'BC1'.
20 ***  将一个工作区的数据整理到一个内表中
21 ASSIGN lh_t334t TO <t334t>.
22 DO times TIMES.
23   num = 10 + sy-index.
24   UNASSIGN <lgty>.
25   ASSIGN  COMPONENT num OF  STRUCTURE  <t334t> TO  <lgty>.
26   ih_lgty-lgty =  <lgty>.
27   APPEND ih_lgty TO it_lgty.
28 ENDDO.
29 DELETE it_lgty WHERE lgty IS INITIAL.
30 ***
31 SORT it_lgty.
32 DELETE ADJACENT DUPLICATES FROM it_lgty COMPARING ALL FIELDS.
33 num = lines( it_lgty ).
34 WRITE:num.

工作区中的数据:

整理后,内表中的数据:

转载于:https://www.cnblogs.com/ruingy/p/3918767.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值