‎2012 Jul 09 9:06 AM
Dear Guru's
I have a problem in read statement in loop. Let us say i have 10 records in internal table say it_vbap. I am populating the values using loop. in that loop i am reading the same it_vbap for some logic.
For 1st iteration data is coming in proper way, for 2nr iteration also data is coming. For 3rd iteration i am comparing with 2nd record's value and if it is satisfy then i am reading 2nd record for some data. So here after printing 2nd record values i have to print 3rd record and continuously but here i am getting 2nd record values and jumps into 4th record values.
I am missing 3rd record values. Please help me how to resolve this.
Thanks and Regards
Muralikrishna Peravali
‎2012 Jul 09 9:40 AM
Are you using loop condition based on some condition?
Can you paste your code of this part?
‎2012 Jul 09 9:40 AM
Are you using loop condition based on some condition?
Can you paste your code of this part?
‎2012 Jul 09 2:25 PM
‎2012 Jul 09 9:41 AM
I hope you are using INDEX to fetch data from your table. that should work fine, post your code in case it is not.
If you are using WITH KEY for the inner read table, you will always get first record that satisfies the criteria.
‎2012 Jul 09 2:27 PM
Hi Chinmay,
I am not using the index to fetch the data. Please find the attachment so that you will know
Thanks and Regards,
Muralikrishna
‎2012 Jul 09 9:46 AM
Hi Muralikrishna,
It seems this is is a prbolem of handling Index.
Once you process one record, your Index must have been incremented by then and perhaps for that reason you might be loosing your 3rd Record to be displayed.
Check from that angle too.
Thanks.
Kumar Saurav.
‎2012 Jul 09 2:30 PM
‎2012 Jul 09 9:49 AM
You can use like this
Loop at it_tab into wa_itab.
lv_index = sy-tabix + 1.
Read table it_tab with key lv_index. '2nd entry
regards,
Lokesh
‎2012 Jul 09 3:07 PM
Every READ statement will set the following system variables ( and many more )
SY-INDEX - Contains the number of loop passes, including the current loop pass
SY-TABIX - Current row index
Since you have used, READ TABLE with KEY, you cannot guarantee that the records will be read in sequence and I believe this is the issue.
If you want to check / compare data in internal tables, you can use the option COMPARING / TRANSPORTING NO FIELDS. If you specify NO FIELDS, no fields are transported this statement only fills the system fields sy-subrc and sy-tabix.
Pseudo code:
LOOP AT itab into wa.
READ TABLE itab1 INTO wa1 WITH KEY aaaa = wa-bbbb.
READ TABLE itab2 INTO wa2 WITH KEY cccc = wa-1-aaaa. <<< SY-TABIX will change again
ENDLOOP.
Regards,
Shyam
‎2012 Jul 11 2:01 PM
Hi All,
Thankyou for your informations. But my self resolve the issue. Thank you for all supports
‎2012 Jul 12 6:51 AM
If you solve by yourself, then how do you solve the issue? Post here your solution for future reference of other SCN member. Lastly, don't forget to close this thread.
Jake
‎2021 Nov 23 5:09 AM
how you resolved this issue i am also facing the same problem kindly help me to resolved this issue??????