Application Development 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: 

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

why do you need to refresh or initialize system variables.

more over most system varialble do not change

former_member181962
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

rahulkavuri
Active Contributor
0 Kudos
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

former_member188685
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi ALOK,

I think its not possible.

regards,

keerthi.