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

Loop inside ITAB.

Former Member
0 Likes
394

There are few records in ITAB, I want to loop it twice in order to pick correct answer where S = 'X'. Once I completed 1st loop I shud loop from second loop in same loop.

I am using loop at itab into wa from index.

How to loop it correctly.

Following table is to be looped, twice.

where S is is my correct answer.

                         
"1st loop.
TYPE	ID	                           TEXT              	S

Qesn	q1	                          Best PM of India	
Ans	id_47d61fa77bc600ece1008	Manmohan singh1	 -
Ans	id_47d61fc27bc600ece1008	N  Ra0	                  X
Ans	id_47d61fcd7bc600ece1008	Vajpayee	                  -
Ans	id_47d621b57bc600ece1008	Rajiv gandhi	  -
Ans	id_47d6248b7bc600ece1008	IGandhi	                  -

"second loop.
Qesn	id_47dee7d3499f008de10080	who is the best FM	
Ans	id_47dee7e0499f008de10080	Yashwant Sinha	   X
Ans	id_47dee800499f008de10080	Chidambram	   -   

Any clarrification is appreciated.

I need to pick correct answer where S = 'X'.

My 1st loop data shud be.

Qesn	q1	                          Best PM of India	
Ans	id_47d61fc27bc600ece1008	N  Ra0	                  X

second table data shud be

Qesn	id_47dee7d3499f008de10080	who is the best FM	
Ans	id_47dee7e0499f008de10080	Yashwant Sinha	   X

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
373

Hi Anee,

Here is the solution,from wat Iunderstood ur problem.

Loop at itab where type = 'Qesn'.

read table itab with key S = 'X'.

if sy-subrc = 0.

do ur logic.

modify itab with s= 'space.' this is to pick the correct record for next read.

endif.

endloop.

2 REPLIES 2
Read only

Former Member
0 Likes
374

Hi Anee,

Here is the solution,from wat Iunderstood ur problem.

Loop at itab where type = 'Qesn'.

read table itab with key S = 'X'.

if sy-subrc = 0.

do ur logic.

modify itab with s= 'space.' this is to pick the correct record for next read.

endif.

endloop.

Read only

0 Likes
373

i solved myself .

Thanks for replying.