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

How to refresh/initialize sy-tabix in a loop?????

Former Member
0 Likes
3,976

Dear all,

Please do let me know how to refresh/initialize 'sy-tabix' for every new document in a loop statement.

Thanx in advance.

Alok.

Dear all,

Please do let me know how to refresh/initialize 'sy-tabix' for every new document in a loop statement.

Thanx in advance.

Alok.

8 REPLIES 8
Read only

Former Member
0 Likes
1,866

Hi

I can't understand your request, what does "Initialize sy-tabix" mean?

That system variable has the index of the current record while looping an internal table, so what do you really need to do?

Max

Read only

Former Member
0 Likes
1,866

why do you need to refresh or initialize system variables.

more over most system varialble do not change

Read only

Former Member
0 Likes
1,866

Move the content of sy-yabix into a local varaibel lv_tabix and clear this lv_tabix in side the loop.

loop at itab.

lv_tabix = sy-tabix.

clear lv_tabix.

  • Use lv_tabix in place of sy-tabix

endloop.

Read only

Former Member
0 Likes
1,866

HI

GOOD

Read TABLE and Modify

read table t_vbap

with key ps_psp_pnr = t_tab-pspnr binary search.

t_vbap-kunnr = w_kunnr.

modify table t_vbap index sy-tabix.

sy-tabix is the index number of the currently processed row for an internal table.

you can initialize the sy-tabix using if loop.

THANKS

MRUTYUN

Read only

Former Member
0 Likes
1,866

Never try to refresh or initialize system variable. It shall always lead to errors in the programs. For this I have an alternative way below.

Please declare a variable for e.g

data: <b>l_count</b> type sy-tabix.

Inside loop you can write the code like this:

say for eg. you need to refresh l_count for every new material.

Loop at itab.

on change of itab-material.

clear : l_count.

endon.

l_count = l_count + 1.

......

endloop.

Hope this clarifies your issue.

Lakshminarayanan

Read only

rahulkavuri
Active Contributor
0 Likes
1,866
LOOP AT IT_VBRK.

    CTAB = SY-TABIX.

    LOOP AT IT_T001 WHERE BUKRS = IT_VBRK-BUKRS.

      IF SY-SUBRC  = 0.
        IT_VBRK-BUTXT = IT_T001-BUTXT.
        MODIFY IT_VBRK INDEX CTAB.
        CLEAR CTAB.
      ENDIF.

    ENDLOOP.

  ENDLOOP.

Check the code above which helps u on Sy-TABIX

Read only

Former Member
0 Likes
1,866

Hi,

what do you mean by refresh/initialize?

please be more clear..

data: l_index type sy-tabix.
Loop at itab.

l_index = sy-tabix.
.......
.....

clear l_index.

endloop.

Regards

vijay

Read only

Former Member
0 Likes
1,866

Hi ALOK,

I think its not possible.

regards,

keerthi.