Sy-index sy-tabix

can any body tell me diff bw sy-tabex and sy-index. pls

SY-INDEX
In a loop, a statement block is executed several times in succession. There are four kinds of loops in ABAP:
Unconditional loops using the DO statement.
Conditional loops using the WHILE statement.
Loops through internal tables and extract datasets using the LOOP statement.
Loops through datasets from database tables using the SELECT statement.
This section deals with DO and WHILE loops. SELECT is an Open SQL statement, and is described in the Open SQL section. The LOOP statement is described in the sections on internal tables and extract datasets.
Unconditional Loops
To process a statement block several times unconditionally, use the following control structure:
DO [<n> TIMES] [VARYING <f> FROM <f1> NEXT <f 2>].
  <Statement block>
ENDDO.
If you do not specify any additions, the statement block is repeated until it reaches a termination statement such as EXIT or STOP (see below). The system field SY-INDEX contains the number of loop passes, including the current loop pass.
SY-TABIX
You can use the LOOP statement to process special loops for any internal table.
LOOP AT <itab> <result> <condition>.
  <statement block>
ENDLOOP.
This reads the lines of the table one by one as specified in the <result> part of the LOOP statement. You can then process them in the statements within the LOOP... ENDLOOP control structure. You can either run the loop for all entries in the internal table, or restrict the number of lines read by specifying a <condition>. Control level processing is allowed within the loop.
The sequence in which the lines are processed depends on the table type:
Standard tables and sorted tables
The lines are processed according to the linear index. Within the processing block, the system field SY-TABIX contains the index of the current line.
Hashed tables
As long as the table has not been sorted, the lines are processed in the order in which you added them to the table. Within the processing block, the system field SY-TABIX is always 0.

Similar Messages

  • Difference between sy-index & sy-tabix

    Dear friends,
    Please tell me the difference between sy-index & sy-tabix
    Actually my problem is i don't know how to compare for example between first record'field n and second record'field n when u r in loop so i can take particular action based on result
    on current recor
    if possible send me sample code.
    Regards;
    Parag Gavkar.

    SY-TABIX:
    Current line in an internal table. With the following statements SY-TABIX is set for index tables. With hashed tables, SY-TABIX is not filled or it is set to 0.
    - APPEND sets SY-TABIX to the index of the last table row, that is the total number of entries in the target table.
    - COLLECT sets SY-TABIX to the index of the existing or appended table row. With hashed tables, SY-TABIX is set to 0.
    - LOOP AT sets SY-TABIX to the index of the current table row at the beginning of every loop pass. After leaving a loop, SY-TABIX is set to the value it had before entering the loop. With hashed tables, SY-TABIX is set to 0.
    - READ TABLE sets SY-TABIX to the index of the table row read. If no row is found with binary search while reading, SY-TABIX contains the index of the next-highest row or the total number of rows +1. If no row is found with linear search while reading, SY-TABIX is undefined.
    - SEARCH itab FOR sets SY-TABIX to the index of the table row, in which the search string was found.
    SY-INDEX:
    SY-INDEX contains the number of loop passes in DO and WHILE loops, including the current loop pass.
    Regards,
    Santosh

  • Conflict: READ TABLE itab2 INDEX 1 vs  Modify itab1 from index sy-tabix

    The below simple code is for each itab1 line, create a new itab2 by using select statement, and then grab the max value of field f in itab2 and fill it into a corresponding field in itab1.
    However the statement:
    READ TABLE itab2 into gs_itab1 INDEX 1.
    causes the conflict with our another statement in the end of itab1 loop:
    Modify itab1 from gs_itab1 index sy-tabix.
    that the below Modify statement always modify itab1 at 1st row and also causes an unlimited loop that the program is hung up. Our code looks as the following:
    Loop AT itab1 into gs_itab1.
             use Select statement to fill in itab2...
             SORT itab2 BY f DESCENDING. "f is a field of itab2
             READ TABLE itab2 into gs_itab1 INDEX 1.
             Modify itab1 from gs_itab1 index sy-tabix.
    EndLoop.
    However the last two lines of statements in the itab1 loop causes the program hang!
    Any solution?
    Thanks in advance!

    Hi,
    I got confused while going thru the code...
    according to code
    first u loop itab1 and get tht in gs_itab1 and then a select query to get data from some table and store in itab2.
    Here are u using any where condition, if yes u may probably check aganst gs_itab1 rite? if yes
    first suggestion...why cant u put the select statement above the loop and get all the values to an internal table and then read the internal table in the loop stmt. Yes i can see u r sorting it based on some 'f'..just a suggestion
    Now here can u follow this code...
    Loop AT itab1 ASSIGNING <fs_itab1>,
             use Select statement to fill in itab2...
             SORT itab2 BY f DESCENDING. "f is a field of itab2
             READ TABLE itab2 into <fs_itab1> index 1.
    EndLoop.
    Please let me know if its not ok
    <REMOVED BY MODERATOR>
    Regards,
    ABAPer007
    Edited by: Alvaro Tejada Galindo on Apr 11, 2008 12:26 PM

  • Why "Modify itab index sy-tabix." makes internal table content blank?

    We have an internal table itab which looks like to have the following content:
    A---B---C
    1----3----
    2----2----
    We would like to get the column C value in this internal table itab by summing Column A and Column B, and then fill C column values into this internal table. We know that the program would looks like:
    Loop at itab into wa_itab.
        wa_itab-C = wa_itab-A + wa_itab-B.
        Modify itab index sy-tabix.
    EndLoop.
    But after executing the above code, all itab becomes blank. Through debugging, find it's caused by the statement "Modify itab index sy-tabix.".  Could any ABAP expert here let us know the reason and we will give you reward points!

    hi,
    what you tried is correct.but instead of using
    modify itab index sy-tabix
    use
    modify itab index sy-tabix from wa_itab.
    the reason for blank data is you are not mentioning from where that record is to be updated.your specifying the record using index.one thing is no need to use index also because in a loop you are modifying so automatically it will take you to the record.
    try the following code.
    types:begin of it,
         a type i,
         b type i,
         c type i,
         end of it.
    data:itab type standard table of it.
    data:wa_itab type it.
    wa_itab-a = 3. wa_itab-b = 4.
    append wa_itab to itab.
    Loop at itab into wa_itab.
        wa_itab-C = wa_itab-A + wa_itab-B.
    Modify itab index sy-tabix from wa_itab.
    *you can use Modify itab from wa_itab.
    EndLoop.
    loop at itab into wa_itab.
    write:wa_itab-a,wa_itab-b,wa_itab-c.
    endloop.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 8, 2008 5:49 PM

  • Insert ITAB INDEX SY-TABIX Problem

    Hi Experts,
    I have a problem in my report.
    Please look into the code.
    loop at li_basez980.
       read table i_z980 with key spmon = l_spmon
                                  matnr = li_basez980-matnr
                                  kunnr = li_basez980-kunnr
                                  werks = li_basez980-werks
                                  vkorg = li_basez980-vkorg binary search.
       if sy-subrc ne 0.
         i_z980-spmon = l_spmon.
         i_z980-matnr = li_basez980-matnr.
         i_z980-kunnr = li_basez980-kunnr.
         i_z980-werks = li_basez980-werks.
         i_z980-vkorg = li_basez980-vkorg.
         i_z980-basme = li_basez980-basme.          " 8/6/07
         i_z980-waers = c_waers.
         i_z980-cpudt = v_datum.
         i_z980-cputm = v_uzeit.
         i_z980-znetsalekg = 0.
         i_z980-znetsalevl = 0.
         insert i_z980 index sy-tabix.
         clear  i_z980.
       endif.
    endloop.
    When run my report in Foreground it runs fine. But when i run the same report in Background job gets cancelled when the index reaches to 228984 once 230070 once and 230104 once at insert statement i.e " insert i_z980 index sy-tabix." . I found this  by debugging the Job.
    Please help me if you know the solution.
    Regards,
    Ravikumar P
    Edited by: Ravikumar P on Mar 30, 2010 4:40 PM

    Hi,
    This is happening because after read you inserting the records when sy-surbc <> 0. At that time did you check the sy-tabix value. This value is comming correctly. You directly append the same.
    loop at li_basez980.
    read table i_z980 with key spmon = l_spmon
    matnr = li_basez980-matnr
    kunnr = li_basez980-kunnr
    werks = li_basez980-werks
    vkorg = li_basez980-vkorg binary search.
    if sy-subrc ne 0.
    i_z980-spmon = l_spmon.
    i_z980-matnr = li_basez980-matnr.
    i_z980-kunnr = li_basez980-kunnr.
    i_z980-werks = li_basez980-werks.
    i_z980-vkorg = li_basez980-vkorg.
    i_z980-basme = li_basez980-basme. " 8/6/07
    i_z980-waers = c_waers.
    i_z980-cpudt = v_datum.
    i_z980-cputm = v_uzeit.
    i_z980-znetsalekg = 0.
    i_z980-znetsalevl = 0.
    insert i_z980 index sy-tabix.
    clear i_z980.
    endif.
    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-index / sy-tabix wrong within loop

    Hi friends,
    i do a loop over a a table and am writing out the field contents like this:
    LOOP AT <dyn_table> INTO <dyn_wa>.
            do.
          assign component sy-index
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    * Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.
          endif.
      ENDLOOP.
    What now doesnt work is, that whenever i have the read statement uncommented the loop doesnt increment so i only get the first row but that n-times.
    any idea where the error is  ?
    thank you! i am awarding points generously

    LOOP AT <dyn_table> INTO <dyn_wa>.
            do.
          assign component sy-index
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.
          endif.
      ENDLOOP.
    If i gt you rite..i would suggest this
    Data: l_tabix type sy-tabix.
    LOOP AT <dyn_table> INTO <dyn_wa>.
      l_tabix - sy-tabix.
          assign component l_tabix
             of structure <dyn_wa> to <dyn_field>.
            if sy-subrc <> 0.
             EXIT.
            else.
    Here it gets the name of the field based on the sy-index of the component
            READ TABLE l_tab_fields INTO w_tab_fields INDEX l_tabix.
          endif.
      ENDLOOP.
    santhosh

  • Read table index sy-tabix

    Hi Experts,
    As per my requirment I need fetch two different categories of matnr based on movment type
    from mseg..
    For eg: If I have two itab's : itab1 and itab2.
    In itab1 the available records are:    
    matnr    werks     lifnr
    mat1     unit1      ABC
    mat2     unit1      ABC
    mat3     unit1      ABC
    mat4     unit1      ABC
    In itab2 the available records are:  
    matnr_1  werks_1  lifnr_1
    mat5       unit1       ABC
    mat6       unit1       ABC
    mat7       unit1       ABC
    mat8       unit1       ABC
    and I want to move this itab1 and itab2 to another itab ie. itab3.
    and my o/p shud look like:
    matnr    werks     lifnr     matnr_1
    mat1     unit1     ABC     mat5
    mat2     unit1     ABC     mat6
    mat3     unit1     ABC     mat7
    mat4     unit1     ABC     mat8.
    Please advice
    Karthik
    Edited by: Karthik R on Jun 18, 2009 6:33 PM

    Hi Suhas,
    Thanks a lot !! Ur logic is working.. but I have some other problem now:
    ie. If in itab 1 I have
    matnr    werks     lifnr
    mat1     unit1      ABC
    mat2     unit1      ABC
    In itab2 the available records are:
    matnr_1  werks_1  lifnr_1
    mat5       unit1       ABC
    mat6       unit1       ABC
    mat7       unit1       ABC
    mat8       unit1       ABC
    I want my o/p as :
    matnr    werks     lifnr    matnr_1
    mat1     unit1      ABC    mat5
    mat2     unit1      ABC    mat6
                               mat7
                               mat8.
    But as per ur logic I got the o/p as:
    matnr    werks     lifnr    matnr_1
    mat1     unit1      ABC    mat5
    mat2     unit1      ABC    mat6
    Please advice
    Karthik
    Edited by: Karthik R on Jun 18, 2009 7:07 PM
    Edited by: Karthik R on Jun 18, 2009 7:08 PM

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

  • Sy-tabix vs sy-index

    Hi all,
    I have one LOOP and two READ statements inside of it. After each READ statement i need to MODIFY some lines. In one of MODIFY statements i use MODIFY...INDEX sy-tabix but it seems that is not a good way to correctly modify line that I would like to. Can you please give me any suggestions?
    KR,
    Maja
    eg. of Code is below:
    LOOP AT it_srret INTO wa_srret.
          READ TABLE it_srret1 INTO wa_srret1 WITH KEY obknr = wa_srret-obknr.
          wa_srret-mblnr = wa_srret1-mblnr.
          wa_srret-mjahr = wa_srret1-mjahr.
          wa_srret-zeile = wa_srret1-zeile.
          wa_srret-datum = wa_srret1-datum.
          MODIFY it_srret FROM wa_srret.
          READ TABLE it_list INTO wa_list WITH KEY sernr = wa_srret-sernr.
          IF sy-subrc = 0.
            wa_list-returned = 'D'.
            MODIFY it_list FROM wa_list INDEX sy-tabix.
            CLEAR wa_list.
            wa_list-lfdat = wa_srret-datum.
            wa_list-sernr = wa_srret-sernr.
            wa_list-mblnr = wa_srret-mblnr.
            wa_list-zeile = wa_srret-zeile.
            APPEND wa_list TO it_list.
          ENDIF.
        ENDLOOP.

    HI,
    If you can use Field-symbols... then there is no need to use the MODIFY statements.
    field-symbols: <fs_srret> like wa_srret.
    field-symbols: <fs_srret1> like wa_srret.
    field-symbols: <fs_list> like w_list.
    LOOP AT it_srret assigning <fs_srret>.
    READ TABLE it_srret1 INTO <fs_srret1> WITH KEY obknr = <fs_srret>-obknr.
    lf sy-subrc eq 0.
    <fs_srret1>-mblnr = <fs_srret>-mblnr.
    <fs_srret1>-mjahr = <fs_srret>-mjahr.
    <fs_srret1>-zeile = <fs_srret>-zeile.
    <fs_srret1>-datum = <fs_srret>-datum.
    endif.
    READ TABLE it_list assigning <fs_list> WITH KEY sernr = <fs_srret>-sernr.
    IF sy-subrc = 0.
    <fs_list>-returned = 'D'.
    CLEAR wa_list.
    wa_list-lfdat = wa_srret-datum.
    wa_list-sernr = wa_srret-sernr.
    wa_list-mblnr = wa_srret-mblnr.
    wa_list-zeile = wa_srret-zeile.
    APPEND wa_list TO it_list.
    ENDIF.
    ENDLOOP.
    Regards,
    Venkatesh

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

  • Problem with SY-TABIX?

    Hi all,
    I am using one FM in my application, at one place i am reading table using sy-tabix. But it is showing 0 even table contains values.
    In some other place in this code tabix is working. perticular in that place it is not working.
    And i check this by executing se37 there it is working fine...
    Here the code..
      SELECT   vbeln  vkorg  vtweg  kunnr spart  FROM vbak INTO  TABLE it_vbak
                     where vbeln  in  s_vbeln.
    IF it_vbak[] IS NOT INITIAL.
        SELECT  kunnr   "Customer Number 1
                adrnr   "Address
          FROM kna1 INTO CORRESPONDING FIELDS OF TABLE it_kna1
          FOR ALL ENTRIES IN it_vbak
          WHERE kunnr = it_vbak-kunnr.
    //Here sy-tabix always showing 0.    
    READ TABLE it_kna1 INTO wa_kna1 INDEX sy-tabix.
        IF sy-subrc = 0.
          gv_kunnr = wa_kna1-kunnr.
        ENDIF.
    In some other place it is working...
          SELECT  lifnr     "ACCOUNT NUMBER OF VENDOR OR CREDITOR
                  adrnr     "ADDRESS
            FROM lfa1
            INTO CORRESPONDING FIELDS OF TABLE it_lfa1
            FOR ALL ENTRIES IN it_knvp
            WHERE lifnr = it_knvp-lifnr.
        ENDIF.
        READ TABLE it_lfa1 INTO wa_lfa1 INDEX sy-tabix.   // Here it is working.  
    IF sy-subrc = 0.
          gv_lifnr = wa_lfa1-lifnr.
        ENDIF.
    Can anyone give me any suggetions.. i think code is correct, any fault is there...
    Tahnks,
    Venkat.

    Venkat,
    There are two selects, 1 from KNa1 and other from LFA1 and a read statement after each select.
    For your first select, your sy-tabix will always be 0. Sy-tabix will be filled with Loop or read. Now when execution reaches your second statement of read, the sy-tabix is already filled by the first read.
    So, two things: 1. Always use debugging, 2. please explore yourself first on these issues. You can use sy-dbcnt which fills with the total number of records returned.
    Regards,
    Santosh

Maybe you are looking for