Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Regarding loop statement

Former Member
0 Likes
2,071

hi,

how to find whether a statement exists between loop and endloop.

for eg:

loop at itab.

clear.....

endloop.

want check whether clear statement exists between loop.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,034

Hi Selvaraj,

in the following code, sy-tabix vary from 1 to 10... but it doesnot mean there is a statment inside loop.

data: itab like tstc occurs 0 with header line.

select * from tstc into table itab up to 10 rows.

loop at itab.

regards,

Venkatesh

endloop.

20 REPLIES 20
Read only

Former Member
0 Likes
2,034

Can you be clear ........

Read only

Former Member
0 Likes
2,034

Hi,

I am not sure what exactly you are looking for.....

We can check out whether the table is getting looped or not by checking out the sy-subrc value.

Why do you need to find out whether there is a statement in side a loop.

Regards,

Venkatesh

Read only

Former Member
0 Likes
2,034

Hi,

If u r debugging the code,

Check ur SY-TABIX value,

if it is changing continuously like 1, 2, 3,.........etc.

then ur statement inside the loop.

Read only

Former Member
0 Likes
2,035

Hi Selvaraj,

in the following code, sy-tabix vary from 1 to 10... but it doesnot mean there is a statment inside loop.

data: itab like tstc occurs 0 with header line.

select * from tstc into table itab up to 10 rows.

loop at itab.

regards,

Venkatesh

endloop.

Read only

0 Likes
2,034

Hi venkatesh,

I'm not saying that , if sy-tabix varies, it will contain some statements.

I said that If ur cursor on a particular statement, now u want to find out that statement whether in loop or not.

Read only

christine_evans
Active Contributor
0 Likes
2,034

>

> hi,

>

> how to find whether a statement exists between loop and endloop.

> for eg:

> loop at itab.

>

> clear.....

>

> endloop.

>

> want check whether clear statement exists between loop.

>

> Thanks

Can't you just read the code?

Read only

Former Member
0 Likes
2,034

Instead of Clear statement in Loop and Endloop you can move some value by defining some local variable.

You can verify the veriable by checking the value of variable ...

e.g.

Data : l_check(20) Type C.

Loop at ...

l_check = 'Test Move'.

Endloop.

If the value of variable is 'Test Move' then your purpose will be solved... You can check this by debugging

Read only

Subhankar
Active Contributor
0 Likes
2,034

Hi...

Using the read report statement you can get the source code.

then you can check the condition.

Ex. READ REPORT sy-repid INTO i_source.

Read only

Former Member
0 Likes
2,034

hi,

we can use read report but how i will know that clear statement exists between loop.

Read only

Former Member
0 Likes
2,034

If you want to find that Clear Statement is whithin the loop or not.

Just debug the code, IF sy-subrc EQ 0 that means loop is working . And when you are within the Loop, just debug it line by line thru F5 you will get to know all the Statements within the loop.

Read only

Former Member
0 Likes
2,034

hi,

i dont want to check in debug mode.

i am reading a report and checking whether clear statements exists with in a loop.

i want to check and capture that code line which exists between loop and endloop.

Read only

Former Member
0 Likes
2,034

You should have mentioned this in your original question to avoid inappropriate answers.

regards,

Advait

Edited by: Advait Gode on Jan 12, 2009 12:13 PM

Read only

Former Member
0 Likes
2,034

thanks

Read only

Former Member
0 Likes
2,034

Hi,

In debugging the code , and check the sy-tabix .

Regards,

Madhu

Read only

0 Likes
2,034

hi,

i am writing a report which should read another report and check clear statements exists between loop.

i am not talking about debug mode.

Read only

0 Likes
2,034

Take the report into one Internal table say t_source1 using below statement.

  • Reading Report to delete the comments

READ REPORT p_pgname INTO t_source1.

Get all the includes of the program into an internal table

CALL FUNCTION 'GET_INCLUDETAB'

EXPORTING

progname = p_pgname

TABLES

incltab = i_incl_tab.

IF NOT i_incl_tab[] IS INITIAL.

  • Loop at this internal table and append all the data to

  • Main Report table

LOOP AT i_incl_tab INTO wa_incl_tab.

READ REPORT wa_incl_tab-line INTO t_source_tmp.

APPEND LINES OF t_source_tmp TO t_source1.

REFRESH t_source_tmp[].

CLEAR wa_incl_tab.

ENDLOOP.

ENDIF.

Now LOOP AT t_source1 INTO wa_source1 ..... This t_source1 is an internal table with all the lines including all subroutines.....

You can read the table line by line with Key word LOOP and once find then you can find the required Statement ....

Include one more condition... If you find a Keywork ENDLOOP then it means your required statement does not exist in LOOP and ENDLOOP..... if found then you can set a Flag....

Thanks,

Amol

I think this will solve your purpose.

Read only

0 Likes
2,034

h

Read only

Former Member
0 Likes
2,034

Actually, I think there is no good way. Within a LOOP/ENDLOOP, there may be calls to other forms, function modules, external performs.

Rob

Read only

Former Member
0 Likes
2,034

If you're wondering if a certain variable is changed, you might try using the debugger and a watchpoint.

Read only

0 Likes
2,034

removed

Edited by: Rob Burbank on Jan 12, 2009 11:41 AM