2008 Jul 10 5:35 AM
Hello Experts,
I need your help.
I am looping at an internal table. I have to check for a condition. If this condition is true, I need to check for another condition on the previous record.
This is the IT content:
SINCHFCiVision Heffen
Z200720000126800P0000005544041229320005217381935Eversdijk M. M.
K200720000126800
D200720000126800 01/0001 00002007
!
!
!
I need to check for first letter of each line ie., S, Z, K and D in this case. Based on the letter, I need to check some condition on previous record.
Currently I am using LOOP AT. Within this loop, how can we go back to the previous record?
Thank you,
Warm regards,
Deepak
2008 Jul 10 5:45 AM
Hello
data: pointer type i.
loop at itab.
pointer = sy-tabix - 1.
if itab-field = 'S' or itab-field = 'Z' or itab-field = 'K' or itab-field = 'D'.
read table itab index pointer.
if sy-subrc = 0.
..... do anything here .....
endif.
endif.
endloop.
Hello Experts,
I need your help.
I am looping at an internal table. I have to check for a condition. If this condition is true, I need to check for another condition on the previous record.
This is the IT content:
SINCHFCiVision Heffen
Z200720000126800P0000005544041229320005217381935Eversdijk M. M.
K200720000126800
D200720000126800 01/0001 00002007
!
!
!
I need to check for first letter of each line ie., S, Z, K and D in this case. Based on the letter, I need to check some condition on previous record.
Currently I am using LOOP AT. Within this loop, how can we go back to the previous record?
Thank you,
Warm regards,
Deepak
2008 Jul 10 5:39 AM
hi you can use the sy-tabix.
loop at itab into wa_itab.
if condition = true.
vl_previous = sy-tabix - 1.
read table itab index vl_previous.
if sy-subrc eq 0.
ur code...
endif.
else...
some other code..
endloop.
2008 Jul 10 5:45 AM
Hello
data: pointer type i.
loop at itab.
pointer = sy-tabix - 1.
if itab-field = 'S' or itab-field = 'Z' or itab-field = 'K' or itab-field = 'D'.
read table itab index pointer.
if sy-subrc = 0.
..... do anything here .....
endif.
endif.
endloop.
2008 Jul 10 6:01 AM
Thank you so much everybody.
Points rewarded!!!
Cheers,
Deepak
2008 Jul 10 5:48 AM
hi,
Try using two internal table containing same records.
call that 2nd internal table within loop of 1st internal table.
Loop at itab1.
if ( your condition ).
loop at itab2.
endloop.
endif.
endloop.
Best Regards,
SUDHIR MANJAREKAR
2008 Jul 10 5:54 AM
Before ENDLOOP. move your current work area to temparory workarea. So when you are on the second record. you will get the reference of first record from temp. Work area.
You can overwrite this temp. workarea once your conditions are satisfied or everytime.
Loop at Itab
Your logical conditions to
..
.
.
.
..
move itab to temp_itab.
endloop