Reg:SY-TABIX

Hi,
  Can anybody please tell me how to display the record at a particular sy-tabix value in an internal table i.e how can i get the
field value be displayed at that particular sy-tabix value??

Hi Nandi,
you can sumthing like...
loop at itab.
if sy-tabix = x.
  write:.....
endif.
endloop.
SY-TABIX - Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.
APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.
COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.
LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.
READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.
regards,
pritam.

Similar Messages

  • Reg:rfc

    Hai to all,
    I am created one below rfc function module. that is ZTEST_FUNC.
    Expert Forums » ABAP Development » ABAP Dictionary
    Thread: reg:fm
    Welcome, chaitu sumi   
    Your Control Panel 
    Your Reward Points 
    Your Questions 
    There are new replies to your question.
    Mark question as still not answered.
    Mark question as answered.
    Use the radio buttons to award points to replies.
      You are watching this thread. To stop watching this thread, click "Stop Watching Thread" below. (Watch Options) 
    This watch sends emails by default. If you don't want to receive emails on changes in this thread, go to the watch options, un-mark the "Email" checkbox next to the thread's entry and click "Update". 
    Reply to this Thread   Search Forum    Stop Watching Thread    Back to Thread List 
      Replies: 2 - Pages: 1 - Last Post: Aug 6, 2007 5:03 PM by: Sudheer Junnuth...  Threads: Previous  
    chaitu sumi  
    Posts: 9
    Questions: 9
    Registered: 7/13/07
    Forum points: 0 
       reg:fm  
    Posted: Aug 6, 2007 4:47 PM         Reply      E-mail this post 
    I created below function module, which is having below import parameters and tables:
    FUNCTION ztest_func.
    ""Local interface:
    *" IMPORTING
    *" VALUE(S_LFDAT1) LIKE LIKP-LFDAT
    *" VALUE(S_LFDAT2) LIKE LIKP-LFDAT OPTIONAL
    *" VALUE(RAIL_ROAD) TYPE CHECKBOX
    *" TABLES
    *" IT_FINAL STRUCTURE ZTLC_SAL
    data: it_cond type n,
    loop_index like sy-tabix .
    select zdelv~vkorg
    zdelv~vbeln
    zdelv~lfart
    zdelv~lfdat
    zdelv~wadat
    zdelv~vtweg
    zdelv~spart
    zdelv~vkbur
    zdelv~vkgrp
    zdelv~kunnr
    zdelv~vsbed
    zdelv~ntgew
    zdelv~route
    zdelv~lgort
    zdelv~inco1
    zdelv~matnr
    zdelv~mvgr1
    zdelv~vsart
    zdelv~rwerks
    zdelv~dwerks
    into corresponding fields of table IT_FRGT
    From zdelv WHERE zdelv~wadat = s_lfdat1 " and s_lfdat2
    AND zdelv~lfart IN ('ZGDP','ZGRR','ZRLF','ZGLF').
    if Sy-subrc = 0.
    Sort it_frgt
    by vbeln dwerks lgort route kunnr regio vkbur vkgrp bran1 cityc.
    Delete adjacent duplicates from it_frgt
    Comparing vbeln dwerks lgort route kunnr
    regio vkbur vkgrp bran1 Cityc.
    Loop_index = 1.
    Loop at it_frgt." to wa_frgt.
    *select kunnr regio from kna1 into kna1 where kunnr = it_frgt-kunnr.
    *select bland from t005u into corresponding fields of table it_regio where Bland = kna1-regio.
    *endselect.
    IF RAIL_ROAD = 'I'.
    IF IT_FRGT-VSBED <> '04'.
    DELETE IT_FRGT.
    clear it_frgt.
    CONTINUE.
    ENDIF.
    ENDIF.
    IF RAIL_ROAD = 'R'.
    IF IT_FRGT-VSBED = '04'.
    DELETE IT_FRGT.
    clear it_frgt.
    CONTINUE.
    endif.
    endif.
    clear wa_frgt.
    select single lifnr from vbpa into vbpa
    where vbeln eq it_frgt-vbeln and
    parvw eq 'ZD'.
    move-corresponding it_frgt to wa_frgt.
    move vbpa-lifnr to wa_frgt-lifnr.
    If wa_frgt-lfart eq 'ZGND' OR
    wa_frgt-lfart eq 'ZGNL' OR
    wa_frgt-lfart eq 'ZGNS'.
    wa_frgt-LVTEXT = 'STA'.
    if wa_frgt-lfart eq 'ZGNS'.
    delete it_frgt.
    continue.
    endif.
    select mseg~werks
    mseg~lgort
    into (wa_frgt-rwerks,wa_frgt-rlgort)
    from vbfa join mseg
    on mseg~mblnr = vbfa~vbeln
    where vbfa~vbelv eq wa_frgt-vbeln and
    vbfa~vbtyp_n = 'i'.
    Endselect.
    wa_frgt-netwr = 0.
    if wa_frgt-netwr = 0.
    select single regio region plant lgobe cityc from zsta
    into corresponding fields of it_zfrgt
    where werks = it_frgt-dwerks
    and lgort = it_frgt-lgort
    and vkorg = it_frgt-vkorg
    and kunnr = it_frgt-kunnr.
    if sy-subrc <> 0.
    select single regio region plant lgobe cityc from zsta into corresponding fields of it_zfrgt
    where werks = it_frgt-dwerks
    and lgort = it_frgt-lgort
    and vkorg = it_frgt-vkorg.
    select single cityc from kna1 into wa_frgt-cityc
    where kunnr = wa_frgt-kunnr.
    it_zfrgt-cityc = wa_frgt-cityc.
    endif.
    select single regio region plant lgobe cityc from zsta into corresponding fields of it_zfrgt1
    where werks = it_frgt-rwerks
    and lgort = it_frgt-rlgort
    and vkorg = it_frgt-vkorg
    and kunnr = it_frgt-kunnr.
    if sy-subrc <> 0.
    select single regio region plant lgobe cityc from zsta into corresponding fields of it_zfrgt1
    where werks = it_frgt-rwerks
    and lgort = it_frgt-rlgort
    and vkorg = it_frgt-vkorg.
    endif.
    else.
    select single regio region plant lgobe cityc from zsta into corresponding fields of it_zfrgt
    where werks = it_frgt-dwerks
    and lgort = it_frgt-lgort
    and vkorg = it_frgt-vkorg.
    endif.
    else.
    select single * from zsta into it_zfrgt
    where werks = it_frgt-dwerks
    and lgort = it_frgt-lgort
    and vkorg = it_frgt-vkorg.
    endif.
    wa_frgt-regio = it_zfrgt-regio.
    wa_frgt-region = it_zfrgt-region.
    wa_frgt-plant = it_zfrgt-plant.
    wa_frgt-lgobe = it_zfrgt-lgobe.
    wa_frgt-cityc = it_zfrgt-cityc.
    wa_frgt-soffice = it_zfrgt1-Plant.
    STA *
    endif.
    if wa_frgt-lfart eq 'ZGDP' OR
    wa_frgt-lfart eq 'ZGDR' OR
    wa_frgt-lfart eq 'ZGRR' OR
    wa_frgt-lfart eq 'ZRLF' OR
    wa_frgt-lfart eq 'ZGLF' OR
    wa_frgt-lfart eq 'ZGLR' .
    if wa_frgt-lfart eq 'ZGLR'.
    delete it_frgt.
    continue.
    endif.
    if wa_frgt-lfart eq 'ZGDR'.
    delete it_frgt.
    continue.
    endif.
    select single WBSTK from LIKPUK into Likpuk-wbstk
    where vbeln = wa_frgt-vbeln.
    if sy-subrc = 0.
    if likpuk-wbstk <> 'C'.
    delete it_frgt.
    clear wa_frgt.
    continue.
    endif.
    endif.
    wa_frgt-LVTEXT = 'SALES'.
    wa_frgt-netwr = 0.
    if wa_frgt-netwr = 0.
    Select single * from ZFRGT into it_zfrgt2
    where werks = it_frgt-dwerks
    and lgort = it_frgt-lgort
    and vkorg = it_frgt-vkorg
    and kunnr = it_frgt-kunnr.
    if sy-subrc <> 0.
    clear it_zfrgt2.
    Select single * from ZFRGT into it_zfrgt2
    where werks = it_frgt-dwerks
    and lgort = it_frgt-lgort
    and vkorg = it_frgt-vkorg.
    if sy-subrc <> 0.
    select single * from t001w
    where werks = it_frgt-dwerks.
    if sy-subrc = 0.
    wa_frgt-plant = t001w-name1.
    select single * from t001l
    where werks = it_frgt-Dwerks and
    lgort = it_frgt-lgort.
    if sy-subrc = 0.
    wa_frgt-lgobe = t001l-lgobe.
    endif.
    it_zfrgt2-lgobe = wa_frgt-lgobe.
    it_zfrgt2-plant = wa_frgt-plant.
    endif.
    Endif.
    Select single * from kna1 where kunnr = it_frgt-kunnr.
    wa_frgt-cityc = kna1-cityc.
    wa_frgt-regio = kna1-regio.
    wa_frgt-bran1 = kna1-bran1.
    select single vtext from tbrct into tbrct where braco = it_frgt-bran1.
    wa_frgt-vtext = tbrct-vtext.
    endselect.
    select single bezei from t005u into t005u where bland = wa_frgt-regio
    and land1 = 'IN'.
    wa_frgt-region = t005u-bezei.
    it_zfrgt2-cityc = wa_frgt-cityc.
    it_zfrgt2-regio = wa_frgt-regio.
    it_zfrgt2-region = wa_frgt-region.
    it_zfrgt2-vtext = wa_frgt-vtext.
    it_zfrgt2-bran1 = wa_frgt-bran1.
    endif.
    endif.
    endif.
    wa_frgt-regio = it_zfrgt2-regio.
    wa_frgt-region = it_zfrgt2-region.
    wa_frgt-plant = it_zfrgt2-plant.
    wa_frgt-lgobe = it_zfrgt2-lgobe.
    wa_frgt-cityc = it_zfrgt2-cityc.
    wa_frgt-vtext = it_zfrgt2-vtext.
    wa_frgt-bran1 = it_zfrgt2-bran1.
    select single * from tvkbt into tvkbt where vkbur = wa_frgt-vkbur.
    if sy-subrc = 0.
    wa_frgt-soffice = tvkbt-bezei.
    endif.
    select single * from tvgrt where vkgrp = wa_frgt-vkgrp.
    if sy-subrc = 0.
    wa_frgt-district = tvgrt-bezei.
    endif.
    endif.
    select single * from zdest into zdest where
    vkorg = wa_frgt-vkorg and
    regio = wa_frgt-regio and
    cityc = wa_frgt-cityc and
    actvt = 'A'.
    if sy-subrc = 0.
    wa_frgt-vtext = zdest-vtext1.
    wa_frgt-bran1 = zdest-ibraco.
    wa_frgt-vkgrp = zdest-ivkgrp.
    select single * from tvgrt into tvgrt where vkgrp = wa_frgt-vkgrp.
    if sy-subrc = 0.
    wa_frgt-district = tvgrt-bezei.
    endif.
    else.
    wa_frgt-vtext = ' '.
    wa_frgt-bran1 = ' '.
    wa_frgt-district = ' '.
    endif.
    endselect.
    *endselect.
    *IF kna1-regio IS NOT INITIAL.
    Read table it_regio with key BLAND = wa_FRGT-REGIO.
    IF SY-SUBRC <> 0.
    DELETE IT_FRGT.
    clear it_frgt.
    CONTINUE.
    ENDIF.
    ENDIF.
    if wa_frgt-lfart eq 'ZGDR'.
    wa_frgt-NQGEW = wa_frgt-NTGEW.
    wa_frgt-NQGEW = wa_frgt-NQGEW * 1.
    else.
    wa_frgt-NQGEW = wa_frgt-NTGEW.
    wa_frgt-NQGEW = wa_frgt-NQGEW * 1.
    endif.
    if wa_frgt-vsbed <> '04'.
    Wa_frgt-t_mode = 'Road'.
    else.
    Wa_frgt-t_mode = 'Rail'.
    endif.
    it_cond = 0.
    if wa_frgt-netwr eq 0.
    if wa_frgt-vsbed <> '04'.
    select * from a531 into a531
    where werks eq wa_frgt-dwerks and
    zzlgort eq wa_frgt-lgort and
    cityc eq wa_frgt-cityc
    order by datbi DESCENDING.
    if sy-subrc = 0.
    it_cond = 1.
    if ( a531-datbi >= sy-datum and
    a531-datab <= sy-datum ).
    wa_frgt-knumh = a531-knumh.
    exit.
    endif.
    endif.
    endselect.
    if it_cond = 0.
    select * from a524 into a524
    where werks eq wa_frgt-dwerks and
    ZZTRANSP eq wa_frgt-lifnr and
    cityc eq wa_frgt-cityc
    order by datbi DESCENDING.
    if sy-subrc = 0.
    it_cond = 1.
    if ( a524-datbi >= sy-datum and
    a524-datab <= sy-datum ).
    . wa_frgt-knumh = a524-knumh.
    exit.
    endif.
    endif.
    endselect.
    endif.
    if it_cond = 0.
    select * from a530 into a530
    where werks eq wa_frgt-dwerks and
    ZZLGORT eq wa_frgt-lgort and
    inco1 eq wa_frgt-inco1 and
    cityc eq wa_frgt-cityc
    order by datbi DESCENDING.
    if sy-subrc = 0.
    it_cond = 1.
    if ( a530-datbi >= sy-datum and
    a530-datab <= sy-datum ).
    wa_frgt-knumh = a530-knumh.
    exit.
    endif.
    endif.
    endselect.
    endif.
    if it_cond = 0.
    select * from a527 into a527
    where werks eq wa_frgt-dwerks and
    ZZLGORT eq wa_frgt-lgort and
    ZZTRANSP eq wa_frgt-lifnr and
    cityc eq wa_frgt-cityc
    order by datbi DESCENDING.
    if sy-subrc = 0.
    it_cond = 1.
    if ( a527-datbi >= sy-datum and
    a527-datab <= sy-datum ).
    wa_frgt-knumh = a527-knumh.
    exit.
    endif.
    endif.
    endselect.
    endif.
    endif.
    else.
    select * from a519 into a519
    where vsbed eq wa_frgt-vsbed and
    rke_route eq wa_frgt-route
    order by datbi DESCENDING.
    if sy-subrc = 0.
    it_cond = 1.
    if ( a519-datbi >= sy-datum and
    a519-datab <= sy-datum ).
    wa_frgt-knumh = a519-knumh.
    exit.
    endif.
    endif.
    endselect.
    endif.
    if wa_frgt-knumh is not initial.
    select single * from konp into konp
    where knumh = wa_frgt-knumh.
    move konp-kbetr to wa_frgt-netwr.
    if konp-KMEIN = 'BAG'.
    wa_frgt-NQTWR = wa_frgt-NETWR *
    ( wa_frgt-ntgew * ( 20 / konp-kpein ) ).
    else.
    wa_frgt-NQTWR = wa_frgt-NETWR * wa_frgt-ntgew.
    endif.
    else.
    delete it_frgt.
    clear wa_frgt.
    continue.
    endif.
    else.
    wa_frgt-NQTWR = wa_frgt-NETWR.
    endif.
    CLEAR ZFREIGHT.
    if wa_frgt-vsbed = '04'.
    select single distn frgt from Zfreight into Zfreight
    Where Werks eq wa_FRGT-DWERKS
    AND LGORT eq wa_FRGT-LGORT
    AND route eq wa_FRGT-route.
    else.
    if ( it_frgt-lfart = 'ZGNL' ) OR ( it_frgt-lfart = 'ZGLF' ).
    Select single * from Zfreight into Zfreight
    Where Werks eq wa_FRGT-DWERKS
    AND cityc eq wa_FRGT-cityc
    AND route eq wa_FRGT-route.
    else.
    Select single * from Zfreight into Zfreight
    Where Werks eq wa_FRGT-DWERKS
    AND LGORT eq wa_FRGT-LGORT
    AND cityc eq wa_FRGT-cityc
    AND route eq wa_FRGT-route.
    endif.
    endif.
    if sy-subrc = 0.
    wa_FRGT-RRKM = ZFREIGHT-DISTN.
    if wa_frgt-rrkm > 0.
    wa_frgt-NKTWR = wa_frgt-rrkm * wa_frgt-ntgew.
    endif.
    IF ZFREIGHT-FRGT = 'P'.
    wa_frgt-BEZEI = 'Primary Freight'.
    Endif.
    IF ZFREIGHT-FRGT = 'S'.
    wa_frgt-BEZEI = 'Secondary Freight'.
    Endif.
    endif.
    modify it_frgt from wa_frgt index loop_index .
    Loop_index = loop_index + 1.
    endloop.
    endif.
    Sort it_frgt by Regio dwerks lgort Vkbur district bran1 mvgr1 t_mode.
    Clear:WA_frgt.
    Loop at it_frgt.
    If wa_frgt is initial.
    move-corresponding it_frgt to wa_frgt.
    wa_frgt-NQGEW = 0.
    wa_frgt-NQTWR = 0.
    wa_frgt-NKTWR = 0.
    endif.
    if it_frgt-lfart eq 'ZGDR' .
    it_frgt-NQGEW = it_frgt-NQGEW * -1.
    it_frgt-NQTWR = it_frgt-NQTWR * -1.
    it_frgt-NKTWR = it_frgt-NKTWR * -1.
    endif.
    if it_frgt-regio = wa_frgt-regio and
    it_frgt-dwerks = wa_frgt-dwerks and
    it_frgt-lgort = wa_frgt-lgort and
    it_frgt-vkbur = wa_frgt-vkbur and
    it_frgt-district = wa_frgt-district and
    it_frgt-bran1 = wa_frgt-bran1 and
    it_frgt-t_mode = wa_frgt-t_mode.
    wa_frgt-NQGEW = wa_frgt-NQGEW + it_frgt-NQGEW.
    wa_frgt-NQTWR = wa_frgt-NQTWR + it_frgt-NQTWR.
    wa_frgt-NKTWR = wa_frgt-NKTWR + it_frgt-NKTWR.
    else.
    Append wa_frgt to it_sfrgt.
    Clear wa_frgt.
    move-corresponding it_frgt to wa_frgt.
    wa_frgt-NQGEW = 0.
    wa_frgt-NQTWR = 0.
    wa_frgt-NKTWR = 0.
    wa_frgt-NQGEW = WA_frgt-NQGEW + it_frgt-NQGEW.
    wa_frgt-NQTWR = wa_frgt-NQTWR + it_frgt-NQTWR.
    wa_frgt-NKTWR = wa_frgt-NKTWR + it_frgt-NKTWR.
    endif.
    AT LAST .
    Append wa_frgt to it_sfrgt.
    Clear wa_frgt.
    ENDAT.
    endloop.
    sort it_sfrgt by regio dwerks lgort Vkbur district bran1 t_mode rrkm nqgew nqtwr nktwr avg_frt.
    Loop At IT_SFRGT.
    IT_SFRGT-RRKM = 0 .
    IF IT_SFRGT-NQGEW > 0 AND IT_SFRGT-NQTWR > 0.
    IT_SFRGT-AVG_FRT = IT_SFRGT-NQTWR / IT_SFRGT-NQGEW.
    ENDIF.
    IF IT_SFRGT-NQGEW > 0 AND IT_SFRGT-NKTWR > 0.
    IT_SFRGT-RRKM = IT_SFRGT-NKTWR / IT_SFRGT-NQGEW.
    ENDIF.
    IF IT_SFRGT-RRKM > 0 AND IT_SFRGT-AVG_FRT > 0.
    IT_SFRGT-FRT_RT = IT_SFRGT-AVG_FRT / IT_SFRGT-RRKM.
    ENDIF.
    MODIFY IT_SFRGT .
    Endloop.
    Sort it_sfrgt by REGION vkorg dwerks lgort t_mode rwerks mvgr1.
    loop at it_sfrgt.
    move-corresponding it_sfrgt to itab1.
    append itab1.
    endloop.
    loop at itab1.
    move-corresponding itab1 to IT_FINAL.
    append it_final.
    endloop.
    ENDFUNCTION.
    AND I created another function module ZTEST_RFC.
    In ZTEST_RFC MODULE I AM CALLING ABOVE FUNCTION MODULE ZTEST_FUNC.
    NOW its going to dump its showing the error CALL_FUNCTION_UC_STRUC RUNTIME ERROR IS COMING.
    how can i solve this problem could any body tell me its very urgent.
    In ZTEST_FUNC  function module only i am collecting the data and put into IT_FINAL INTERNAL TABLE.

    According to
    http://help.sap.com/saphelp_nw04/helpdata/en/f9/3f69fd11a80b4e93a5c9230bafc767/content.htm
    The reason for the Runtime error: CALL_FUNCTION_UC_STRUCT is that "Type conflict while transferring structure ".
    I'd suggest therefore that you check the definition of the variables in ZTEST_RFC where it calls ZTEST_FUNC as there would seem to be a mismatch.  If you are editing ZTEST_RFC, try using the Check > Extended check functionality as this will typically pinpoint such problems for you.

  • Which to use - Sy-index or sy-tabix ??

    This is what i found out about SY-INDEX and SY-TABIX but which one to use when i want to delete a line of data from an internal table ? I tried both sy-index and sy-tabix and both works fine and returning the expected output for me but which one is better of to use ?
    SY-TABIX :- For Internal Table, Current Line Index
    SY-INDEX :- For Loops, Current Loop Pass
    The below code is where i uses the Delete ..
    LOOP AT dmg.
            CONCATENATE
                   dmg-dmg00
                   dmg-dmg01
                   dmg-dmg02
                   dmg-dmg03
                   dmg-dmg04
                   dmg-dmg07
                   dmg-dmg08
                   dmg-dmg09 INTO tli_down1 SEPARATED BY '*'.
            APPEND tli_down1. CLEAR tli_down1.
            DELETE dmg INDEX sy-index.
            EXIT.
          ENDLOOP.

    Right. Just like what they said upstairs, sy-babix is the best choice.
    One more thing is, if you want to concatenate fields of table dmg and append to tli_down1 on by one. You should not use EXIT after delete dmg.
    In that case ,only one line can be appended into tli_down1 table.
    > The below code is where i uses the Delete ..
    >
    > LOOP AT dmg.
    >         CONCATENATE
    >        dmg-dmg00
    >         dmg-dmg01
    >        dmg-dmg02
    >         dmg-dmg03
    >        dmg-dmg04
    >         dmg-dmg07
    >        dmg-dmg08
    >         dmg-dmg09 INTO tli_down1 SEPARATED BY '*'.
    >   APPEND tli_down1. CLEAR tli_down1.
    >       DELETE dmg INDEX sy-index.
    >   EXIT.
    >     ENDLOOP.

  • INDEX vs TABIX

    Hi,
    Can some body explain the CLEAR difference between Sy-index and Sy-tabix. And one or two small examples. I am little bit confused.
    Thanx.

    Hi,
    SY-INDEX
    In a DO or WHILE loop, SY-INDEX contains the number of loop passes including the current pass.
    SY-TABIX
    Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.
    APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.
    COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.
    LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.
    READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.
    SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search string is found.
    regards,
    madhu

  • Sy-tabix value has changed...

    Hi Gurus,
    I  am using a code like dis...this is not the actual code m using instad m sendin u a sample program so that u can understand the problem
    There is a selecvtion for Customer.
    sort itab by kunnr.
    loop at itab.
    on change of itab-kunnr.
    wkunnr = itab-kunnr.
      read table zitab with key kunnr = itab-kunnr.
    endon.
    if itab-kunnr = wkunnr.
    wdmbtr = wdmbtr + itab-dmbtr.
    endif.
    at end of kunnr.
    ftab-kunnr = wkunnr.
    ftab-dmbtr = wdmbtr.
    append ftab.
    endat.
    endloop.
    Now my problem is that  AT END OF Kunnr is working fine for the first customer or say for single customer but when there are multiple customers  AT END OF kunnr is triggring for each entry.......
    In debug MOdei can see that as soon as read table  syntax is used the tabix value is changed....
    So Can anyone suggest what is the solution....
    Regards,
    Raman

    This is the Declaration
    DATA:  BEGIN OF ITAB OCCURS 0,
                      KUNNR      LIKE BSID-KUNNR,
                      BELNR      LIKE BSID-BELNR,
                      BUKRS      LIKE BSID-BUKRS,
                      GJAHR      LIKE BSID-GJAHR,
                      BUZEI      LIKE BSID-BUZEI,
                      SHKZG      LIKE BSID-SHKZG,
                      VALUT      LIKE BSID-ZFBDT,
                      SGTXT(70)  TYPE  C,
                      ZFBDT      LIKE BSID-ZFBDT,
                      ZBD1T       TYPE BSID-ZBD1T,
           ZBD2T       TYPE BSID-ZBD2T,
           ZBD3T       TYPE BSID-ZBD3T,
           REBZG       TYPE BSID-REBZG,
           NETDT       TYPE BSID-BUDAT,
                      ZUONR      LIKE BSID-ZUONR,
                       BLART      LIKE BSID-BLART,
                      DMBTR      LIKE BSID-DMBTR,
                      SPART       TYPE VBRK-SPART,
                      DAY    TYPE RFPOSX-VERZN,
                      FLAG TYPE C,
                      CITY        TYPE KNA1-ORT01,
           NAME1       TYPE LFA1-NAME1,
                     CR_DR1(4)  TYPE C,
                      PSWSL      LIKE BSID-PSWSL,
                      ZTERM      LIKE BSID-ZTERM,
                      VBELN      LIKE BSID-VBELN,
                      UMSKZ      LIKE BSID-UMSKZ,
                      KLIMK      LIKE KNKK-KLIMK,
                      VTEXT      LIKE TVZBT-VTEXT,
                      ADV        LIKE BSID-DMBTR,
                      REBZT       TYPE BSID-REBZT,
                      XBLNR      LIKE BSID-XBLNR,
                      VTEXT1(70) TYPE  C,
                       FKLIMK    LIKE KNKK-KLIMK,
                      ABC(4)     TYPE C,
                    AGRO(4)        TYPE C,
                      BIO(4)        TYPE C,
                      SKFOR      LIKE KNKK-SKFOR,
                      SSOBL      LIKE KNKK-SSOBL,
                      CTLPC      LIKE KNKK-CTLPC,
                      OEIKW      LIKE S066-OEIKW,
                      OLIKW      LIKE S067-OLIKW,
                      OFAKW      LIKE S067-OFAKW,
                     NAME1      LIKE LFA1-NAME1,
                      BUDAT      LIKE BKPF-BUDAT,
                      D_DMBTR    LIKE BSID-DMBTR,
                      S_DMBTR    LIKE BSID-DMBTR,
                      VORGN      LIKE BSEG-VORGN,
                      WERKS      LIKE BSEG-WERKS,
                      NAMESO     LIKE KNA1-NAME1,
                      NAMEAM     LIKE KNA1-NAME1,
                      NAMERM     LIKE KNA1-NAME1,
                       NAMEDR     LIKE KNA1-NAME1,
       END OF ITAB.

  • Sy-tabix question

    Hi,
    If i delete records within a loop the sy-tabix remain with initial value?
    code:
    loop at itab.
    if itab-a = 'please delete'.
    fi_tabix = sy-tabix.
    loop at itab where b = c.
    if itab-d = 0.
      delete itab.
    endif.
    endloop.
    read table itab index fi_tabix. 'return to in loop previous record
    endif.
    endloop.
    Regards
    Juan

    hi Juan,
    i suggest you to dont delete the records in side the loop. <b>two ways</b> ...
    1. maintailn extra field(example flage type c) in itab.--then loop the table change the faag = 'X'. then endloop.
    then delete itab where flag = 'X'.
    <b>or</b>
    2. use the field symbols the
    example
    FIELD-SYMBOLS <FS_WA_ITAB> TYPE (ITAB TYPE).
    LOOP AT ITAB ASSIGNING <FS_WA_ITAB>.
    IF XXXX CONDITION.
    CLEAR <FS_WA_ITAB>.
    ENDIF.
    ENDLOOP.
    DELETE ITAB WHERE FIELS 1 IS INITIAL
    Why iam using this last delete is when you clear using the field symbols.. data will be cleared from the table but the empty rowsa will be remain.. that why iam using the DELETE after the loop.
    <b>if u use the 2nd way it is good.</b>
    Please Close this thread.. when u r problem is solved
    Reward if Helpful
    Regards
    Naresh Reddy K
    Message was edited by:
            Naresh Reddy

  • Sy-tabix for internal table in smartform

    Hi friends,
    How to capture the sy-tabix value for the entries in an internal table which has been looped into the loop of table node of a smartform?? I need to print something immedaitely after the end of the table
    For every record the value of sy-tabix is showing 1 !!
    Advance Thanks
    Aadarsh

    Hi Aadarsh,
    Give ur sy-tabix at the end of the loop.
    loop at itab.
    //table node populations.
    endloop.
    give a seperate loop for this.
    loop at itab.
    sy-tabix.
    endloop
    get the total no and print it after the table.
    If u r using do loop then give sy-index.
    Hope tihs helps u,
    Regards,
    Nagarajan.
    Message was edited by: Nagarajan Kumarappan

  • Sy-tabix in loop : Doubt

    LOOP AT i_lfa1 INTO wa_lfa1 WHERE werks = space.       
       wf_tabix = sy-tabix.                                 
       APPEND wa_lfa1 TO i_lfa1_werks.                      
       DELETE i_lfa1 index wf_tabix.                        
    ENDLOOP.                                               
    in the above code the sy-tabix is always 2.
    what i want to know is if there is a where clause , should we not use the sy-tabix for deletion.

    >
    Keshav.T wrote:
    > May be ill  get something from sap help.
    Hello Keshav,
    As a matter of fact , I always do
    SAP says:
    If you delete the current line or lines in front of the current line, the internal loop counter is decreased by one with each deleted line. In the case of loops on index tables or if using a sorted key, this affects sy-tabix in the subsequent loop pass, and sy-tabix is decreased accordingly
    @Dzed: Hail SAP Help !!! Anyways this was common sense & i dont think SAP processor is dumb
    Cheers,
    Suhas
    Edited by: Suhas Saha on Jan 28, 2010 6:46 PM

  • Sy-tabix

    one can set the value of sy-tabix dynamically(in a program) or not?

    YES IT IS POSSIBLE TO DO IT.
    example
    read table p_it_history with key ebeln = wa_final-ebeln
                                         ebelp = wa_final-ebelp
                                         binary search transporting no fields.
        loop at p_it_history into wa_history from sy-tabix
                                             where ebeln = wa_final-ebeln
                                             and   ebelp = wa_final-ebelp.
          wa_final-bewtp = wa_history-bewtp.
          wa_final-bwart = wa_history-bwart.
          wa_final-belnr = wa_history-belnr.
          wa_final-buzei = wa_history-buzei.
          wa_final-budat = wa_history-budat.
          wa_final-bpmng = wa_history-bpmng.
          wa_final-wrbtr = wa_history-wrbtr.
          wa_final-shkzg = wa_history-shkzg.
          wa_final-vgabe = wa_history-vgabe.
          append wa_final to p_it_final.
    plz reawrd if useful
    keep rockin
    vivek

  • Sy-tabix when using secondary key

    Hi,
    I have an internal table with records that contain a field with the line index of another table entry that they depend on.
    I can process this table recursively, by passing the parent index inside and using a
    LOOP AT ... USING KEY secondary_key WHERE index = iv_index.
    Unfortunately the sy-tabix is afterwards not correct, it contains the position in the secondary key probably instead the position in the internal table.
    Is there a way how I could find out the current table index, when using a secondary key to read a record?
    Regards,
    Bruno

    I rewrote it to include the row index also, not only the dependency.. was thinking too generic

  • Sy-tabix in relation to LOOP AT and READ TABLE

    Hi All,
    As per SAP documentation,
    1) While looping through an internal table (LOOP AT), sy-tabix contains the index number of current row(for standard and sorted tables)
    2)When successfully reading from an internal table(READ TABLE), sy-tabix is set to the index of the result row.
    But what happens when READ TABLE is used while looping through another internal table?
    i.e. Loop at TAB1...
    write sy-tabix.
    READ TABLE TAB2...
    write sy-tabix.
    endloop.
    If we are looping through 1st row of TAB1 and the result of read statement is found in 3rd row of TAB2, I expected that sy-tabix before READ would be 1 and after the READ be 3.
    But, I found that sy-tabix remains unchanged at 1. Can someone expalin why?
    Thanks,
    Jagan

    Hi
    If after reading the table TAB2 the system variable SY-TABIX has still the previous value, that menas the READ TABLE fails or it was read the first record of TAB2.
    After READ TABLE TAB2 try to check the SY-SUBRC:
    LOOP AT TAB1.
       WRITE: / 'TAB1 index:', SY-TABIX.
       READ TABLE TAB2 .........
       IF SY-SUBRC = 0.
         WRITE: 'TAB2 index:', SY-TABIX.
    Try this:
    DATA: BEGIN OF ITAB OCCURS 0,
            FIELD1,
          END   OF ITAB.
    DATA: BEGIN OF ITAB2 OCCURS 0,
            FIELD1,
          END   OF ITAB2.
    DATA: INDEX TYPE I.
    DO 10 TIMES.
      APPEND ITAB.
    ENDDO.
    DO 10 TIMES.
      APPEND ITAB2.
    ENDDO.
    LOOP AT ITAB.
      WRITE: / 'ITAB:', SY-TABIX.
      INDEX = SY-TABIX + 2.
      READ TABLE ITAB2 INDEX INDEX.
      IF SY-SUBRC = 0.
        WRITE:  'ITAB2:', SY-TABIX.
      ENDIF.
    ENDLOOP.
    Max

  • Sy-tabix problem

    Hi,
    i am modifying a internal table in which i am using this statement :-
    MODIFY T_DD FROM W_DD INDEX SY-TABIX
    and the work area is further used to insert the data base table . i just want to know that is this the correct way to modify the internal table bcoz when i execute the program for updating the database it is hardly taking 1 minute  to get updated and i think the problem lies in the above statement.
    Please provide me guidelines to sove this problem.

    Hi,
    Refer below code
    LOOP AT it_crmm_territory INTO wa_crmm_territory.
            l_index = sy-tabix.
            CLEAR : wa_crmm_territory_v.
            READ TABLE it_crmm_territory_v INTO wa_crmm_territory_v WITH KEY terr_guid = wa_crmm_territory-terr_guid.
            IF sy-subrc EQ 0.
              wa_crmm_territory-valid_from = wa_crmm_territory_v-valid_from.
              wa_crmm_territory-valid_to   = wa_crmm_territory_v-valid_to.
              wa_crmm_territory-guid       = wa_crmm_territory_v-guid.
            ENDIF.
            MODIFY it_crmm_territory FROM wa_crmm_territory INDEX l_index
                                          TRANSPORTING guid valid_from valid_to.
            CLEAR : wa_crmm_territory.
          ENDLOOP.
    Regards,
    Prashant

  • SY-TABIX value of a loop in other loop in other loop.

    Hello Gurus,
    I have a problem i want to modify some columns in final internal table and it is possible by using Transporting and Index but when i see SY-TABIX value it is not really giving particular loop iteration value. Because my present loop is in another loop and it is in another loop. Please gurus help me out
    or
    How to Insert particular filed columns  and how to use where clause in insert..
    Thanks.

    Hi !
    Here are things you could do:
    1. You can use nested loops with the WHERE statement on the inner loop. But this can be slow.
         This will look like this
                   loop at i_tab1 into wa1
                   loop at i_tab2 into wa2 where cond1 = wa1-cond1....
                     (   move wa2-field3 to wa1-field3.....)
                        modify i_tab1.
                   endloop.
                   endloop.
    2. You can use the parallel cursor technique as suggested above.
         This technique speeds up processing of data significantly. Here it is:
         data lv_tabix type i.
              sort i_tab1 by field1 ascending.
              sort i_tab2 by field1 ascending.
              loop at i_tab1 into wa1
              read table i_tab2 transporting no fields with key cond1 = wa1-cond1 binary search.
              lv_tabix = sy-tabix.
                   loop at i_tab2 into wa2 from lv_tabix.
                        if wa2-cond1 <> wa1-cond1.
                                   exit.       
                         endif.
                   ( move wa2-field3 to wa1-field3.....)
                        modify i_tab1.
                    endloop.
              endloop.
    Please let me know if you want more explanation

  • Sy-tabix Pboblem ?

    Before this loop sy-tabix becomes 17 .
    and when sy-subrc is 0
    instead of deleting the first line it deletes the 17th.
    CLEAR: SY-SUBRC,SY-TABIX.
      SORT: IT_FINAL, IT_TE, IT_TEM." BY VBELN POSNR.
      DELETE ADJACENT DUPLICATES FROM IT_TE  COMPARING VBELN.
      DELETE ADJACENT DUPLICATES FROM IT_TEM COMPARING VBELV.
      SORT: IT_TE,IT_TEM.
      LOOP AT IT_TE INTO WA_TE.
        READ TABLE IT_TEM INTO WA_TEM WITH KEY VBELV = WA_TE-VBELN
                                               POSNV = WA_TE-POSNR.
        CLEAR SY-TABIX.
        IF SY-SUBRC EQ 0.
          DELETE IT_TE INDEX SY-TABIX.
        ENDIF.
        MOVE: WA_TE-VBELN TO WA_TEMP-VBELN,
              WA_TE-POSNR TO WA_TEMP-POSNR.
        APPEND WA_TEMP TO IT_TEMP.
        CLEAR SY-SUBRC.
        CLEAR WA_TEMP.
    please help.
    Edited by: Matt on Sep 27, 2010 2:19 PM - added  tags

    Prabhu Das,
    DATA : l_index type sy-tabix.
      CLEAR: SY-SUBRC,SY-TABIX.
      SORT: IT_FINAL, IT_TE, IT_TEM." BY VBELN POSNR.
      DELETE ADJACENT DUPLICATES FROM IT_TE  COMPARING VBELN.
      DELETE ADJACENT DUPLICATES FROM IT_TEM COMPARING VBELV.
      SORT: IT_TE,IT_TEM.
      LOOP AT IT_TE INTO WA_TE.
        l_index = sy-tabix.
        READ TABLE IT_TEM INTO WA_TEM WITH KEY VBELV = WA_TE-VBELN
                                               POSNV = WA_TE-POSNR.
        CLEAR SY-TABIX.
        IF SY-SUBRC EQ 0.
           DELETE IT_TE INDEX l_index.
         " DELETE IT_TE INDEX SY-TABIX.
        ENDIF.
        MOVE: WA_TE-VBELN TO WA_TEMP-VBELN,
                   WA_TE-POSNR TO WA_TEMP-POSNR.
        APPEND WA_TEMP TO IT_TEMP.
        CLEAR SY-SUBRC.
        CLEAR WA_TEMP.
    ENDLOOP.
    I did as you suggested this has solved my problem .
    But the one which has to be deleted is deleted in the loop but it is appending in the temp table.
    i don't want those VBELN's
    Thanks.

  • Sy-tabix issue

    What is the difference between the sy-tabix & sy-index ?

    sy-tabix & sy-index
    /message/4752267#4752267 [original link is broken]
    sy-index & sy-tabix
    Reward points..

Maybe you are looking for