2011 Sep 20 12:33 PM
Hi everyone,
I have a program, which uses "READ REPORT" (gets the code of a report in an internal table). Now I want to loop at the internal table to find blocks of code ... just like loop - endloop. Any Idea how to realize this?
Best regards!
2011 Sep 20 12:41 PM
Hi,
Use below code.
DATA prog(30) TYPE c.
DATA WA TYPE STRING.
DATA itab TYPE TABLE OF string.
PROG = 'ZSAMPLE' "REPORT NAME
READ REPORT prog INTO itab.
LOOP AT ITAB INTO WA.
ENDLOOP.
REGARDS,
MURALII
Hi everyone,
I have a program, which uses "READ REPORT" (gets the code of a report in an internal table). Now I want to loop at the internal table to find blocks of code ... just like loop - endloop. Any Idea how to realize this?
Best regards!
2011 Sep 20 12:41 PM
Hi,
Use below code.
DATA prog(30) TYPE c.
DATA WA TYPE STRING.
DATA itab TYPE TABLE OF string.
PROG = 'ZSAMPLE' "REPORT NAME
READ REPORT prog INTO itab.
LOOP AT ITAB INTO WA.
ENDLOOP.
REGARDS,
MURALII
2011 Sep 20 12:48 PM
Sorry, maybe I expressed myself not clearly enough... I know how to loop at an internal table But I want to find out at which line of the internal table a block of code starts and where it ends. Example:
Loop. " Start Block 1
Loop. " Start Block 2
If. " Start Block 3
Endif. " End Block 3
Endloop. " End Block 2
Loop. " End Block 1
Edited by: Fabian Vogt on Sep 20, 2011 1:48 PM
2011 Sep 20 12:55 PM
Hi
Split the line into table where space
LOOP AT ITAB INTO WA.
SPLIT WA AT SPACE INTO TABLE ITAB1.
LOOP AT ITAB1 INTO WA1.
AT FAST.
"FIRST BLOCK.
ENDAT.
AT LAST.
"LAST BLOCK.
ENDAT.
ENDLOOP.
ENDLOOP.
REGARDS.
MURALI
2011 Sep 20 1:06 PM
I think it is too tedious to use the result of READ REPORT for your purpose, you might want to look at the SCAN statement.
http://help.sap.com/abapdocu_702/en/abapscan.htm
It takes a while to figure out how it works, but it is quite powerful. SAP flags it as "internal use only", so use it at your own risk.
Thomas
2011 Sep 20 12:44 PM
Hi
U need to use command like SEARCH in order to get out a certain value of a string (in your case the line of abap code)
Max