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

Similar Messages

  • LOOP DOUBT INSIDE  PACKAGE

    CREATE PACKAGE EMP_PKG AS
    CURSOR EMP_CUR IS
    SELECT EMPNO,DEPTNO,SAL,HIREDATE
    FROM EMP
    WHERE DEPTNO=30;
    PROCEDURE P_EMP;
    PROCEDURE P_GET_SAL(V_EMPNO NUMBER);
    PROCEDURE P_GET_LOC(V_EMPNO NUMBER);
    Now inside my Package Body
    INSIDE THE MAINPROCEDURE P_EMP
    I WILL BE CALLING THE BELOW TWO PROCEDURES
    PROCEDURE P_EMP
    BEGIN
    FOR I IN EMP_CUR LOOP
    P_GET_SAL(I.EMPNO);-- DO I NEED TO LOOP AGAIN IN P_GET_SAL PROC?
    P_GET_LOC(I.DEPTNO);
    END LOOP;
    END;
    NOW WHAT IAM DOING IS
    in my P_GET_SAL Procedure is
    PROCEDURE P_GET_SAL(V_EMPNO NUMBER)
    V_SAL EMP.SAL%TYPE;
    BEGIN
    FOR I IN EMP_CUR LOOP
    SELECT SAL INTO V_SAL FROM EMP
    WHERE EMPNO=I.EMPNO --DOUBT HERE
    END;
    I WANT TO KNOW WHETHER I NEED TO LOOP AGAIN
    HERE OR INSTEAD OF THAT
    PROCEDURE P_GET_SAL(V_EMPNO NUMBER)
    V_SAL EMP.SAL%TYPE;
    BEGIN
    SELECT SAL INTO V_SAL FROM EMP
    WHERE EMPNO =V_EMPNO;
    END;
    SINCE iam calling V_EMPNO WITH CURSOR FROM MY
    MAINPROCEDURE ..
    WILL THE PROCEDURE USES THE CURSOR VALUES
    AND LOOP ITSELF FOR EVERY EMPLOYEE TO
    GET THE SALALRY ?
    PLEASE LET ME KNOW SINCE MY PACKAGE IS MORE THAN 3000
    LINES I cant proceed unless its confirmed i can
    do so ..

    Hi all,
    Thanks for Looking into my Problem
    I Got answer by MySelf ..i dont need to loop again my sub procedures
    if i try to do that iam getting the error
    ERROR at line 1:
    ORA-06511: PL/SQL: cursor already open
    Thank you all once again ..

  • Problem in deleting entries from internal table

    i am selecting
               vrgar
                perio
                paobjnr
                belnr
                gjahr
                perde
                budat
                kndnr
                artnr
                frwae
                kursf
                rec_waers
                kaufn
                kdpos
                bukrs
                kokrs
                werks
                gsber
                vkorg
                vtweg
                spart
                rbeln
                rposn
                prctr
                pprctr
                kunnr
                land1
                regio
                kunwe
                kvgr1
                wwpmg
                zterm
                wwcst
                wwrst
                mvgr3
                wwseg
                wwcls
                wwesa
                prdha
                wwbun
                wwexd
                wwph1
                wwph2
                wwph3
                wwph4
                prat1
                prat2
                vrprs
                vv510
                vv508
                vv509
                vvqt2
                vv515
        INTO TABLE ct_ce11000 FROM ce11000
        WHERE paledger EQ gv_ledbo AND
              vrgar    EQ lc_vrgar AND
              belnr    GT uv_belnr AND
              gjahr    EQ pa_gjahr AND
              perde    EQ pa_perd AND
              bukrs    EQ pa_bukrs.
    now i awant to delete all those entries from my internal table ct_ce11000 where my plant (WEKRS) and company code (BUKRS)
    i am writting
    loop at ct_ce11000 into wa_ce11000.
    if wa_ce11000-werks ne wa_ce11000-bukrs.
    now how can i delete all the entries from nmy internal table (ct_ce11000)  when plant and company code is not same
    pls help me  with logic.
    thank you for helping me

    Hello Guys,
    It is not advisable to delete the entries from the internal table you are looping upon. See this thread: [Sy-tabix in loop : Doubt|Sy-tabix in loop : Doubt]
    And to answer the OP's question select data into some local internal table & based on the condition populate your final table. Creating a local table of the same type as the final table will not create too much performance overhead
    Cheers,
    Suhas

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

  • Doubt on loops

    Hi Guys,
    While writing a report using no. of select statements
    for all these we have make loops to get the data in the final out put internal table.For this iam writing loops
    for all the internal tables & finally iam getting nested
    endloops.In order to avoid this nested endloops which is the best procedure. Give the solution urgent or else send
    me some code which u guys r having for more no. of tables.
    Thank You.

    Saripalli,
    If you must use nested loops, then I would agree with Imtiaz with the Binary Search option. I usually use the Binary Search to find the first instance of a record then loop from that point onward. eg.
    sort tbl_vbak by vbeln.
    sort tbl_vbap by vbeln.
    data: l_index like sy-tabix.
    loop at tbl_vbak.
      read table tbl_vbap with key vbeln = tbl_vbak-vbeln
                          binary search.
      if sy-subrc eq 0.
        l_index = sy-tabix.
        loop at tbl_vbap from l_index.
          if tbl_vbap-vbeln be tbl_vbak-vbeln.
            exit.
          endif.
    * Do your processing here....
        endloop.
      endif.
    endloop.
    Hope this helps. Also as some people have said, if you actually paste segments of your code in your post we can help you optimise your code further.
    Cheers,
    Pat.
    Message was edited by: Patrick Yee

  • About mest loop

    hi forks,
       i have some doubts about the nest loop
    when i write the code in this type
      loop at itab1 into lfc_itab1.
         loop at itab2 into lfc_itab2 where k1 = lfc_itab1-k1.
         endloop.
      endloop.
    but my leader told me to write in this way
    sort itab2 by k1 ascending.
    loop at itab1 into lfc_itab1.
      read table itab2 with key k1 = lfc_itab1-k1 binary seach.
      li_tabix = sy-tabix.
      loop at itab2 form  li_tabix.
        if lfc_itab1-k1 = lfc_itab2-k1.
        endif.
      endloop.
    endloop.
    i also agree with what he said,but i write test code
    it return the opposite result .i use record (100100,10001000,10000*10000)
    dose anyone tell which will be better
    thanks in advance

    Hi,
    In ur case second logic is better , first one is call as LINEAR SEARCH and asecond one is called as BINARY SEARCH.
    in LINEAR search ALL entries of itab are processed where as in Binary search entries processaed are logrihtm in no.
    Binary serach is like getting desired page in a book using index, say if u want to search 41st page in 100 page book so in binary seach, if u opeend first time at 50 then it will search first half only, in second pas if u opened 30 page then it iwll search second half and so on...
    Jogdand M B

  • Sy-tabix and sy-dbcnt and sy-dynrr? significance

    hi all,
    Can anyone let me know the significance of sy-tabix and sy-dbcnt and sy-dynrr?
    found while debugging any abap programs.
    can anyone explain me with an example.
    thanxs and regds
    haritha

    sy-dynnr-current screen number
    sy-tabix-current loop pass.....
    sy-dbcnt---number of database records processed
    Sy-dycnt  - I never used
    Sy-tabix ,suppose you have internal table,you want to modify some record based on condition
    loop at itab.
    itab-fld2 = 2000.
    modify itab index sy-tabix. -> here itab modfies currnet internal table index.
    endloop.
    SY-DYNNR -  We use this one in module pool program,some times there would be conditions.
    let me take one simple example :
    you have two screens for one program.
    you want to validate ,you want to give message. i have common include
    now first screen i need to give one message
    i will write simple code
    if sy-dynnr = 100.
    message
    endif.
    same thing i use for other screen too
    Thanks
    Seshu

  • Loop Internal Table Performance

    Hi I am from BW and not much familiar with ABAP. I have written the following code in BW. I have around 1.5 million records coming into BW and the code I have written needs to go through 1.5 million times. Hence the data load is taking long time. I would like someone to please go through the code below and suggest if any for performance improvement.
    data: i_datapackage like DATA_PACKAGE occurs 0 with header line,
          i_index like sy-tabix,
          j_index like sy-tabix,
          i_employee like /bi0/memployee occurs 0 with header line,
          i_begda like /bi0/memployee occurs 0 with header line.
          prev_job like i_employee-job,
          prev_position like i_employee-hrposition,
          curr_job like i_employee-job,
          curr_position like i_employee-hrposition,
          job_datefrom like i_employee-datefrom,
          position_datefrom like i_employee-datefrom,
          prejob_datefrom like i_employee-datefrom,
          prepos_datefrom like i_employee-datefrom,
          prejob_dateto like i_employee-datefrom,
          prepos_dateto like i_employee-datefrom.
    i_datapackage[] = DATA_PACKAGE[].
    sort i_datapackage by employee calmonth ascending.
    select * from /bi0/memployee into table i_employee.
    sort i_employee by employee dateto descending.
    i_begda[] = i_employee[].
    sort i_begda by employee datefrom ascending.
    delete adjacent duplicates from i_employee comparing employee.
    loop at i_datapackage.
    *collecting current job,position, previous job, position
        read table i_employee with key employee = i_datapackage-employee
        dateto ='99991231'.
        if sy-subrc = 0.
          curr_job = i_employee-job.
          curr_position = i_employee-hrposition.
        endif.
       read table i_begda with key employee = i_datapackage-employee.
       if sy-subrc = 0.
         prev_job = i_begda-/bic/zhr_pjob.
         prev_position = i_begda-/bic/zhr_ppost.
       endif.
    *end of collecting current job and position
    sort i_begda by employee datefrom descending.
    read table i_begda with key employee = i_datapackage-employee
    binary search.
    if sy-subrc = 0.
      i_index = sy-tabix.
    endif.
    read table i_begda index i_index.
    if i_begda-employee ne i_datapackage-employee.
      exit.
    endif.
    code for populating service award tenure
    if i_begda-/bic/zhr_srvdt is not initial.
    i_datapackage-/bic/zhr_hrtnr = sy-datum+0(4) -
    i_begda-/BIC/ZHR_SRVDt+0(4).
    if sy-datum4(4) lt i_begda-/bic/zhr_srvdt4(4).
       i_datapackage-/bic/zhr_hrtnr = i_datapackage-/bic/zhr_hrtnr - 1.
    endif.
    endif.
    code for current hire tenure
    if i_begda-/bic/zhr_curdt is not initial.
    i_datapackage-/bic/zhr_crtnr = sy-datum+0(4) -
    i_begda-/BIC/ZHR_CURDT+0(4).
    if sy-datum4(4) lt i_begda-/BIC/ZHR_CURDT4(4).
       i_datapackage-/BIC/ZHR_CRTNR = i_datapackage-/bic/zhr_crtnr - 1.
    endif.
    endif.
    code for current supervisor tenure
    if i_begda-/bic/zhr_csbdt is not initial.
    i_datapackage-/bic/ZHR_CSTNR = sy-datum+0(4) -
    i_begda-/BIC/ZHR_CSBDT+0(4).
    if sy-datum4(4) lt i_begda-/BIC/ZHR_CSBDT4(4).
       i_datapackage-/bic/ZHR_CSTNR = i_datapackage-/bic/ZHR_CSTNR - 1.
    endif.
    endif.
    code for previous supervisor tenure
    if i_begda-/bic/zhr_psbdt is not initial.
    i_datapackage-/bic/ZHR_PSTNR = sy-datum+0(4) -
    i_begda-/BIC/ZHR_PSBDT+0(4).
    if sy-datum4(4) lt i_begda-/BIC/ZHR_PSBDT4(4).
       i_datapackage-/bic/ZHR_PSTNR = i_datapackage-/bic/ZHR_PSTNR - 1.
    endif.
    endif.
    Code for populating Years in current job
    and current position
      sort i_begda by employee datefrom ascending.
        clear j_index.
        read table i_begda with key employee = i_datapackage-employee.
        if sy-subrc = 0.
          j_index = sy-tabix.
        endif.
        loop at i_begda from j_index.
          if i_begda-employee ne i_datapackage-employee.
            exit.
          elseif ( i_begda-job eq curr_job ) and
          ( curr_job is not initial ).
            job_datefrom = i_begda-datefrom.
            prejob_dateto = i_begda-datefrom - 1.
            exit.
          endif.
        endloop.
        loop at i_begda from j_index.
          if i_begda-employee ne i_datapackage-employee.
            exit.
          elseif ( i_begda-hrposition eq curr_position ) and
              ( curr_position is not initial ).
              position_datefrom = i_begda-datefrom.
              prepos_dateto = i_begda-datefrom - 1.
              exit.
          endif.
        endloop.
        loop at i_begda from j_index.
          if i_begda-employee ne i_datapackage-employee.
            exit.
          elseif ( i_begda-job eq prev_job ) and
             ( prev_job is not initial ) and
             ( i_begda-datefrom ne '10000101').
              prejob_datefrom = i_begda-datefrom.
              exit.
          endif.
        endloop.
        loop at i_begda from j_index.
          if i_begda-employee ne i_datapackage-employee.
            exit.
          elseif ( i_begda-hrposition eq prev_position ) and
             ( prev_position is not initial ) and
             ( i_begda-datefrom ne '10000101').
              prepos_datefrom = i_begda-datefrom.
              exit.
          endif.
        endloop.
    i_datapackage-/bic/zhr_cjtnr = sy-datum+0(4) -
    job_datefrom+0(4).
    if sy-datum4(4) lt job_datefrom4(4).
       i_datapackage-/bic/zhr_cjtnr = i_datapackage-/bic/zhr_cjtnr - 1.
    endif.
    if position_datefrom+0(4) is not initial.
    i_datapackage-/bic/zhr_cptnr = sy-datum+0(4) -
    position_datefrom+0(4).
    if sy-datum4(4) lt position_datefrom4(4).
       i_datapackage-/bic/zhr_cptnr = i_datapackage-/bic/zhr_cptnr - 1.
    endif.
    endif.
    if prejob_datefrom is not initial.
    i_datapackage-/bic/zhr_pjtnr = prejob_dateto+0(4) -
    prejob_datefrom+0(4).
    if prejob_dateto4(4) lt prejob_datefrom4(4).
       i_datapackage-/bic/zhr_pjtnr = i_datapackage-/bic/zhr_pjtnr - 1.
    endif.
    endif.
    if prepos_datefrom is not initial.
    i_datapackage-/bic/zhr_pptnr = prepos_dateto+0(4) -
    prepos_datefrom+0(4).
    if prepos_dateto4(4) lt prepos_datefrom4(4).
       i_datapackage-/bic/zhr_pptnr = i_datapackage-/bic/zhr_pptnr - 1.
    endif.
    endif.
    modify i_datapackage transporting /bic/zhr_hrtnr /bic/zhr_crtnr
    /bic/zhr_cstnr /bic/ZHR_PSTNR /bic/zhr_cjtnr /bic/zhr_cptnr
    /bic/zhr_pjtnr /bic/zhr_pptnr.
    endloop.
    DATA_PACKAGE[] = i_datapackage[].
    Thanks.

    i_datapackage[] = DATA_PACKAGE[].
    i_begda[] = i_employee[].
    How larger are these internal tables ?
    If large, then
    > sort i_begda by employee datefrom descending.
    > read table i_begda with key employee = i_datapackage-employee binary search.
    the resorting and
    the nested loops
    => will kill your performance
    Please reconsider the whole logic, I have only some hints
    + Binary search does not help anything if you have to sort everytime you use it.
    + Never use a sort of a larger table inside a larger loop, it is always avoidable!
    + Check whether you can break down the big piece into smaller one, try to
       do the break down in the database already to save memory
    =>  Please provide your code in better layout, and explain what you actually want
          to do.
    Siegfried

  • Issue with sy-tabix..

    hey,
    In my BADI, i have a variable l_ztabix of type sy-tabix.
    i loop thru my idoc data internal table and modify the internal table if neccessary.
    loop at t_idoc_data INTO wa_idoc_data.
    l_ztabix = sy-tabix.
    modify t_idoc_data index l_ztabix FROM wa_idoc_data.
    endloop.
    now it so happens, that during the 10th iteration, the sy-tabix is 10, but when the statement  l_ztabix = sy-tabix.
    is encountered, l_ztabix is set to ' * '. I dont understand why !! bcos of this my modify fails and i get a dump that says, convert_no_number !!
    can anyone guess what is happening ??
    thks

    You did not define l_ztabix big enough.  Define it like this.
    data: l_ztabix type sy-tabix
    Regards,
    Rich Heilman

  • Setting of sy-tabix in my sales order program

    Dear Experts,
    I am working on a ZProgram made for sales order.
    In my module pool I have: ORDER TYPE, sales org,dist channel,division and sold to party.
    I have one material number for example 100 which is exluded for a particular sold to party.
    When I enter material number which is not excluded the material is saved for a particular sold to party.
    suppose the material which is not excluded 101 102 103 104 It gets saved for a particluar sold to party.
    when I enter the exclusion material it gives a error message and none of the material is than accepted.
    Now I have a table control: MATERIAL NUMBER        ORDER QUANTITY      MATERIAL DESCRIPTION
                                            101                                  1                               abc
                                             102                                  2                               def
                                              103                                 3                               xyz
    Now, suppose if the user edits 101 and puts the exclusion material number i.e 100 I get the error message but in the first row the last material i.e 103 appears but I need 100.
    For this I had set a sy-tabix can so that my exclusion material only appears in the first row but the last line i.e 103 is appearing.
    Can anyone let me know the logic for this.
    Thanks,
    Nikhil.

    Hi Dev,
    The table is sorted. The coding which I have done is
    MODULE check_matlist INPUT.   ( PAI )
    DATA: v_tabix TYPE string.
          v_tabix = sy-tabix.
      LOOP AT matlist INTO vbap WHERE matnr = space.
        DELETE matlist.
      ENDLOOP.
      error_line = 0.
      LOOP AT matlist INTO vbap.
    error_line = 0.
           error_line = v_tabix.
           dyn_matli-top_line = error_line.
              MESSAGE ID 'V1' TYPE 'S' NUMBER '117' DISPLAY LIKE 'E' with DA_MATNR.
              CLEAR: DA_FOUND.
    This is the logic I have used but unfortunately the excluded material is not coming in first row.

  • Concatenate in loop

    Hai,
    As Iam using Loop in a Loop iam getting  time out dump .
    in my internal table itab3 has unique objnr values.
    for each objnr i have different status in itab_jcds.
    each status column has diff status.
    now i need to concatenate the status depending upon same objnr.
    LOOP AT  ITAB3 INTO WA_ITAB3.
        RDX = SY-TABIX.
        LOOP AT ITAB_JCDS INTO WA_ITAB_JCDS WHERE OBJNR = WA_ITAB3-OBJNR.
         CONCATENATE WA_ITAB_JCDS-STATUS1 WA_ITAB3-STATUS1 INTO WA_ITAB3-STATUS1 SEPARATED BY SPACE.
          CONCATENATE WA_ITAB_JCDS-STATUS2 WA_ITAB3-STATUS2 INTO WA_ITAB3-STATUS2 SEPARATED BY SPACE.
          CONCATENATE WA_ITAB_JCDS-STATUS3 WA_ITAB3-STATUS3 INTO WA_ITAB3-STATUS3 SEPARATED BY SPACE.
          CONCATENATE WA_ITAB_JCDS-STATUS4 WA_ITAB3-STATUS4 INTO WA_ITAB3-STATUS4 SEPARATED BY SPACE.
        ENDLOOP.
        MODIFY ITAB3 FROM WA_ITAB3 INDEX RDX
                                            TRANSPORTING
                                            OBJNR
                                            STATUS1
                                            STATUS2
                                            STATUS3
                                            STATUS4.
      ENDLOOP.
    example:
    itab3
    objnr
    123
    145
    itab_jcds.
    objnr                    stat1                    stat2                     stat3                     stat4
    123                       nopr                      mav                     crtd                       rel
    123                       CRTD                    mnav                    rel                        prt
    123                       rel                          orsc                   txt                          crtd
    now i req output as
    itab3
    objnr               stat1                    stat2                    stat3             stat4.
    123           nopr crtd rel         mav mnav orsc        crtd rel txt      rel prt crtd
    could u please help.

    Hi,
    Try this way..
    SORT ITAB3 BY OBJNR.
    SORT ITAB_JCDS BY OBJNR.
    LOOP AT ITAB3 INTO WA_ITAB3.
    RDX = SY-TABIX.
    READ TABLE ITAB_JCDS INTO WA_ITAB_JCDS WITH KEY OBJNR = WA_ITAB3-OBJNR.
                                                                                    BINARY SEARCH.
    IF SY-SUBRC EQ 0.
    LOOP AT ITAB_JCDS INTO WA_ITAB_JCDS FROM SY-TABIX.
    IF WA_ITAB_JCDS-OBJNR NE WA_ITAB3-OBJNR.
    EXIT.
    ENDIF.
    CONCATENATE WA_ITAB_JCDS-STATUS1 WA_ITAB3-STATUS1 INTO WA_ITAB3-STATUS1 SEPARATED BY SPACE.
    CONCATENATE WA_ITAB_JCDS-STATUS2 WA_ITAB3-STATUS2 INTO WA_ITAB3-STATUS2 SEPARATED BY SPACE.
    CONCATENATE WA_ITAB_JCDS-STATUS3 WA_ITAB3-STATUS3 INTO WA_ITAB3-STATUS3 SEPARATED BY SPACE.
    CONCATENATE WA_ITAB_JCDS-STATUS4 WA_ITAB3-STATUS4 INTO WA_ITAB3-STATUS4 SEPARATED BY SPACE.
    ENDLOOP.
    MODIFY ITAB3 FROM WA_ITAB3 INDEX RDX
    TRANSPORTING
    OBJNR
    STATUS1
    STATUS2
    STATUS3
    STATUS4.
    ENDIF.
    ENDLOOP

  • Condition WHERE in LOOP

    Good afternoon,
    I have the following issue,
    I  have that do a LOOP to a table Internal, ie.
    Loop at it_tabla where lgart = '0100' or lgart = '0200' or lgart = '0300' or lgart = '0400' or lgart = '0500' or  lgart = '0600' or lgart = '0700' or lgart = '0800' .
    Endloop.
    The question is, Is there any way , in the which not have that do many or  in the sentence LOOP?
    Kind regards.

    I think Rob means that it will go through the table once.
    It's true for Standard tables.  But as it says in the help on the WHERE clause.
    While with standard tables all rows of the internal table are checked for the logical expression of the WHERE- addition, with sorted tables and hash tables (as of Release 7.0) you can achieve optimized access by checking that at least the beginning part of the table key in sorted tables and the entire table key in hash tables is equal in the logical expression through queries linked with AND. Optimization also takes effect if the logical expression contains other queries linked with AND with arbitrary operators
    In this case though, the queries are linked with OR - so you still get all rows checked! 
    Now, if it_tabla is a sorted table with key lgart, then you could do the following:
    PERFORM read_the_table USING: '0100', '0200',...
    FORM read_the_table USING i_lgart TYPE ...
      data: l_tabix TYPE sytabix.
      READ TABLE it_table WITH TABLE KEY lgart =i_lgart TRANSPORTING NO FIELDS.
      l_tabix = sy-tabix.
      LOOP AT it_table FROM l_tabix INTO ls_wa.
        IF ls_wa-lgart NE i_lgart.
          EXIT.
        ENDIF.
        " Do stuff
      ENDLOOP.
    ENDFORM.
    matt

  • Simple doubt in BDC  Call Transaction Method

    Hi Friends,
      When i try to call vk13 transaction and pass the screen field values for the second screen and execute it it is displaying properly.But when i try to pass the different value in the bcddata internal table it is changing properly but in the screen it not updating that value.Alawly the screen fields are taking the values passed the first time.But in the internal table which we are oassing to the calltransaction it is changing correctly but not in the corresponding screen fields. Why it is happening so. Can any one help me out of this problem.
    Thanks in Advance.

    I am not passing through the selection screen . It is like iteractive report. when i select the particular line in the list output then the screen fields should take the values from that selected line. First time when i select the line it is taking properly.
    But next time when i select the line the content of the i_bdc_tbl is changing correctly but when it enter in to the transaction it is not taking the values from the i_bdc_tbl. Simply it is displaying the screen fields with the old values. It is not updating the screen fields with the values from the i_bdc_tbl. Why the screen fields are not replaced with the value of i_bdc_tbl? Why it is not getting refreshed with the new values?
    Just i am posting the bdc portion of my code here. So you can help me out on this.
    AT LINE-SELECTION.
      SELECT SINGLE kozgf FROM t685 INTO v_kozgf
                          WHERE kschl = wa_report-kschl.
      SELECT kolnr kotabnr FROM t682i INTO TABLE i_t682i
                     WHERE kozgf = v_kozgf.
      SORT i_t682i BY kolnr.
      READ TABLE i_t682i WITH KEY kotabnr = wa_report-tabna+1(3)
           TRANSPORTING NO FIELDS.
      CHECK sy-subrc = 0.
      v_index = sy-tabix.
      REFRESH i_bdc_tbl.
      l_tabix = '01'.
      PERFORM f_vk13.
      CONCATENATE 'RV13' wa_report-tabna  INTO v_bdc_val_field.
      PERFORM bdc_dynpro      USING v_bdc_val_field '1000'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'F004-LOW'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=ONLI'.
      CREATE DATA v_rec  TYPE (wa_report-tabna).
      ASSIGN v_rec->* TO <wa_table>.
      SELECT SINGLE *  FROM (wa_report-tabna) INTO <wa_table>
      WHERE kschl = wa_report-kschl AND matnr = wa_report-matnr AND knumh = wa_report-objectid.
      CALL FUNCTION 'DDIF_FIELDINFO_GET'
        EXPORTING
          tabname        = wa_report-tabna
        TABLES
          dfies_tab      = lwa_tabna
        EXCEPTIONS
          not_found      = 1
          internal_error = 2
          OTHERS         = 3.
      READ TABLE lwa_tabna WITH KEY fieldname = 'KSCHL'.
      p1 = sy-tabix + 1.
      READ TABLE lwa_tabna WITH KEY fieldname = 'MATNR'.
      p2 = sy-tabix.
      LOOP AT lwa_tabna.
        v_field = lwa_tabna-fieldname.
        IF lwa_tabna-position BETWEEN p1 AND p2.
          ASSIGN COMPONENT lwa_tabna-position OF STRUCTURE <wa_table> TO <fld>.
          PERFORM f_vk13_s2 USING lwa_tabna-fieldname <fld>.
        ENDIF.
      ENDLOOP.
      PERFORM bdc_field       USING 'RV130-DATAM'
                                       wa_report-fdate_value_new.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    'ONLI'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'F001'.
      CALL TRANSACTION 'VK13' USING i_bdc_tbl
                              MODE  'A'.
    FORM f_vk13.
      DATA: l_tabix(2) TYPE c.
    *Condition type
      PERFORM bdc_dynpro      USING 'SAPMV13A' '0100'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'RV13A-KSCHL'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM bdc_field       USING 'RV13A-KSCHL'
                                     wa_report-kschl.
    *Key combination
      PERFORM bdc_dynpro      USING 'SAPLV14A' '0100'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'RV130-SELKZ(01)'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=WEIT'.
      PERFORM bdc_field       USING 'RV130-SELKZ(01)'
      l_tabix = v_index.
      SHIFT l_tabix RIGHT.
      OVERLAY l_tabix WITH '00'.
      CONCATENATE 'RV130-SELKZ(' l_tabix ')' INTO v_bdc_field.
      PERFORM bdc_field       USING v_bdc_field
                                    'X'.
    ENDFORM.                                                    "f_vk13
          FORM BDC_DYNPRO
          This form accepts the program name and screen number
          and places the values into the I_BDC_TBL internal table.
    FORM bdc_dynpro USING program dynpro.
      CLEAR wa_bdc_tbl.
      wa_bdc_tbl-program  = program.
      wa_bdc_tbl-dynpro   = dynpro.
      wa_bdc_tbl-dynbegin = 'X'.
      APPEND wa_bdc_tbl TO i_bdc_tbl.
    ENDFORM.                    "BDC_DYNPRO
          FORM F_BDC_FIELD
        This form accepts the field name and the corresponding value
        for that field and places them into the I_BDC_TBL internal table.
    FORM bdc_field USING fnam fval.
      CLEAR wa_bdc_tbl.
      MOVE fnam TO wa_bdc_tbl-fnam.
      MOVE fval TO wa_bdc_tbl-fval.
      APPEND wa_bdc_tbl TO i_bdc_tbl.
    ENDFORM.                    "BDC_FIELD
    *&      Form  f_vk13_s2
          text
    -->  p1        text
    <--  p2        text
    FORM f_vk13_s2 USING p_fieldname p_fld.
      CONCATENATE wa_report-tabna '-' p_fieldname INTO v_bdc_val_field.
      CHECK NOT p_fld IS INITIAL.
      PERFORM bdc_field USING v_bdc_val_field p_fld.
    ENDFORM.                                                    " f_vk13_s2
    Thanks.

  • How we know tables for komv, komk, komp structures in ME23n Trans for PO

    Hi gurus,
    We are extracting data of PO relating to me23n and sending that data to XI. Its working fine. But some fields value are getting wrong. I am getting problem with komv, komk, and komp structures, bcoz i dont know which tables i have to use. I am using konv right now.
    Pls give some suggestions.
    and also how we get netwr value in the header i.e. total amout of items and price element rate KOMV-KBETR in header.
    ex: KOMV-KBETR
         KOMK-WAERK
         KOMP-NETWR
         TDTEXT based on ID
         ZTEXT (item level text, and header level text).
    Thanks in advance...

    Pls see my code...
    *This for Header.............*
          i_zzep_pohdr_s-doc_date = i_ekko-bedat.    "14
          SELECT SINGLE * FROM t052 INTO i_t052 WHERE zterm = i_ekko-zterm.
          IF sy-subrc = 0.
            i_zzep_pohdr_s-pay_trms = i_t052-zterm.     "15
          ENDIF.
          SELECT SINGLE * FROM tcurc INTO i_tcurc WHERE waers = i_ekko-waers.
          IF sy-subrc = 0.
            i_zzep_pohdr_s-curr = i_tcurc-waers.     "16
          ENDIF.
          i_zzep_pohdr_s-ex_rate = i_ekko-wkurs.     "17
          i_zzep_pohdr_s-ex_rate_fxd = i_ekko-kufix. "18
          i_zzep_pohdr_s-inco = i_ekko-inco1.        "19
          i_zzep_pohdr_s-add_inco = i_ekko-inco2.    "20
          SELECT SINGLE * FROM t685t INTO i_t685t
          WHERE spras = i_ekko-spras.
          IF sy-subrc = 0.
            i_zzep_pohdr_s-pri_ele_cond_desc = i_t685t-vtext. "21
          ENDIF.
          SELECT SINGLE * FROM konv INTO i_konv WHERE knumv = i_ekko-knumv.
          IF sy-subrc = 0.
            IF i_konv-kschl = 'PBXX'.
    *          i_zzep_pohdr_s-Pri_ele_rate = i_konv-kbetr.                "22
              i_zzep_pohdr_s-pri_ele_curr_cond = i_konv-waers.           "23
              i_zzep_pohdr_s-pri_ele_cond_val_doc_curr = i_konv-kwert_k. "24
            ENDIF.
          ENDIF.
          MOVE i_ekko-ebeln TO xname.
          CALL FUNCTION 'READ_TEXT'
            EXPORTING
    *   CLIENT                        = SY-MANDT
              id                            = 'F02'
              language                      = sy-langu
              name                          = xname
              object                        = 'EKKO'
    *   ARCHIVE_HANDLE                = 0
    *   LOCAL_CAT                     = ' '
    * IMPORTING
    *   HEADER                        =
            TABLES
              lines                         = i_xtline
       EXCEPTIONS
         id                            = 1
         language                      = 2
         name                          = 3
         not_found                     = 4
         object                        = 5
         reference_check               = 6
         wrong_access_to_archive       = 7
         OTHERS                        = 8
          IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ELSE.
            CLEAR temp.
            LOOP AT i_xtline INTO rline.
              IF rline-tdline IS NOT INITIAL.
                CONCATENATE temp rline-tdline INTO temp SEPARATED BY space.
              ENDIF.
            ENDLOOP.
            MOVE temp TO i_zzep_pohdr_s-hdr_lvl_txt_cont . "28
          ENDIF.
          SELECT SINGLE * FROM t166k INTO i_t166k WHERE bsart = i_ekko-bsart.
          IF sy-subrc = 0.
            i_zzep_pohdr_s-hdr_lvl_txt_id = i_t166k-tdid.            "26
          ENDIF.
          SELECT SINGLE * FROM t166k INTO i_t166k WHERE bsart = i_ekko-bsart.
          IF sy-subrc = 0.
            SELECT SINGLE * FROM ttxot INTO i_ttxot WHERE tdobject = i_t166k-tdobject
                                                    AND tdspras = i_ekko-spras.
            IF sy-subrc = 0.
              i_zzep_pohdr_s-hdr_lvl_txt_desc_id = i_ttxot-tdtext. " 27
            ENDIF.
          ENDIF.
          APPEND i_zzep_pohdr_s TO t_zzep_pohdr_t.
        ENDLOOP.
    *This for Items.............*
    SELECT * FROM t166p INTO TABLE i_t166p WHERE bstyp = i_ekpo-bstyp
                                                  AND pstyp = i_ekpo-pstyp.
          IF sy-subrc = 0.
            LOOP AT i_t166p INTO wa_t166p.
              IF wa_t166p-tdid = 'F01'.
                i_zzep_podet_s-itm_lvl_txt_id = wa_t166p-tdid.            "29
              ENDIF.
            ENDLOOP.
            SELECT SINGLE * FROM ttxot INTO i_ttxot WHERE tdobject = 'EKPO'
                                                    AND tdspras = sy-langu.
            IF sy-subrc = 0.
              i_zzep_podet_s-itm_lvl_txt_desc_id = i_ttxot-tdtext. " 27
            ENDIF.
          ENDIF.
    *select single * from stxl into i_stxl where tdspras = i_ekko-spras.
    *select single * from
          APPEND i_zzep_podet_s TO t_zzep_podet_t.
          sum = sum + i_zzep_podet_s-pri_ele_net_val_doc_curr.
          CLEAR i_zzep_podet_s.
        ENDLOOP.
        CLEAR current_line.
        LOOP AT t_ekko INTO i_ekko.
          current_line = sy-tabix.
          LOOP AT t_ekpo INTO i_ekpo WHERE ebeln = i_ekpo-ebeln.
            IF sy-subrc = 0.
              *MOVE sum TO i_zzep_pohdr_s-pri_ele_net_val_doc_curr.* (NETWR)
              *MOVE sum TO i_zzep_pohdr_s-pri_ele_rate.* (KBETR)
            ENDIF.
          ENDLOOP.
          MODIFY t_zzep_pohdr_t FROM i_zzep_pohdr_s INDEX current_line.
        ENDLOOP.
      ENDIF.
    I already down althose wht u suggested previous...
    just see this code and give suggestion where i have to change my code....
    I am getting doubt when i am using ..
    IF i_konv-kschl = 'PBXX'.
                i_zzep_podet_s-pri_ele_rate = i_zzep_podet_s-ext_val_itm.                "25
                i_zzep_podet_s-pri_ele_curr_cond = i_konv-waers.           "26
                i_zzep_podet_s-pri_ele_cond_val_doc_curr = i_konv-kwert_k. "27
              ENDIF.
    and..
    CLEAR current_line.
        LOOP AT t_ekko INTO i_ekko.
          current_line = sy-tabix.
          LOOP AT t_ekpo INTO i_ekpo WHERE ebeln = i_ekpo-ebeln.
            IF sy-subrc = 0.
              MOVE sum TO i_zzep_pohdr_s-pri_ele_net_val_doc_curr.
              MOVE sum TO i_zzep_pohdr_s-pri_ele_rate.
            ENDIF.
          ENDLOOP.
          MODIFY t_zzep_pohdr_t FROM i_zzep_pohdr_s INDEX current_line.
        ENDLOOP.
      ENDIF.
    pls suggest me...
    thanks.
    Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:49 PM

Maybe you are looking for