Skip to Content
avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

8 Answers

  • avatar image
    Former Member
    May 22, 2006 at 10:08 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2006 at 10:10 AM

    why do you need to refresh or initialize system variables.

    more over most system varialble do not change

    Add comment
    10|10000 characters needed characters exceeded

  • May 22, 2006 at 10:10 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2006 at 10:11 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2006 at 10:13 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2006 at 10:13 AM
    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

    Add comment
    10|10000 characters needed characters exceeded

  • May 22, 2006 at 10:16 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2006 at 10:25 AM

    Hi ALOK,

    I think its not possible.

    regards,

    keerthi.

    Add comment
    10|10000 characters needed characters exceeded