‎2006 Jun 22 11:26 AM
Hello Friends,
I would like to know if its possible to access the next comming element inside the loop as we have in java, FOR loop ++ or +1 stuff.
Actually I have to create dynamic selection ( fields- name, sign, value, I have in an internal table) and inside the where clause I have to put 'AND' or 'OR' depending upon if field is same or change....if the field is same I have to use OR and if field changes I have to use AND.
Many thanks for your kind inputs,
Regards,
So I just have to see the next field inside the loop, if next is same, I will place OR at the end of previous statement, and if next comming field is different I have to place AND at the end of previous statement.
‎2006 Jun 22 11:28 AM
loop at itab.
lv_tabix = sy-tabix + 1.
read table itab into wa index lv_tabix.
now the work area wa will have the next record.
endloop.
Regards,
Ravi
‎2006 Jun 22 11:33 AM
Hi ,
Use this.
DATA : l_index TYPE sy-tabix.
LOOP AT t_marc INTO wa_marc.
l_index = sy-tabix + 1.
READ TABLE t_mara INTO wa_mara read table itab INDEX l_index.
"Some Processing
CLEAR l_index.
ENDLOOP.
Regards,
Arun S.
Message was edited by: Arun Sambargi
‎2006 Jun 22 11:36 AM
Hi,
Use sy-tabix+1 for internal table and
sy-index+1 for do loop.
loop at itab.
lv_index = sy-tabix.
lv_index = lv_index + 1.
read table itab index lv_index.
if sy-subrc eq 0.
endif.
endloop.
Regards
Amole
‎2006 Jun 22 11:48 AM
Hi All,
many thanks for your kind inputs, all replies were more or less same, so points will be awarded on first come first serve bases, but many thanks to all of you for your kind replies,
I will be get back if it works as i expected
till then...
One question: if table index + 1 (sy-tabix+1) does not exists, I will get DUMP ???
Message was edited by: Shah H
‎2006 Jun 22 11:59 AM
Hi
If index + 1 does not exist then it will return
SY_SUBRC <> 0
i.e
SY-SUBRC = 4
Sameena
Message was edited by: sameena attarwala
‎2006 Jun 22 11:57 AM
hi Shah,
Declare a local variable that holds sy-tabix value.
data : lv_tabix type sy-tabix.
loop at itab.
*Increase the value by 1.
lv_tabix = sy-tabix + 1.
read table itab into wa index lv_tabix.
now the work area wa will have the next record.
**//here you can do your processing.
endloop.
Hope this will help you.
Regards,
Richa
‎2006 Jun 22 12:10 PM
Hi Shah,
first get the value of sy-tabix in a local variable i.e.
l_index.
loop at t_itab.
l_index = sy-tabix.
l_index = l_index + 1.
read table t_itab index l_index.
endloop.
hope this works for u.
Seema