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

Similar Messages

  • 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 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..

  • What is the diffrence betweensy-tabix and sy-index

    hi
    can any one suggest me
    what is the diffrence betweensy-tabix and sy-index
    Thanks & Regards
    kalyan.

    Hi Kalyan,
    This question has been answered many times on SCN. Please make a search before posting a thread.
    Read the Rules of Engagement.
    Happy Posting.
    Regards,
    Chandra Sekhar

  • ABAP-- diff between sy-sy-tabix and sy-index

    Hi Guru's,
    Pleae can anybody expalins me what is the difference between sy-tabix and sy-index(Loop Index) ?
    Because in one case i am Modifyimg the internal table inside the do loop by giving sy-index ((Index of Internal Tables)(MODIFY scarr_tab INDEX sy-index FROM scarr_wa TRANSPORTING currcode. )  in the syntax and in other case inside loop statement i am modifyng same record by giving sy-tabix MODIFY scarr_tab INDEX  sy-tabix FROM scarr_wa TRANSPORTING currcode.) in the syntax.
    in both cases its working fine but i am not getting which one i have to use  where to modify the internal table?
    regards
    SATYA

    Hi Henry,
    SY-INDEX is the value of the current iteration. It is applicable for the following programming constructs in ABAP -
    DO...ENDDO.
    WHILE...ENDWHILE.
    SY-TABIX (TABle IndeX) is applicable to internal tables. If you scroll down in the link which Eddie has given, you will find a more detailed explanation for sy-tabix and which statements affect its value.
    Regards,
    Anand Mandalika.

Maybe you are looking for

  • Can't open Illustrator file - "does not have the correct number of operands..."

    Right off the bat - Mac, 10.6.8, Illustrator CS4. I've seen different variations of this "...correct number of operands..." error on these boards, with fonts and other things as the culprit, but I haven't come across this specific issue yet. If someo

  • How to make File-Sharing work with Firewall?

    Hello everybody, I try to connect two laptops via FileSharing, running 10.5.5. Both have the following settings: - Sharing: File-Sharing (AFP) on - Firewall: + Only allow essential services (wording might differ, I translated it) + File-Sharing (AFP)

  • ORACLE APPS migration from AIX to Linux

    Dear All, Please help me to understand the following scenario of ORACLE APP'S migration. One of my client currently using Oracle APP'S ver 11.0.3 DB version 8.0.5 running on IBM AIX platform. Currently three customized module under operation with 50

  • Is there auto scrolling in iBook?

    Back in the day I had a palm pilot with an ereader.  It had autscrolling which was the best feature in ebooks.  I haven't found this in any of the iBooks or kindle readers yet.   I'm surprised.

  • EJB deployment

    Hi, I try to deploy my first ejb. I'm pretty sure I have done everything right, but I'm getting errors anyway. Does anyone recognize this error message? org.omg.CORBA.COMM_FAILURE: java.net.SocketException: JVM_recv in socket input stream read (code=