Unable to Get the Data Using For All Entries

Hi everybody, i am using for all entries in a program. but when i am writing a code using for all entries i am getting an error as 
Where condition does not refers to the FOR ALL ENTRIES tables...
SELECT KUNNR
       NAME1
       ORT01
       LAND1
   FROM KNA1 INTO TABLE ITAB1 WHERE KUNNR IN S_KUNNR.
IF NOT ITAB1 IS INITIAL.
SELECT VBELN
        ERDAT
        KUNNR
   FROM VBAK INTO TABLE ITAB2 FOR ALL ENTRIES IN ITAB1 WHERE KUNNR = IT_KNA1-KUNNR.
ENDIF.
can anybody help out in this
regards
hyder ali

The correct one may be like this:
SELECT KUNNR
NAME1
ORT01
LAND1
FROM KNA1 INTO TABLE ITAB1 WHERE KUNNR IN S_KUNNR.
IF NOT ITAB1 IS INITIAL.
SELECT VBELN
ERDAT
KUNNR
FROM VBAK INTO TABLE ITAB2 FOR ALL ENTRIES IN ITAB1 WHERE KUNNR = ITAB1-KUNNR. "modified here
ENDIF.
Edited by: XuJian84 on Mar 9, 2010 4:25 AM

Similar Messages

  • What is the condition for using 'for all entries' and  why?

    what is the condition for using 'for all entries' and  why? can any body tell the reason for this ? its a big favour of me .
    regards,
    ravi.

    hi,
    for all entries is used to join two or more tables.
    It is same as join but performance wise for all entries is more effective.
    You can only use FOR ALL ENTRIES IN ...WHERE ...in a SELECT statement.
    SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT
    statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol
    itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result
    set. If the internal table itab does not contain any entries, the system treats the statement as though there were
    no WHERE cond condition, and selects all records (in the current client).
    for example:
    SELECT * FROM sflight INTO wa_sflight
    FOR ALL ENTRIES IN ftab
    WHERE CARRID = ftab-carrid AND
    CONNID = ftab-connid AND
    fldate = '20010228'.
    this condition, return all entries of the sflight
    hen using FOR ALL ENTRIES the number of matching records is restricted to the number of records in the internal table. If the number of records in the database tables is too large then join would cause overheads in performance. Additionally a JOIN bypasses the table buffering.
    So for all entries is used for filtering out the data from the two tables based on the entries in them.
    Advantages:
    1) For all entries avoids inner join & so the performance increases.
    2) For specified values in 1 itab, if you to fetch values from other table you can use it.
    3) Use of select stmt in loop is gets avoided, as u can use read statement on the the new itab.

  • Unable to get the admin object for the CsContainerAdmin service

    Hi,
    On AIX, we deployed XIR2 SP2 --> XIR2 SP3 --> SP3 Productivity Pack.
    The Conection server does show up on the server list in the CMC, but on trying to access this server, it throws an error" Unable to get the admin object for the CsContainerAdmin service"
    Tried to manually create another Connection server, same result.
    Is this an issue that is addressed by a later FP?
    Thanks in advance
    Rajesh Jayakumar

    Hi Rajesh,
    Were you able to resolve this issue? I am facing the same issue with almost every BOE 11.5 SP3 server on Windows.
    For example, the Input file server says this -
    "Unable to get the admin object for the FileServerAdmin service for server Input.BOCMSMSGT1.fileserver".
    Getting the same error on WebI Report Server as well -
    There was an error while retrieving data from the server: Unable to get the admin object for the WebiServerAdmin service for server BOPROCENG1.Web_IntelligenceReportServer.webiserver
    Thanks,
    Sarang
    Edited by: Sarang Deshpande on Sep 26, 2008 3:08 PM

  • Unable to get the composite instance for the invocation. This could be because instance has not yet been created or because the audit level for the SOA infra has been set to Off

    I am on Oracle 11.1.1.7 BPM suite on W8 64 bit. I can't launch the flow trace and get the error "Unable to get the composite instance for the invocation. This could be because instance has not yet been created or because the audit level for the SOA infra has been set to Off".  I have set the audit level to development at the soa-infra>SOA Administration> Common Properties > Audit level set to development and Capture Composite Instance State is Checked.
    Can somebody advice.
    Thanks

    Can you please confirm me the following steps...
    Log in to the EM console, Expand soa-infra (soa_server1) , go to the partition where your composite is been deployed, Click on your composite, On the right, click on the dropdown Settings and choose Composite Audit Level. you can choose to set the Audit Level for this composite. If you choose Inherit, it will take the settings to what the server is being set to. Otherwise, we can override it by choosing Off, Production, or Development.
    Make sure your setting for that composite is not Off, keep inherit or production or development.
    Thanks,
    N

  • How can i write the below code using "For all entries"

    Hi
    How can we write the below code using "for all entries" and need to avoid joins...
    Please help
    SELECT aaufnr aobjnr aauart atxjcd a~pspel
    agstrp awerks carbpl cwerks
    INTO TABLE t_caufv
    FROM caufv AS a
    INNER JOIN afih AS b
    ON aaufnr = baufnr
    INNER JOIN crhd AS c
    ON bgewrk = cobjid
    AND c~objty = 'D'
    WHERE ( a~pspel = space
    OR a~txjcd = space
    OR NOT a~objnr IN
    ( select OBJNR from COBRB AS e
    WHERE objnr = a~objnr ) )
    AND a~werks IN s_plant
    AND a~auart IN s_wtype
    AND NOT a~objnr IN
    ( select OBJNR from JEST AS d
    WHERE objnr = a~objnr
    AND ( dstat = 'A0081'OR dstat = 'A0018' )
    AND d~inact 'X' ).
    Reward points for all helpfull answers
    Thanks
    Ammi.

    Hi,
    SELECT objnr objid aufnr
            from afih
            into table t_afih.
    SELECT objnr
            from JEST
            into table t_JEST
            where stat = 'A0045'
               OR stat = 'A0046'
               AND inact 'X'.
    SELECT objnr
            from COBRB
            into table t_cobrb.
    SELECT arbpl werks objid objty
          from crhd
          INTO table it_crhd
          FOR ALL ENTRIES IN it_afih
          WHERE objty eq 'D'
          AND gewrk = it_afih-objid.
    SELECT aufnr objnr auart txjcd pspel gstrp werks aufnr
            FROM caufv
            INTO table t_caufv
            FOR ALL ENTRIES IN it_afih
            WHERE aufnr = it_afih-aufnr
              And pspel = ' '
              AND txjcd = ' '
             ANd objnr ne it_crhd-objnr
              AND auart in s_wtype
              AND werks in s_plant.
             AND objnr ne it_jest-objnr.
    dont use NE in the select statements, it may effect performance also. Instead use if statements inside
    loops.
    loop at t_caufv.
    read table it_chrd............
      if t_caufv-objnr ne it_chrd-objnr.
      read table it_jest..........
       if   if t_caufv-objnr ne it_jest-objnr.
        (proceed further).
       endif.
      endif.
    endloop.
    hope this helps.
    Reward if useful.
    Regards,
    Anu

  • Can anyone confirm the date used for pushing the data into AR interface table? Is it abse don Actual ship date or scheduled ship date?

    Can anyone confirm the date used for pushing the data into AR interface table? Is it abse don Actual ship date or scheduled ship date? We are facing a scenario where trx date is lower than the actual ship to which logically sounds incorrect.
    Appreciate any quick response around this.

    Hi,
    Transaction date  will be your autoinvoice master program submission level date (If you haven't setup any logic.
    Please check the program level default date, if user enter old date ststem will pick the same.
    Customer is trying to set the value of the profile OM:Set receivables transaction date as current date for non-shippable lines at the responsiblity level. System does not set the transaction date to current date in ra_interface_lines_all.
    CAUSE
    Customer has used the functionality in R11i. But after the upgrade to R12, the system functions differently than R11i.
    SOLUTION
    1.Ensure that there are no scheduled workflow background process run.
    2.Set the profile "OM: Set Receivables Transaction Date as Current Date for Non-Shippable Lines"  at Responsibility level only as Yes.
    3.Now switch the responsibility to which the profile is set.
    4.Create order for Non-Shippable Lines and progress it to invoicing.
    5.Ensure that the 'workflow background process' concurrent program is run in the same responsibility and this line is considered in it.
    6.Now check if the 'SHIP_DATE_ACTUAL' is populated to ra_interface_lines_all

  • Problem in getting records using FOR ALL ENTRIES

    Hi All,
    I am bringing the employee details with required selection criteria into an internal master table IT_EMPDETAILS.
    Now, I would want to fill the other columns of this internal table, using FOR ALL ENTRIES as  below:
      SELECT ZRCODE FROM PA9001
      INTO CORRESPONDING FIELDS OF TABLE IT_EMPDETAILS
      FOR ALL ENTRIES IN IT_EMPDETAILS
      WHERE   PERNR = IT_EMPDETAILS-PERNR
          AND ENDDA = '99991231'.
    but while i use this, it is actually clearing the IT_EMPDETAILS instead of filling the column of IT_EMPDETAILS table.
    what could be going wrong??
    Thanks in advance,
    Mohan

    Dear All,
    Thanks for the amazing replies, yesterday's world cup match is really doing wonders i guess!
    To give more insight at what i am looking for and what is done so far:
    I tried creating another Internal table and then filled that with only PERNR.
    and then using that. tried to fill IT_EMPDETAILS internal table using for all entries,
    alas it did not work, and it did not work with APPENDING CORRESPONDING either.
    now, coming to using LOOP, if I use loop, I am going run the loop for 1lakh emp(approx..and going high everyday) and modify the internal table for 1lakh records. AND not only that, I am going to loop another 9 tables in similar manner. that is 9lakh loops AND thats not all,
    after that I have to again loop the master internal table to loop and fill other employee details like 'text' instead of 'code' from a master table.
    This is one of the most query intensive, realtime, online comprehensive employee report that i am making.
    Appreciate replies from ABAP performance tuning experts and gurus in advance.
    Cheers,
    Mohan

  • SD Flow program using For all entries.

    using simple ALV grid: I have the urgent requirement of changing the following program using 'For all entries' instead of joins and I should not use 'TABLES' -- For top-of-page I need to get dynamic fields like if I select company code in the selection screen then I need to get 'This report is base on COMPANY CODE'.
    This program is about sales flow where i shud get only those records that have ebeln in vbak, delivery, invoice.
    The original program is as follows:
    *& Report  ZSD_DOCU_FLOW                                               *
    REPORT  zsd_docu_flow  NO STANDARD PAGE HEADING                    .
    * Program     : ZCOS_SALES                                           *
    * Dev. Class  :  ZSD
    * Functional  :
    * Created on  :                                                        *
    * Project     :
    * CR Number   :
    * Transaction :  ZSDCSUT                                               *
    * Description :   * Sales document life cylce for given customer
    *                  to declaired period displaying the sales document
    *                  details ,with relevant del details and corresponding
    *                  Invocie Details
    *-----------     Tables Declaration      -----------*
    TABLES: vbak,vbap,vbfa,kna1,vbrk,vbrp,likp,lips,t001.
    TYPE-POOLS : slis.
    *-----------    Internal Tables Declaration      -----------*
    *      Internal Table for Sales Order data                   *
    DATA: BEGIN OF it_so OCCURS 0,
            vbeln LIKE vbak-vbeln,
            kunnr LIKE vbak-kunnr,
            posnr LIKE vbap-posnr,
            matnr LIKE vbap-matnr,
            kwmeng LIKE vbap-kwmeng,
            netwr LIKE vbap-netwr,
         END OF it_so.
    *      Internal Table for Delivery Order data                   *
    DATA: BEGIN OF it_del OCCURS 0,
            delnum  LIKE likp-vbeln,
            lfdat LIKE likp-lfdat,
            delitem LIKE lips-posnr,
            lfimg LIKE lips-lfimg,
          END OF it_del.
    *      Internal Table for Invoice data                          *
    DATA: BEGIN OF  it_inv OCCURS 0,
            invnum LIKE vbrk-vbeln,
            invitem LIKE vbrp-posnr,
            fkimg LIKE vbrp-fkimg,
            amount LIKE vbrp-netwr,
         END OF it_inv.
    *      Internal Table for Final data                            *
    DATA: BEGIN OF it_final OCCURS 0,
            vbeln LIKE vbak-vbeln,
            posnr LIKE vbap-posnr,
            kunnr LIKE vbak-kunnr,
            name LIKE kna1-name1,
            matnr LIKE vbap-matnr,
            kwmeng LIKE vbap-kwmeng,
            netwr LIKE vbap-netwr,
            delnum  LIKE likp-vbeln,
            lfdat LIKE likp-lfdat,
            delitem LIKE lips-posnr,
            lfimg LIKE lips-lfimg,
            invnum LIKE vbrk-vbeln,
            invitem LIKE vbrp-posnr,
            fkimg LIKE vbrp-fkimg,
            amount LIKE vbrp-netwr,
         END OF it_final.
    *-----------    Variables Declaration      -----------*
    DATA: v_name LIKE kna1-kunnr," variable for customer name
          v_delnum LIKE likp-vbeln," variable for delivery number
          v_invnum LIKE vbrk-vbeln." variable for invoce number
    DATA : ls_layout TYPE slis_layout_alv,
           it_fcat TYPE slis_t_fieldcat_alv ,
           wa_fcat TYPE slis_fieldcat_alv,
           lh TYPE slis_t_listheader,
           ls TYPE slis_listheader,
           it_events TYPE slis_t_event  ,
           ls_event TYPE slis_alv_event ,
           i_sort     TYPE slis_t_sortinfo_alv,
           w_var TYPE i.
    DATA : l_date(10).
    DATA : l_date1(20).
    DATA : l_repid LIKE trdir-name.
    l_repid = 'ZSD_DOCU_FLOW1'.
    *-----------    Select-options & parameters Declaration  ---*
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_bukrs LIKE vbak-bukrs_vf,
                 p_vkorg LIKE vbak-vkorg,
                p_vtweg LIKE vbak-vtweg,
                p_spart LIKE vbak-spart.
    SELECT-OPTIONS: s_kunnr FOR vbak-kunnr,
                    s_audat FOR vbak-audat.
    SELECTION-SCREEN END OF BLOCK b1.
    *----------- AT SELECTION-SCREEN  --------------------------*
    AT SELECTION-SCREEN.
      SELECT SINGLE * FROM  t001 INTO t001
                                WHERE bukrs = p_bukrs.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Company Code'.
      ENDIF.
      SELECT SINGLE * FROM vbak INTO vbak
                              WHERE vkorg = p_vkorg.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Sales Organization'.
      ENDIF.
      SELECT SINGLE * FROM vbak INTO vbak
                                WHERE vtweg = p_vtweg.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid distribution channel'.
      ENDIF.
      SELECT SINGLE * FROM vbak INTO vbak
                                WHERE spart = p_spart.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Division'.
      ENDIF.
      SELECT SINGLE * FROM kna1 INTO kna1
                                WHERE kunnr IN s_kunnr.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Customer Number'.
      ENDIF.
    *----------- START-OF-SELECTION-----------------------------*
    START-OF-SELECTION.
      ls-typ = 'H'.
      ls-info = 'Sales Document Flow'.
      APPEND ls TO lh.
      ls-typ = 'S'.
      WRITE: sy-datum TO l_date USING EDIT MASK '__/__/____'.
      CONCATENATE 'DATE :' l_date INTO l_date1 SEPARATED BY space.
      ls-info = l_date1.
      APPEND ls TO lh.
      PERFORM field_cat.
      PERFORM t_sort_build USING i_sort.
      PERFORM get-data.
    *----------- END-OF-SELECTION-----------------------------*
    END-OF-SELECTION.
    IF it_final[] IS INITIAL.
        MESSAGE i000(8i) WITH 'No data Found'.
        EXIT.
      ENDIF.
    PERFORM print-data.
    *&      Form  get-data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get-data .
    *  Accesing Sales Data
      SELECT a~vbeln a~kunnr b~posnr b~matnr b~kwmeng b~netwr
       INTO CORRESPONDING FIELDS OF TABLE it_so
       FROM vbak AS a INNER JOIN vbap AS b
                             ON a~vbeln = b~vbeln
                              WHERE a~bukrs_vf = p_bukrs
                                 AND a~vkorg = p_vkorg
                                 AND  a~vtweg = p_vtweg
                                    AND a~spart = p_spart
                                     AND a~kunnr IN s_kunnr
                                          AND a~audat IN s_audat.
      LOOP AT it_so.
        SELECT SINGLE name1 FROM kna1 INTO v_name
                                         WHERE kunnr = it_so-kunnr.
        SELECT SINGLE vbeln FROM vbfa INTO v_delnum
                                          WHERE vbelv = it_so-vbeln
                                            AND  vbtyp_n = 'J'.
        IF sy-subrc = 0.
          SELECT SINGLE  vbeln FROM vbfa INTO v_invnum
                                WHERE vbelv = v_delnum
                                  AND  vbtyp_n = 'M'.
        ENDIF.
        MOVE-CORRESPONDING it_so TO it_final.
        it_final-name = v_name.
        it_final-delnum = v_delnum.
        it_final-invnum = v_invnum.
        APPEND it_final.
        CLEAR it_final.
        CLEAR v_delnum.
        CLEAR v_invnum.
      ENDLOOP.
      LOOP AT it_final.
        IF it_final-delnum NE ' '.
    * Reading Del Data.
          SELECT SINGLE  a~vbeln  a~lfdat b~posnr b~lfimg   INTO
                    (it_del-delnum, it_del-lfdat, it_del-delitem,
                     it_del-lfimg ) FROM
                        likp AS a INNER JOIN lips AS b ON a~vbeln = b~vbeln
                                   WHERE a~vbeln = it_final-delnum
                                   AND b~posnr = it_final-posnr.
          MOVE-CORRESPONDING it_del TO it_final.
          MODIFY it_final.
        ENDIF.
        IF it_final-invnum NE ' '.
    * Reading Invoice Data.
          SELECT SINGLE vbeln posnr fkimg netwr INTO
         (it_inv-invnum, it_inv-invitem, it_inv-fkimg, it_inv-amount )
                       FROM vbrp  WHERE vbeln = it_final-invnum
                                  AND   posnr = it_final-posnr.
          MOVE-CORRESPONDING it_inv TO it_final.
          MODIFY it_final.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " get-data
    *&      Form  print-data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM print-data .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = l_repid
    *     I_CALLBACK_PF_STATUS_SET          = ' '
    *     I_CALLBACK_USER_COMMAND           = ' '
         i_callback_top_of_page            = 'TOP'
    *     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *     I_CALLBACK_HTML_END_OF_LIST       = ' '
    *     I_STRUCTURE_NAME                  =
    *     I_BACKGROUND_ID                   = ' '
    *     I_GRID_TITLE                      =
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT                         =
         it_fieldcat                       = it_fcat
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS                 =
         IT_SORT                           = i_sort[]
    *     IT_FILTER                         =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
    *     I_SAVE                            = ' '
    *     IS_VARIANT                        =
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT                          =
    *     IS_REPREP_ID                      =
    *     I_SCREEN_START_COLUMN             = 0
    *     I_SCREEN_START_LINE               = 0
    *     I_SCREEN_END_COLUMN               = 0
    *     I_SCREEN_END_LINE                 = 0
    *     IT_ALV_GRAPHICS                   =
    *     IT_HYPERLINK                      =
    *     IT_ADD_FIELDCAT                   =
    *     IT_EXCEPT_QINFO                   =
    *     I_HTML_HEIGHT_TOP                 =
    *     I_HTML_HEIGHT_END                 =
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER           =
    *     ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_final.
    *   EXCEPTIONS
    *     PROGRAM_ERROR                     = 1
    *     OTHERS                            = 2
    *  IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *  ENDIF.
    ENDFORM.                    " print-data
    *&      Form  field_cat
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM field_cat .
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'VBELN'.
      wa_fcat-key = 'X'.
      wa_fcat-ref_fieldname = 'VBELN'.
      wa_fcat-ref_tabname = 'VBAK'.
      wa_fcat-seltext_m = 'Sales Order NO'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'POSNR'.
      wa_fcat-ref_fieldname = 'POSNR'.
      wa_fcat-ref_tabname = 'VBAP'.
      wa_fcat-seltext_m = 'SalesItemNO'.
      wa_fcat-fix_column = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'KUNNR'.
      wa_fcat-seltext_m = 'CUSTNUM'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'NAME'.
      wa_fcat-seltext_m = 'CUSTNAME'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'MATNUM'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'KWMENG'.
      wa_fcat-seltext_m = 'Sales Quantity'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'NETWR'.
      wa_fcat-seltext_m = 'Value'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'DELNUM'.
      wa_fcat-seltext_m = 'DeloveryNum'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'DELITEM'.
      wa_fcat-seltext_m = 'DelItemNO'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'LFDAT'.
      wa_fcat-seltext_m = 'DelDate'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'LFIMG'.
      wa_fcat-seltext_m = 'DelQuantity'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'INVNUM'.
      wa_fcat-seltext_m = 'InvoiceNum'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'INVITEM'.
      wa_fcat-seltext_m = 'InvoiceItem'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'FKIMG'.
      wa_fcat-seltext_m = 'INVQuantity'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'AMOUNT'.
      wa_fcat-seltext_m = 'INVvalue'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
    ENDFORM.     " field_cat
    *&      Form  top
    *       text
    FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv.
      DATA: ls_sort TYPE slis_sortinfo_alv.
      ls_sort-fieldname = 'VBELN'.
      ls_sort-spos      = 1.
      ls_sort-up        = 'X'.
      ls_sort-subtot    = 'X'.
      APPEND ls_sort TO l_sort.
      ls_sort-fieldname = 'KUNNR'.
      ls_sort-spos      = 2.
      ls_sort-up        = 'X'.
      APPEND ls_sort TO l_sort.
    ENDFORM.                    "t_sort_bui
    FORM top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = lh
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP
    ===========================================================================
    I have started the new program but i have trouble with the final internal table. Since i'm using For all entries I have declared internal tables for each table. My incomplete new program is as follows(not sure if the logic is correct till what I have coded):
    *& Report  Z_SDFLOW                                                    *
    REPORT  Z_SDFLOW  NO STANDARD PAGE HEADING.
    ********* TABLES TO BE USED ***********************
    **** VBAK - SALES DOCUMENT HEADER
    * VBAP - SALES ITEM
    * VBFA - SALES DOCUMENT FLOW
    * KNA1- CUSTOMER MASTER
    * VBRK - BILLING DOCUMENT HEADER
    * VBRP - BLLING DOCUMENT ITEM
    * LIKP - DELIVERY HEADER
    * LIPS - DELIVERY ITEM
    * TOO1 - COMPANY CODES
    * SLIS.
    TYPE-POOLS: SLIS.
    ** STRUCTURE DECLARATIONS ********
    **STRUCTURE FOR ENQUIRY.
    **STRUCTURE FOR QUOTATION.
    **STRUCTURE FOR SALES ORDER HEADER- VBAK.
    TYPES: BEGIN OF XT_VBAK,
    VBELN TYPE VBAK-VBELN,     "SALES DOCUMENT NUMBER
    KUNNR TYPE VBAK-KUNNR,     " SOLD-TO-PARTY
    END OF XT_VBAK.
    **STRUCTURE FOR SALES ORDER  ITEM-VBAP
    TYPES: BEGIN OF XT_VBAP,
    POSNR TYPE VBAP-POSNR,     " SALES ITEM NUMBER
    MATNR TYPE VBAP-MATNR,     " MATERIAL NUMBER
    KWMENG TYPE VBAP-KWMENG,   " CUMMULATIVE ORDER QUANTITY IN SALES UNITS
    NETWR TYPE VBAP-NETWR,     " NET VALUE OF THE ORDER ITEM
    END OF XT_VBAP.
    ** STRUCTURE FOR DELIVERY HEADER -LIKP
    TYPES: BEGIN OF XT_LIKP,
    DELVBELN TYPE LIKP-VBELN,           "DELIVERY DOCUMENT NUMBER
    LFDAT TYPE LIKP-LFDAT,           " DELIVERY DATE
    END OF XT_LIKP.
    **STRUCTURE FOR DELIVERY ITEM - LIPS
    TYPES: BEGIN OF XT_LIPS,
    DELPOSNR TYPE LIPS-POSNR,           " DELIVERY ITEM NUMBER
    LFIMG TYPE LIPS-LFIMG,           " ACTUAL QUANTITY DELIVERED
    END OF XT_LIPS.
    **STRUCTURE FOR BILLING DOCUMENT HEADER -VBRK
    TYPES: BEGIN OF XT_VBRK,
    INVVBELN TYPE VBRK-VBELN,          "BILLING DOCUMENT NUMBER
    END OF XT_VBRK.
    **STRUCTURE FOR BILLING DOCUMENT ITEM - VBRP
    TYPES: BEGIN OF XT_VBRP,
    INVPOSNR TYPE VBRP-POSNR,          "BILLING ITEM NUMBER
    FKIMG TYPE VBRP-FKIMG,          "ACTUAL INVOICED QUANTITY
    INVNETWR TYPE VBRP-NETWR,          "NET VALUE OF THE BILLING ITEM
    END OF XT_VBRP.
    **STRUCTURE FOR FINAL INTERNAL TABLE.
    TYPES: BEGIN OF XT_FINAL,
    VBELN TYPE VBAK-VBELN,
    DELVBELN TYPE LIKP-VBELN,
    INVBELN TYPE VBRK-VBELN,
    KUNNR TYPE VBAK-KUNNR,
    POSNR TYPE VBAP-POSNR,
    DELPOSNT TYPE LIPS-POSNR,
    INVPOSNR TYPE VBRP-POSNR,
    MATNR TYPE VBAP-MATNR,
    KWMENG TYPE VBAP-KWMENG,
    NETWR TYPE VBAP-NETWR,
    INVNETWR TYPE VBRP-NETWR,
    LFDAT TYPE LIKP-LFDAT,
    LFIMG TYPE LIPS-LFIMG,
    FKIMG TYPE VBRP-FKIMG,
    NAME1 TYPE KNA1-NAME1,
    END OF XT_FINAL.
    **DATA DECLARATIONS
    DATA: V_NAME1 TYPE KNA1-NAME1,  "#EC *
          V_DELVBELN TYPE LIKP-VBELN,
          V_INVVBELN TYPE VBRK-VBELN,
          V_BUKRS TYPE T001-BUKRS,    "COMPANY CODE "#EC *
          V_AUDAT TYPE VBAK-AUDAT,
          V_VKORG TYPE VBAK-VKORG,
          V_VKGRP TYPE VBAK-VKGRP,
          V_SPART TYPE VBAK-SPART.
    **INTERNAL TABLE DECLARATIONS
    DATA: IT_VBAK TYPE STANDARD TABLE OF XT_VBAK,
          WA_VBAK TYPE XT_VBAK,
          IT_VBAP TYPE STANDARD TABLE OF XT_VBAP,
          WA_VBAP TYPE XT_VBAP,
          IT_LIKP TYPE STANDARD TABLE OF XT_LIKP,
          WA_LIKP TYPE XT_LIKP,
          IT_LIPS TYPE STANDARD TABLE OF XT_LIPS,
          WA_LIPS TYPE XT_LIPS,
          IT_VBRK TYPE STANDARD TABLE OF XT_VBRK,
          WA_VBRK TYPE XT_VBRK,
          IT_VBRP TYPE STANDARD TABLE OF XT_VBRP,
          WA_VBRP TYPE XT_VBRP,
          IT_FINAL TYPE STANDARD TABLE OF XT_FINAL,
          WA_FINAL TYPE XT_FINAL.
    **ALV DECLARATIONS
    DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
          IT_LSTHDR TYPE SLIS_T_LISTHEADER,
          WA_LSTHDR TYPE SLIS_LISTHEADER,
          IT_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: S_BUKRS FOR V_BUKRS NO INTERVALS NO-EXTENSION,
                    S_VBELN FOR WA_VBAK-VBELN,  "SALES DOCUMENT NUMBER
                    S_KUNNR FOR WA_VBAK-KUNNR,  "SOLD-TO-PARTY
                    S_AUDAT FOR V_AUDAT,      "SALES DOCUMENT DATE
                    S_VKORG FOR V_VKORG,      "SALES ORGANISATION
                    S_VKGRP FOR V_VKGRP,      "SALES GROUP
                    S_SPART FOR V_SPART.      "DIVISION
    SELECTION-SCREEN END OF BLOCK b1.
    *****************SCREEN VALIDATION***************
    AT SELECTION-SCREEN.
    SELECT SINGLE BUKRS FROM T001 INTO V_BUKRS WHERE BUKRS IN S_BUKRS."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID COMPANY CODE'.
    ENDIF.
    SELECT SINGLE VBELN FROM VBAK INTO
              CORRESPONDING FIELDS OF WA_VBAK WHERE VBELN IN S_VBELN.
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER VALID SALES DOCUMENT NUMBER'.
    ENDIF.
    SELECT SINGLE KUNNR FROM VBAK INTO
              CORRESPONDING FIELDS OF WA_VBAK WHERE KUNNR IN S_KUNNR. "EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID CUSTOMER NUMBER'.
    ENDIF.
    SELECT SINGLE AUDAT FROM VBAK INTO V_AUDAT WHERE AUDAT IN S_AUDAT."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES DOCUMENT DATE'.
    ENDIF.
    SELECT SINGLE VKORG FROM VBAK INTO V_VKORG WHERE VKORG IN S_VKORG."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES ORGANISATION'.
    ENDIF.
    SELECT SINGLE VKGRP FROM VBAK INTO V_VKGRP WHERE VKGRP IN S_VKGRP."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES GROUP'.
    ENDIF.
    SELECT SINGLE SPART FROM VBAK INTO V_SPART WHERE SPART IN S_SPART."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES DIVISION'.
    ENDIF.
    PERFORM GET_DATA.
    *&      Form  GET_DATA
    FORM GET_DATA .
    SELECT VBELN KUNNR
            INTO TABLE IT_VBAK
            FROM VBAK
            WHERE VBELN IN S_VBELN.
    *        BUKRS_VF IN S_BUKRS AND
    *        VKORG IN S_VKORG AND
    *        VKGRP IN S_VKGRP AND
    *        SPART IN S_SPART AND
    *        KUNNR IN S_KUNNR AND
    *        AUDAT IN S_AUDAT.
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT POSNR MATNR KWMENG NETWR
            INTO TABLE IT_VBAP
            FROM VBAP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT VBELN LFDAT
            INTO TABLE IT_LIKP
            FROM LIKP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    IF IT_VBAP[] IS NOT INITIAL.
    SELECT POSNR LFIMG
            INTO TABLE IT_LIPS
            FROM LIPS
            FOR ALL ENTRIES IN IT_VBAP
            WHERE POSNR = IT_VBAP-POSNR.
    ENDIF.
    IF IT_LIKP[] IS NOT INITIAL.
    SELECT VBELN
            INTO TABLE IT_VBRK
            FROM VBRK
            FOR ALL ENTRIES IN IT_LIKP
            WHERE VBELN = IT_LIKP-DELVBELN.
    ENDIF.
    IF IT_LIPS[] IS NOT INITIAL.
    SELECT POSNR FKIMG NETWR
            INTO TABLE IT_VBRP
            FROM VBRP
            FOR ALL ENTRIES IN IT_LIPS
            WHERE POSNR = IT_LIPS-DELPOSNR.
    ENDIF.
    ENDFORM.                    " GET_DATA
    Edited by: srk s on Jan 29, 2008 7:33 PM
    Edited by: Alvaro Tejada Galindo on Jan 29, 2008 9:49 AM

    Hi Satish,
    I have started the new program but i have trouble with the final internal table. Since i'm using For all entries, I have declared internal tables for each table. My incomplete new program is as follows(not sure if the logic is correct till what I have coded):
    *& Report  Z_SDFLOW                                                    *
    REPORT  Z_SDFLOW  NO STANDARD PAGE HEADING.
    ********* TABLES TO BE USED ***********************
    **** VBAK - SALES DOCUMENT HEADER
    * VBAP - SALES ITEM
    * VBFA - SALES DOCUMENT FLOW
    * KNA1- CUSTOMER MASTER
    * VBRK - BILLING DOCUMENT HEADER
    * VBRP - BLLING DOCUMENT ITEM
    * LIKP - DELIVERY HEADER
    * LIPS - DELIVERY ITEM
    * TOO1 - COMPANY CODES
    * SLIS.
    TYPE-POOLS: SLIS.
    ** STRUCTURE DECLARATIONS ********
    **STRUCTURE FOR ENQUIRY.
    **STRUCTURE FOR QUOTATION.
    **STRUCTURE FOR SALES ORDER HEADER- VBAK.
    TYPES: BEGIN OF XT_VBAK,
    VBELN TYPE VBAK-VBELN,     "SALES DOCUMENT NUMBER
    KUNNR TYPE VBAK-KUNNR,     " SOLD-TO-PARTY
    END OF XT_VBAK.
    **STRUCTURE FOR SALES ORDER  ITEM-VBAP
    TYPES: BEGIN OF XT_VBAP,
    POSNR TYPE VBAP-POSNR,     " SALES ITEM NUMBER
    MATNR TYPE VBAP-MATNR,     " MATERIAL NUMBER
    KWMENG TYPE VBAP-KWMENG,   " CUMMULATIVE ORDER QUANTITY IN SALES UNITS
    NETWR TYPE VBAP-NETWR,     " NET VALUE OF THE ORDER ITEM
    END OF XT_VBAP.
    ** STRUCTURE FOR DELIVERY HEADER -LIKP
    TYPES: BEGIN OF XT_LIKP,
    DELVBELN TYPE LIKP-VBELN,           "DELIVERY DOCUMENT NUMBER
    LFDAT TYPE LIKP-LFDAT,           " DELIVERY DATE
    END OF XT_LIKP.
    **STRUCTURE FOR DELIVERY ITEM - LIPS
    TYPES: BEGIN OF XT_LIPS,
    DELPOSNR TYPE LIPS-POSNR,           " DELIVERY ITEM NUMBER
    LFIMG TYPE LIPS-LFIMG,           " ACTUAL QUANTITY DELIVERED
    END OF XT_LIPS.
    **STRUCTURE FOR BILLING DOCUMENT HEADER -VBRK
    TYPES: BEGIN OF XT_VBRK,
    INVVBELN TYPE VBRK-VBELN,          "BILLING DOCUMENT NUMBER
    END OF XT_VBRK.
    **STRUCTURE FOR BILLING DOCUMENT ITEM - VBRP
    TYPES: BEGIN OF XT_VBRP,
    INVPOSNR TYPE VBRP-POSNR,          "BILLING ITEM NUMBER
    FKIMG TYPE VBRP-FKIMG,          "ACTUAL INVOICED QUANTITY
    INVNETWR TYPE VBRP-NETWR,          "NET VALUE OF THE BILLING ITEM
    END OF XT_VBRP.
    **STRUCTURE FOR FINAL INTERNAL TABLE.
    TYPES: BEGIN OF XT_FINAL,
    VBELN TYPE VBAK-VBELN,
    DELVBELN TYPE LIKP-VBELN,
    INVBELN TYPE VBRK-VBELN,
    KUNNR TYPE VBAK-KUNNR,
    POSNR TYPE VBAP-POSNR,
    DELPOSNT TYPE LIPS-POSNR,
    INVPOSNR TYPE VBRP-POSNR,
    MATNR TYPE VBAP-MATNR,
    KWMENG TYPE VBAP-KWMENG,
    NETWR TYPE VBAP-NETWR,
    INVNETWR TYPE VBRP-NETWR,
    LFDAT TYPE LIKP-LFDAT,
    LFIMG TYPE LIPS-LFIMG,
    FKIMG TYPE VBRP-FKIMG,
    NAME1 TYPE KNA1-NAME1,
    END OF XT_FINAL.
    **DATA DECLARATIONS
    DATA: V_NAME1 TYPE KNA1-NAME1,  "#EC *
          V_DELVBELN TYPE LIKP-VBELN,
          V_INVVBELN TYPE VBRK-VBELN,
          V_BUKRS TYPE T001-BUKRS,    "COMPANY CODE "#EC *
          V_AUDAT TYPE VBAK-AUDAT,
          V_VKORG TYPE VBAK-VKORG,
          V_VKGRP TYPE VBAK-VKGRP,
          V_SPART TYPE VBAK-SPART.
    **INTERNAL TABLE DECLARATIONS
    DATA: IT_VBAK TYPE STANDARD TABLE OF XT_VBAK,
          WA_VBAK TYPE XT_VBAK,
          IT_VBAP TYPE STANDARD TABLE OF XT_VBAP,
          WA_VBAP TYPE XT_VBAP,
          IT_LIKP TYPE STANDARD TABLE OF XT_LIKP,
          WA_LIKP TYPE XT_LIKP,
          IT_LIPS TYPE STANDARD TABLE OF XT_LIPS,
          WA_LIPS TYPE XT_LIPS,
          IT_VBRK TYPE STANDARD TABLE OF XT_VBRK,
          WA_VBRK TYPE XT_VBRK,
          IT_VBRP TYPE STANDARD TABLE OF XT_VBRP,
          WA_VBRP TYPE XT_VBRP,
          IT_FINAL TYPE STANDARD TABLE OF XT_FINAL,
          WA_FINAL TYPE XT_FINAL.
    **ALV DECLARATIONS
    DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
          IT_LSTHDR TYPE SLIS_T_LISTHEADER,
          WA_LSTHDR TYPE SLIS_LISTHEADER,
          IT_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: S_BUKRS FOR V_BUKRS NO INTERVALS NO-EXTENSION,
                    S_VBELN FOR WA_VBAK-VBELN,  "SALES DOCUMENT NUMBER
                    S_KUNNR FOR WA_VBAK-KUNNR,  "SOLD-TO-PARTY
                    S_AUDAT FOR V_AUDAT,      "SALES DOCUMENT DATE
                    S_VKORG FOR V_VKORG,      "SALES ORGANISATION
                    S_VKGRP FOR V_VKGRP,      "SALES GROUP
                    S_SPART FOR V_SPART.      "DIVISION
    SELECTION-SCREEN END OF BLOCK b1.
    *****************SCREEN VALIDATION***************
    AT SELECTION-SCREEN.
    SELECT SINGLE BUKRS FROM T001 INTO V_BUKRS WHERE BUKRS IN S_BUKRS."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID COMPANY CODE'.
    ENDIF.
    SELECT SINGLE VBELN FROM VBAK INTO
              CORRESPONDING FIELDS OF WA_VBAK WHERE VBELN IN S_VBELN.
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER VALID SALES DOCUMENT NUMBER'.
    ENDIF.
    SELECT SINGLE KUNNR FROM VBAK INTO
              CORRESPONDING FIELDS OF WA_VBAK WHERE KUNNR IN S_KUNNR. "EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID CUSTOMER NUMBER'.
    ENDIF.
    SELECT SINGLE AUDAT FROM VBAK INTO V_AUDAT WHERE AUDAT IN S_AUDAT."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES DOCUMENT DATE'.
    ENDIF.
    SELECT SINGLE VKORG FROM VBAK INTO V_VKORG WHERE VKORG IN S_VKORG."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES ORGANISATION'.
    ENDIF.
    SELECT SINGLE VKGRP FROM VBAK INTO V_VKGRP WHERE VKGRP IN S_VKGRP."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES GROUP'.
    ENDIF.
    SELECT SINGLE SPART FROM VBAK INTO V_SPART WHERE SPART IN S_SPART."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES DIVISION'.
    ENDIF.
    PERFORM GET_DATA.
    *&      Form  GET_DATA
    FORM GET_DATA .
    SELECT VBELN KUNNR
            INTO TABLE IT_VBAK
            FROM VBAK
            WHERE VBELN IN S_VBELN.
    *        BUKRS_VF IN S_BUKRS AND
    *        VKORG IN S_VKORG AND
    *        VKGRP IN S_VKGRP AND
    *        SPART IN S_SPART AND
    *        KUNNR IN S_KUNNR AND
    *        AUDAT IN S_AUDAT.
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT POSNR MATNR KWMENG NETWR
            INTO TABLE IT_VBAP
            FROM VBAP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT VBELN LFDAT
            INTO TABLE IT_LIKP
            FROM LIKP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    IF IT_VBAP[] IS NOT INITIAL.
    SELECT POSNR LFIMG
            INTO TABLE IT_LIPS
            FROM LIPS
            FOR ALL ENTRIES IN IT_VBAP
            WHERE POSNR = IT_VBAP-POSNR.
    ENDIF.
    IF IT_LIKP[] IS NOT INITIAL.
    SELECT VBELN
            INTO TABLE IT_VBRK
            FROM VBRK
            FOR ALL ENTRIES IN IT_LIKP
            WHERE VBELN = IT_LIKP-DELVBELN.
    ENDIF.
    IF IT_LIPS[] IS NOT INITIAL.
    SELECT POSNR FKIMG NETWR
            INTO TABLE IT_VBRP
            FROM VBRP
            FOR ALL ENTRIES IN IT_LIPS
            WHERE POSNR = IT_LIPS-DELPOSNR.
    ENDIF.
    ENDFORM.                    " GET_DATA
    Code Formatted by: Alvaro Tejada Galindo on Jan 29, 2008 9:48 AM

  • I have a problem in using  for all entries

    Hi i have a problem in using <b>for all entries</b>
    i have declared the two internal tables as below
      DATA: BEGIN OF ITAB OCCURS 10,
              EBELN LIKE EKKO-EBELN,
              LIFNR LIKE EKKO-LIFNR,
              EBELP LIKE EKBE-EBELP,
              BELNR LIKE EKBE-BELNR,
    *          MATNR LIKE EKPO-MATNR,
    *          TXZ01 LIKE EKPO-TXZ01,
              VGABE LIKE EKBE-VGABE,
              GJAHR LIKE EKBE-GJAHR,
              KNUMV LIKE EKKO-KNUMV,
         END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 10,
              EBELN LIKE EKPO-EBELN,
              MATNR LIKE EKPO-MATNR,
              TXZ01 LIKE EKPO-TXZ01,
              WERKS LIKE EKPO-WERKS,
              NETWR LIKE EKPO-NETWR,
              MENGE LIKE EKPO-MENGE,
              MWSKZ LIKE EKPO-MWSKZ,
              LIFNR LIKE EKKO-LIFNR,
              EBELP LIKE EKBE-EBELP,
              BELNR LIKE EKBE-BELNR,
          END OF ITAB1.
    <b>and now i have tried to move the values in those internal tables using these statements</b>
       SELECT  A~EBELN A~LIFNR A~KNUMV B~VGABE B~EBELP B~GJAHR B~BELNR
            FROM  EKKO AS A
            INNER JOIN EKBE  AS B ON  B~EBELN = A~EBELN
            INTO  CORRESPONDING
            FIELDS OF TABLE ITAB WHERE B~VGABE = '2'.
       SELECT EKPO~EBELN EKPO~MATNR EKPO~TXZ01 EKPO~WERKS EKPO~NETWR
              EKPO~MENGE EKPO~MWSKZ
          FROM EKPO
          INTO CORRESPONDING FIELDS OF TABLE ITAB1
          FOR ALL ENTRIES IN ITAB
          WHERE EBELN = ITAB-EBELN.
          LOOP AT ITAB1.
           READ TABLE ITAB WITH KEY EBELN = ITAB-EBELN.
           ITAB-EBELN = ITAB1-EBELN.
           ITAB1-LIFNR = ITAB-LIFNR.
           ITAB1-EBELP = ITAB-EBELP.
           ITAB1-BELNR = ITAB-BELNR.
           ITAB1-EBELP = ITAB-EBELP.
           APPEND ITAB1.
          ENDLOOP.
    But when i was using loop then it was displaying values in debugging mode but while i was trying to execute it was taking a lot of time i thought that it was due to more information in the already declared internal table so i have tried to remove the previous entries but it was showing an error while i was removing the old entries
    and when i  remove the loop at itab1 then i'll get output directly but it was displaying the itab fields which is my 1st internal table but not the values of itab1 can u explain me what is the possible error for that
    Regards ,
    Pavan

    before using for all entries in, u need to check whether the driver internal table is empty, if it is empty, u should not enter into select statement.
    if u wont use this check means, when the driver internal table is empty, the second select will take all the entires from the tables.
    SELECT  AEBELN ALIFNR AKNUMV BVGABE BEBELP BGJAHR B~BELNR
            FROM  EKKO AS A
            INNER JOIN EKBE  AS B ON  BEBELN = AEBELN
            INTO  CORRESPONDING
            FIELDS OF TABLE ITAB WHERE B~VGABE = '2'.
    if itab[] is not initial.
       SELECT EKPOEBELN EKPOMATNR EKPOTXZ01 EKPOWERKS EKPO~NETWR
              EKPOMENGE EKPOMWSKZ
          FROM EKPO
          INTO CORRESPONDING FIELDS OF TABLE ITAB1
          FOR ALL ENTRIES IN ITAB
          WHERE EBELN = ITAB-EBELN.
    endif.
    I hope this will help u.
    else,
    Sujatha.

  • Populating Empty Fields for Existing Internal Table Using For All Entries

    I have an internal table called itab_extract that populates without any issues in SELECT A and SELECT B below. Trying to avoid looping, I am using select DB table 'for all entries' in itab_extract. I want the empty fields in itab_extract to populate from the values in the database. However, about 200,000 entries are being appended to the table, and, the values that existed for the already populated fields in itab_extract are gone, and the new fields are populated.
    I've played with the syntax and cannot seem to get it to work. My next option is a time consuming loop.
    How should the for all entries syntax look to accomplish filling the empty fields in the itab?   Thank-You
    *read ekko
        select ebeln lifnr aedat bsart from ekko                                                     *SELECT A*
               into  CORRESPONDING FIELDS OF TABLE me->itab_extract
               where aedat in r_aedat.
        select ebeln lifnr aedat BSART from ekko                                                  *SELECT B*
               appending CORRESPONDING FIELDS OF TABLE me->itab_extract
               where aedat in S_DATE2 AND
                     BSART IN S_BSART.
          select ebelp werks matnr                                                                           *SELECT C*
            into CORRESPONDING FIELDS OF TABLE itab_extract
            from ekpo
            FOR ALL ENTRIES IN itab_extract
            where ebeln = itab_extract-ebeln.

    Hi Tom,
               This SQL statement will be time consuming, Do not use a loop.
    There are two options.
    1. Select EKKO and EKPO details based on standard SAP view. (You can type EKKO in se11 view to find the correct view).
        also use one range table populate r_aedat and s_date2 in the same. So you where condition will have r_newrange and   
        s_bsart. Also do not use into corresponding fields, it is not a good idea. It will increase your performance. Maintain the proper 
        sequence (Based on database structure of EKKO and EKPO)
    2. If you are keen to use for all entries, then first select ekko then after your sy-subrc check get the data from EKPO.
    Should be like this.
    select ebeln bsart aedat lifnr from ekko into table gt_ekko where aedat in r_newrange and bsart in s_bsart.
    if sy-subrc eq 0.
    sort gt_ekko by ebeln ascending.
    select ebeln ebelp werks matnr  into table gt_ekpo for all entries in gt_ekko where ebeln eq gt_ekko-ebeln.
    endif.
    Hope it helps,
    Best Regards,
    Tapodipta Khan.

  • Select using for all entries

    hi gurus,
    plz check my report using for all entries where i am give data in selection screen from date to date as 3.01.2007 to 4.02.2007
    my code does not provide me data between  above date to date.
    it fetch data from other date like 26.06.2006 to some other
    plz check code and give me solution for it.
    TABLES: bseg, bkpf.
    *ALV grid_data
    TYPE-POOLS: slis.
                           INTERNAL TABLES
    TYPES: BEGIN OF it_output,
           bukrs  TYPE bseg-bukrs, "Company Code
           belnr  TYPE bseg-belnr, "Accounting Document Number
           gjahr  TYPE bseg-gjahr, "Fiscal Year
           buzei  TYPE bseg-buzei, "Number of Line Item
           augdt  TYPE bseg-augdt, "Clearing Date
           shkzg  TYPE bseg-shkzg, "Debit/Credit Indicator
           dmbtr  TYPE bseg-dmbtr, "Amount in local currency
           kostl  TYPE bseg-kostl, "Cost Center
           hkont  TYPE bseg-hkont, "G/L Account
           matnr  TYPE bseg-matnr, "Material Number
           werks  TYPE bseg-werks, "Plant
           erfmg  TYPE bseg-erfmg, "Quantity in unit of entry
           blart  TYPE bkpf-blart, "Document type
           bldat  TYPE bkpf-bldat, "Document Date
           budat  TYPE bkpf-budat, "Posting Date
           monat  TYPE bkpf-monat, "Fiscal period
           cpudt  TYPE bkpf-cpudt, "Document Entry Date
           usnam  TYPE bkpf-usnam, "User name
           tcode  TYPE bkpf-tcode, "Transaction Code20
           bktxt  TYPE bkpf-bktxt, "Document Header Text
           waers  TYPE bkpf-waers, "Currency Key
           awtyp  TYPE bkpf-awtyp, "Reference procedure
           awkey  TYPE bkpf-awkey, "Object key
          END OF it_output.
    TYPES: BEGIN OF it_bkpf,
           bukrs  TYPE bkpf-bukrs,
           belnr  TYPE bkpf-belnr,
           gjahr  TYPE bkpf-gjahr,
           blart  TYPE bkpf-blart,
           bldat  TYPE bkpf-bldat,
           budat  TYPE bkpf-budat,
           monat  TYPE bkpf-monat,
           cpudt  TYPE bkpf-cpudt,
           usnam  TYPE bkpf-usnam,
           tcode  TYPE bkpf-tcode,
           bktxt  TYPE bkpf-bktxt,
           waers  TYPE bkpf-waers,
           awtyp  TYPE bkpf-awtyp,
           awkey  TYPE bkpf-awkey,
          END OF it_bkpf.
    DATA: lt_output TYPE it_output OCCURS 0 WITH HEADER LINE.
    DATA: lt_bkpf   TYPE it_bkpf OCCURS 0 WITH HEADER LINE.
                       ALV DECLARATION DATA                              *
    DATA: it_fieldcat   TYPE    slis_t_fieldcat_alv,
          it_heading    TYPE    slis_t_listheader,
          it_sort       TYPE    slis_t_sortinfo_alv,
          it_events     TYPE    slis_t_event,
          it_alv_event  TYPE    slis_alv_event,
          gv_repname    TYPE    syrepid,
          gv_save       TYPE    char1,
          is_layout     TYPE    slis_layout_alv.
                     SELECTION SCREEN                                    *
    SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME TITLE text-011.
    SELECT-OPTIONS: s_bukrs FOR bseg-bukrs NO INTERVALS,
                    s_blart FOR bkpf-blart,
                    s_budat FOR bkpf-budat.
    SELECTION-SCREEN END OF BLOCK bl.
                     START OF SELECTION                                  *
    START-OF-SELECTION.
      PERFORM get_data.
                       End of Selection                                  *
    END-OF-SELECTION.
      PERFORM build_field_catalog.
      PERFORM eventstab.
      PERFORM display_data.
                             FORMS                                       *
    *&      Form  get_data
          Get Data
    FORM get_data .
      SELECT bukrs
             belnr
             gjahr
             buzei
             augdt
             shkzg
             dmbtr
             kostl
             hkont
             matnr
             werks
             erfmg
             INTO TABLE lt_output
             FROM bseg
           WHERE bukrs IN s_bukrs.
      IF sy-subrc = 0.
        SORT lt_output BY belnr.
        DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.
      ENDIF.
      IF NOT lt_output[] IS INITIAL.
        SELECT bukrs
               belnr
               gjahr
               blart
               bldat
               budat
               monat
               cpudt
               usnam
               tcode
               bktxt
               waers
               awtyp
               awkey
           INTO TABLE lt_bkpf FROM bkpf
           FOR ALL ENTRIES IN lt_output
           WHERE bukrs = lt_output-bukrs AND
                 belnr = lt_output-belnr AND
                gjahr = lt_output-gjahr."AND
                 blart IN s_blart        AND
                 budat IN s_budat ."     AND
                blart = 'SA'     OR
                blart = 'SB'     OR
                blart = 'AB'     OR
                blart = 'ZC'.
    *sort lt_bkpf  by blart budat.
       DELETE lt_bkpf WHERE blart NOT IN s_blart AND
                            budat NOT IN s_budat.
      ENDIF.
      SORT lt_bkpf BY bukrs belnr.
    SORT lt_output[].
    DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.
      LOOP AT lt_output.
        READ TABLE lt_bkpf WITH KEY bukrs = lt_output-bukrs
                                    belnr = lt_output-belnr
                                    budat = lt_output-budat
                                    BINARY SEARCH.
        IF sy-subrc = 0.
          MOVE: lt_bkpf-gjahr TO  lt_output-gjahr,
                lt_bkpf-belnr TO  lt_output-belnr,
                lt_bkpf-blart TO  lt_output-blart,
                lt_bkpf-bldat TO  lt_output-bldat,
                lt_bkpf-budat TO  lt_output-budat,
                lt_bkpf-monat TO  lt_output-monat,
                lt_bkpf-cpudt TO  lt_output-cpudt,
                lt_bkpf-usnam TO  lt_output-usnam,
                lt_bkpf-tcode TO  lt_output-tcode,
                lt_bkpf-bktxt TO  lt_output-bktxt,
                lt_bkpf-waers TO  lt_output-waers,
                lt_bkpf-awtyp TO  lt_output-awtyp,
                lt_bkpf-awkey TO  lt_output-awkey.
          MODIFY lt_output.
       ELSE.
         DELETE lt_output.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "get_data
    thanks jayant

    Hi Jayant,
    You cannot retrieve data first from BSEG and then from BKPF.
    It is not correct and you cannot get the correct data.
    You should use BKPF which is header table first and then
    using for all entries retrieve data from BSEG.
    Use date field in the select statement condition for BKPF table retrieval and
    you don't have posting date field in BSEG.
    If you do like this, it will definitely work.
    Retrieve data from BKPF using date condition in SELECT statement.
    Then, using for all entries retrieve from BSEG.
    Reward if helpful.

  • Here iam using for-all-entries.

    Hi...
    2....here iam using for-all-entries.
    if the internal table is empty.then what will happen for next select statement.
    thanks and regards,
    k.swaminath

    Hi
    if you write like this
    <b>select data from table into itab where condituioj
    select data from table into itab1 for all entries in itab where condition</b>
    with out checking the weather the above select statement have data or not then it will give all the data which eist in that table
    <b>select data from table into itab where condituioj
    if not itab[] is initial
    select data from table into itab1 for all entries in itab where condition
    endif.</b>
    in this sitvation you don't get any data
    reward if usefull

  • Regarding Select using FOR ALL ENTRIES (FAEI)

    Hi all,
    Please help me with Select using FOR ALL ENTRIES (FAEI)
    Thanks in advns,
    Das.

    Hi,
    This version of the SELECT statement was the only way to join tables until SAP release 3.0E.  It is recommended that the SQL JOIN be used.  However, this is an alternate method of joining tables that may be used in some circumstances.  Remember, SQL JOIN doesn’t utilize the SAP internal database buffer.
    Example:
        SELECT EKGRP FROM T024
               INTO TABLE T_024.
        SELECT MATNR WERKS EKGRP FROM MARC
               INTO TABLE T_MARC
               FOR ALL ENTRIES IN T_024
               WHERE EKGRP = T_024-EKGRP.
    Prerequisites:
    The driver table cannot be empty. This would cause one full table scan.
    In general, keep the driver table as small and unique (in regards to the fields that would be needed for referencing in the FAEI) as possible. If duplicate entries are not deleted, identical data is read unnecessarily from the database.
    If FAEI is used, the selected field list must be a superset of all the key fields of the database tables used in SQL. This is absolutely required to avoid data loss since the DB interface in R/3 returns unique sets of the result set to the application program. Failing to ensure this may cause problems when you want to get all records from a database table that match a certain condition.
    Avoid using FAEI on a small DB table (like configuration tables). This could potentially cause full table scans for each FAEI packet. Even if it does index range scan, it is better to get data from the small DB tables by individual SELECT without the use of FAE.
    Always use FAEI in conjunction with a DB index otherwise it would cause multiple full table scans (one table scan for each FAEI packet).
    The first field(s) of the DB index should refer to the fields of the FAEI driver table in the SQL WHERE clause. Do not leave gaps between index fields in the WHERE clause. Inefficient index access will impact every FAEI packets.
    FAEI works best when retrieving a small percentage of data from a Database table. When a large percentage of data is needed, consider getting data out of the DB table without FAEI implementation, and then do additional filtration in your application
    Reward points if found helpfull...
    Cheers,
    Chandra Sekhar.

  • What is the usage of for all entries ?

    What is the Usage of read table  after using for all entries ?
    In the following example what exactly it is doing ?
      Usage of 'for all entries' in Select Statement
    FORM data_retrieval.
      DATA: ld_color(1) TYPE c.
      DATA: BEGIN OF T_VBAP OCCURS 0,
            VBELN  LIKE VBAP-VBELN,
            MATNR  LIKE VBAP-MATNR,
            POSNR  LIKE VBAP-POSNR,
            END OF T_VBAP.
      DATA: BEGIN OF T_VBFA OCCURS 0,
            VBELV  LIKE VBFA-VBELV,
            VBELN  LIKE VBFA-VBELN,
            VBTYP_N  LIKE VBFA-VBTYP_N,
            END OF T_VBFA.
      DATA: BEGIN OF T_VBAK OCCURS 0,
            VBELN  LIKE VBAK-VBELN,
            IHREZ  LIKE VBAK-IHREZ,
            END OF T_VBAK.
      DATA: BEGIN OF T_KNA1 OCCURS 0,
            KUNNR  LIKE KNA1-KUNNR,
            NAME1  LIKE KNA1-NAME1,
            END OF T_KNA1.
       DATA: BEGIN OF T_MAKT OCCURS 0,
            MATNR  LIKE MAKT-MATNR,
            MAKTX  LIKE MAKT-MAKTX,
            END OF T_MAKT.
      SELECT likpvbeln likplifex likpbldat likpwadat likpwadat_ist likpkodat likp~lfart
             likpkunnr likpvstel lipsposnv lipslfimg lipsvrkme lipslgmng lips~meins
             lipswerks lipslgort lipscharg lipsvbelv lipsposnr lipsmatnr
             lipsvbeln LIPSVGBEL LIPSVGPOS vbupkosta vbupwbsta vbupposnr vbup~vbeln
              VBAKIHREZ VBAKVBELN VBAP~VBELN
         INTO CORRESPONDING FIELDS OF TABLE  it_itab
        FROM ( likp
               INNER JOIN lips
               ON  lipsvbeln = likpvbeln
               INNER JOIN vbup
               ON  vbupposnr = lipsposnr
               and VBUPVBELN = LIPSVBELN )
              left outer join VBAK
              on  VBAKVBELN = LIPSVGBEL
              inner join VBAP
              on  VBAPVBELN = VBAKVBELN )
             WHERE likp~vbeln IN so_vbeln
               AND likp~lifex IN so_lifex
               AND likp~lfart IN so_lfart
               AND likp~kunnr IN so_kunnr
               AND likp~vstel IN so_vstel
               AND likp~bldat IN so_bldat
               AND likp~wadat_ist IN so_wadat
               AND vbup~kosta IN so_kosta
               AND vbup~wbsta IN so_wbsta
               AND LIPS~LFIMG NE 0.
      SELECT VBELN IHREZ INTO TABLE T_VBAK
      FROM VBAK
      FOR ALL ENTRIES IN  IT_ITAB
      WHERE VBELN = IT_ITAB-VGBEL.
    APPEND T_VBAK.
    ENDSELECT.
      SELECT VBELN MATNR POSNR INTO TABLE T_VBAP
      FROM VBAP
      FOR ALL ENTRIES IN  IT_ITAB
      WHERE VBELN = IT_ITAB-VGBEL AND
            MATNR = IT_ITAB-MATNR AND
            POSNR = IT_ITAB-VGPOS.
    APPEND T_VBAP.
    ENDSELECT.
      SELECT VBELV VBELN VBTYP_N INTO TABLE T_VBFA
      FROM VBFA
      FOR ALL ENTRIES IN  IT_ITAB
      WHERE VBELV = IT_ITAB-VBELN AND
            VBTYP_N = 'M' .
      SELECT KUNNR NAME1 INTO TABLE T_KNA1
      FROM KNA1
      FOR ALL ENTRIES IN IT_ITAB
      WHERE KUNNR = IT_ITAB-KUNNR.
    APPEND T_KNA1.
    ENDSELECT.
      SELECT MATNR MAKTX INTO TABLE T_MAKT
      FROM MAKT
      FOR ALL ENTRIES IN IT_ITAB
      WHERE MATNR = IT_ITAB-MATNR.
    APPEND T_MAKT.
    ENDSELECT.
    *Populate field with color attributes
      LOOP AT it_itab INTO wa_ITAB.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
    i.e. wa_ekko-line_color = 'C410'
        REFRESH color.
        colourize 'VBELN' 0. " .
        WA_ITAB-farbe = color[].
        ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
        IF ld_color = 3. "8
          ld_color = 1.
        ENDIF.
        CONCATENATE 'C' ld_color '10' INTO wa_ITAB-line_color.
        WA_ITAB-NAME1 = ''.
        WA_ITAB-MAKTX = ''.
        WA_ITAB-IHREZ = ''.
        WA_ITAB-VBELV = ''.
        READ TABLE T_KNA1 WITH KEY KUNNR = WA_ITAB-KUNNR.
        IF SY-SUBRC = 0.
           WA_ITAB-NAME1 = T_KNA1-NAME1.
        ENDIF.
        READ TABLE T_MAKT WITH KEY MATNR = WA_ITAB-MATNR.
        IF SY-SUBRC = 0.
        WA_ITAB-MAKTX = T_MAKT-MAKTX.
        ENDIF.
        READ TABLE T_VBAK WITH KEY VBELN = WA_ITAB-VGBEL.
        IF SY-SUBRC = 0.
        WA_ITAB-IHREZ = T_VBAK-IHREZ.
        ENDIF.
        READ TABLE T_VBFA WITH KEY VBELV = WA_ITAB-VBELN.
        IF SY-SUBRC = 0.
        WA_ITAB-VBELVA = T_VBFA-VBELN.
        ENDIF.
       READ TABLE T_VBAP WITH KEY VBELN = WA_ITAB-VGBEL
                                  POSNR = WA_ITAB-VGPOS
                                  MATNR = WA_ITAB-MATNR.
       IF SY-SUBRC = 0.
       WA_ITAB-IHREZ = T_VBAK-IHREZ.
       ENDIF.
    wa_ekko-line_color = 'C410'.
        MODIFY it_itab FROM wa_itab.
      ENDLOOP.
    ENDFORM. " data_retrieval

    hi Jyotirmoy,
    The explanation below can give u an idea of wat is going in ur code..
    Use of FOR ALL Entries
    Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
    Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
    If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
    If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
    Not Recommended
                Loop at int_cntry.
                 Select single * from zfligh into int_fligh
                 where cntry = int_cntry-cntry.
                 Append int_fligh.
                Endloop.
    Recommended
                Select * from zfligh appending table int_fligh
                For all entries in int_cntry
                Where cntry = int_cntry-cntry.
    Thankyou,
    Regards.

  • Selecting single value using for all entries.

    Hi Experts,
    I want to know that is it possible to fetch only the first record for a particular condition while using for all entries.
    For ex:
    Suppose i got 10 different vbeln from vbak table into my internal table it_vbak. For a particular vbeln there can be multiple records in vbap table.
    Now i need to fetch only the first record which is getting from vbap table for different vbeln while using 'for all entries in it_vbak where vbeln = it_vbak-vbeln'. Is it possible?
    Thanks in Advance
    Be$t!N
    Moderator message - Moved to the correct forum
    Edited by: Rob Burbank on Nov 17, 2009 9:38 AM

    Hi Rob Burbank,
    Thanks..
    You are correct.. If that is the scenario in their company... Again it depends on the configuration and business process.. But it's possible that they may need to delete first on any line item after creation of sale order..
    In that case below solution will work..
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT * FROM VBAP
    INTO TABLE IT_VBAP
    for all entries in it_vbak
    where vbeln = it_vbak-vbeln.
    ENDIF.
    SORT IT_VBAP BY VBELN POSNR.
    LOOP AT IT_VBAK INTO WA_VBAK.
    READ TABLE IT_VBAP INTO WA_VBAP WITH KEY VBELN = WA_VBAK-VBELN.
    IF SY-SUBRC = 0.
    APPEND WA_VBAP TO IT_VBAP2. " Another Internal table which stores only first record
    ENDIF.
    CLEAR : WA_VBAP.
    ENDLOOP.
    OR
    IT_VBAP3[] = IT_VBAP[].
    SORT IT_VBAP3 BY VBELN POSNR.
    DELETE ADJACENT DUPLICATES FROM IT_VBAP3 COMPARING VBELN.
    Now Table IT_VBAP2 and IT_VBAP3 will be having only first line items for all sales orders..
    Do some little changes in the code as per your requirement.
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

Maybe you are looking for

  • Linking to Specific Page in Attached PDF File

    I'm working with a main PDF file as well as an attached one. I'd like to create multiple links in my main file, with each one linking to a different page in the attached file. How could I go about doing this?

  • Tooltip

    Hello I'm working on the translation in french of the UI. I have problem with tooltip. In the picture below, you can see that the settings of steps are translated in french. The tooltip is still is english. I've searched the ini configuration files b

  • Problem with ODynaset::Close()

    Hi, I'm working with OO4O v. 8.1.7.3.11 and MS VC++ 6.0. My application opens multiple dynasets. When the database access is no longer needed it closes the dynasets using the ODynaset::Close method. But when I take a look at my temporary directory I

  • Rebuild a Photos Library?

    Hello everyone, I'm running Photos 1.0 on OS X 10.10.3, and I'm wondering if there's a way to rebuild a Photos library? I used to be able to do this in Aperture ... Mike

  • HPX3000 P2 Import Question

    We have a client wanting to shoot on the new Panasonic HPX3000 and have us output their material to HDCam through the AJA Kona 3 card. We've had lots of experience doing this with P2 cards but I'm wondering if this new camera, with the new AVC codec