‎2007 Sep 15 8:03 AM
Q3]] An example creates two internal tables TAB1 and TAB2. TAB2 has a deep structure because the second component of LINE2 has the data type of internal table TAB1. LINE1 is filled and appended to TAB1. Then, LINE2 is filled and appended to TAB2. After clearing TAB1 with the REFRESH statement, the same procedure is repeated
LOOP AT TAB2 INTO LINE2.
WRITE: / LINE2-FIELD1.
LOOP AT LINE2-FIELD2 INTO LINE1.
WRITE: / LINE1-COL1, LINE1-COL2, LINE1-COL3.
ENDLOOP.
ENDLOOP.The output is:
A
abc 12 3
def 34 5
B
ghi 56 7
jkl 78 9
How would the output come as<b>:
the dots are there to explain the output without any use</b>
A.... abc 12 .............. 3
...... def 34 ...............5
B..... ghi 56 ................7
........ jkl 78 ..................9
Regards
Abaper.learner
‎2007 Sep 16 5:29 AM
Try this:
LOOP AT tab2 INTO line2.
WRITE: / line2-field1.
LOOP AT line2-field2 INTO line1.
IF sy-tabix = 1.
WRITE: line1-col1, line1-col2.
ELSE.
WRITE: / line1-col1 UNDER line1-col1, line1-col2 UNDER line1-col2.
ENDIF.
ENDLOOP.
ENDLOOP.
‎2007 Sep 16 8:31 AM
I don't have a sytem on hand to proof it, but I think you could also do it easily with:
LOOP AT TAB2 INTO LINE2.
LOOP AT LINE2-FIELD2 INTO LINE1.
WRITE: / LINE2-FIELD1, LINE1-COL1, LINE1-COL2, LINE1-COL3.
clear: LINE2-FIELD1. "empty value after first write
ENDLOOP.
ENDLOOP.Jonathan