嗨,所以我必须选择此字段,直到无法选择任何内容。
例如
field 1 | field 2
________|__________
aaa | bbb
bbb | fff
fff | ccc
ccc | kkk
我需要使用field1选择field2并修改内部表,然后将其查找到字段1,然后再次使字段2修改表,然后再将其查找到字段1,相同的例程进行到没有任何选择。 / p>
这是我的代码。
DATA : BEGIN OF IT OCCURS 0,
PARTNER TYPE BUT000-PARTNER,
PARTNER1 TYPE BUT050-PARTNER1,
2 TYPE BUT050-PARTNER1,
3 TYPE BUT050-PARTNER1,
4 TYPE BUT050-PARTNER1,
5 TYPE BUT050-PARTNER1,
6 TYPE BUT050-PARTNER1,
7 TYPE BUT050-PARTNER1,
8 TYPE BUT050-PARTNER1,
9 TYPE BUT050-PARTNER1,
10 TYPE BUT050-PARTNER1,
END OF IT.
SELECT BUT000~PARTNER BUT050~PARTNER2
FROM BUT000
INNER JOIN BUT050 ON BUT000~PARTNER EQ BUT050~PARTNER1
INTO TABLE IT.
FIELD-SYMBOLS <FS_WA> TYPE ANY.
FIELD-SYMBOLS <FS_WA1> TYPE ANY.
data num type i value 1.
data num2 type string.
data str type string.
data partner(255) type c.
LOOP AT IT.
partner = it-partner1.
while partner <> space.
num = num + 1.
num2 = num.
concatenate 'it-' num2 into str.
condense str.
assign str to <fs_wa>.
select single but050~partner2 into
<fs_wa> from but050 where partner1 eq partner.
partner = <fs_wa>.
modify it from <fs_wa>.
if num = 10.
clear num.
stop.
exit.
endif.
endwhile.
ENDLOOP.
我需要我的内部表看起来像这样。
field 1 | field 2 | field 3 | field 4 | field 5
________|_________|_________|_________|________
aaa | bbb | fff | ccc | kkkk
希望您能对此有所帮助。
答案 0 :(得分:0)
谢谢您已经解决了我的问题,尽管这不是我想要实现的目标,但是,这还可以。
这就是解决我的问题的原因。
LOOP AT IT.
INDEX = 2.
DATA(PART) = IT-PARTNER1.
DO .
INDEX = INDEX + 1.
ASSIGN COMPONENT INDEX OF STRUCTURE IT TO <FS>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
SELECT BUT050~PARTNER2 FROM BUT050
WHERE PARTNER1 EQ @PART
AND RELTYP IN ('ZBP002',
'ZBP003',
'ZBP004',
'ZBP005',
'ZBP006',
'ZBP007',
'ZBP008',
'ZBP009',
'ZBP010',
'ZBP011')
ORDER BY RELTYP ASCENDING
INTO @<FS>.
ENDSELECT.
IF IT-PARTNER NE <FS> AND IT-PARTNER1 NE <FS>.
PART = <FS>.
MODIFY IT.
ELSE.
PART = ''.
ENDIF.
ENDDO.
ENDLOOP.
非常感谢!最好的问候:)