‎2011 Jan 11 7:26 AM
Hi Experts,
I need to know that is it possible that we can decrease or change value of SY-TABIX.
EXAMPLE:
I am using a;
loop at itab. --> at this stage sy-tabix is 1.
for instance current value of sy-tabix is changed to 4 and now I want to make it 3.
in this case I want to read the 3 value in loop again.
So is it possible that I can change my SY-TABIX value from 4 to 3 and read that 3rd record in the loop?
endloop.
can anyone let me know.
thanks in advance.
Regards,
Yahya
‎2011 Jan 11 7:34 AM
Hi
this is not possible directly to change the values of system variables
but the other way is there
what you can do is to move the valuw of sy-tabix in a variable and then loop through the table to that value,
like:
lv_tabix like sy-tabix.
loop at itab into wa where sy-tabix = lv_tabix.
after loop statement.
lv-tabix = sy-tabix.
you code............
before enloop .
lv_tabix = sy-tabix - 1.
endloop.
I am not sure about the above code but you can try something like above.
Thanks
Lalit
‎2011 Jan 11 7:43 AM
I HAVE ALREADY TRIED THIS BUT PROBLEM STILL PERSISTS..
THANKS,
‎2011 Jan 11 7:48 AM
Hello Yahya,
You can try it this way though:
DATA: LV_TABIX TYPE SY-TABIX.
LOOP AT ITAB INTO WA.
* Perform your calculations on LV_TABIX as per your logic & set the value of LV_TABIX
READ TABLE ITAB INTO WA_TEMP INDEX LV_TABIX.
IF SY-SUBRC = 0.
* Write your logic here
ENDIF.
ENDLOOP.BR,
Suhas
‎2011 Jan 11 9:26 AM
Thanks everyone.
I came up with this solution.
loop at it_ship3
index = index - 1.
sy-tabix = index.
read table it_ship3 INDEX index into wa_ship.
append wa_ship to it_ship4.
endloop.I have taken that current index value and read data from the table directly with respect to that index.
Regards,
Yahya
‎2011 Jan 11 9:38 AM
Hi Yahya,
There is no need of
"sy-tabix = index."
It can be removed.
Thanks,
Preyansh
‎2011 Jan 11 9:51 AM
Dear Preyansh,
I'm using that sy-tabix in other scenario that is not displayed in above code. And that's the only reason for using
"sy-tabix = index."
Still appreciate your input.
Regards,
Yahya