on 02-28-2006 6:21 PM
I have a method with a parameter itab of the type ANY TABLE.
Now i want to loop over this itab and convert each line into a string, whereas each field shall be separated by a certain string.
The problem is, that I don't know which fields the table's structure has.
Any ideas?
If you know the structure that the table needs to be moved to then it is possible with assign..
pls check the code below...
REPORT yytest88 LINE-COUNT 20 NO STANDARD PAGE HEADING.
TYPES: BEGIN OF ty_test,
f1(10),
f2(10),
END OF ty_test.
DATA : wa_type(10) VALUE 'TY_TEST'.
DATA : BEGIN OF itab OCCURS 0,
f(20),
END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
f(35),
END OF itab1.
FIELD-SYMBOLS : <fs1> TYPE any.
FIELD-SYMBOLS : <fs2> TYPE any.
FIELD-SYMBOLS : <fs3> TYPE any.
itab-f = '12345678901234567890'.
APPEND itab.
itab-f = '09876543210987654321'.
APPEND itab.
LOOP AT itab.
ASSIGN itab-f TO <fs1> CASTING TYPE (wa_type).
IF sy-subrc = 0.
do.
assign component sy-index of structure <fs1> to <fs2>.
if sy-subrc = 0.
if itab1-f is initial.
concatenate itab1-f <fs2> into itab1-f.
else.
concatenate itab1-f <fs2> into itab1-f separated by 'BREAK'.
endif.
else.
exit.
endif.
enddo.
APPEND itab1.
clear : sy-subrc, itab1-f.
ENDIF.
ENDLOOP.
LOOP AT itab1.
WRITE 😕 itab1-f.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.