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

Similar Messages

  • How can i write the bellow code using field symbols

    data : it_mara type table of mara.
    select * from mara
                into it_mara.
    delete it_mara where matnr = '100-100'
                             and meins = 'KG'.
    if i do the same by using field symbols
    i am getting data into <it_mara>
    but
    delete <it_mara>  where matnr = '100-100'
                               and    meins = 'KG'.
    is showing syntax error
    how to correct the error ?

    I think, DELETE does not allows to dynamically define the logical expression for the WHERE clausule.
    Have you tried by filtering data in SELECT statement??
    Something like:
    if dataBase = 'MARA'.
    append 'MATNR <> '100-100'' to Itab_Where[].
    append 'AND MEINS <> 'KG'' to Itab_Where[].
    endIf.
    select * from (dataBase) where (Itab_Where) into table <my_table>.
    this is possible, but I don't know if this fits your requirements.

  • How can I write the analogous code to the logic:iterate tag functionality

    Hai This is Rayalu .And I am very new to the Java World. I have a doubt?.How can I write the analogous code to the<logic:iterate> tag functionality using the JSP Tag Libraries . Pleae Send me some examples .

    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

  • Hi, how can I keep the same zoom level for all the pages I view in Safari and even when I close and open it.  Indeed with a 27 inch Imac I have a lot of space, most of the websites are built for smaller resolutions  and my sight is dropping !   Thx

    Hi, how can I keep the same zoom level for all the pages I view in Safari and even when I close and open it.  Indeed with a 27 inch Imac I have a lot of space, most of the websites are built for smaller resolutions  and my sight is dropping !   Thx

    Hi, how can I keep the same zoom level for all the pages I view in Safari and even when I close and open it.  Indeed with a 27 inch Imac I have a lot of space, most of the websites are built for smaller resolutions  and my sight is dropping !   Thx

  • Can a JOIN statement be rewritten using FOR ALL ENTRIES in any case ?

    I had a SELECT statement, like:
        select p~key1 t~col3 t~col4 p~col2 p~col3
          into table itab1
          from ( table1 as p left outer join table2 as t
                  on p~key1 = t~key1 and t~col2 = someValue ).
    Among which, table1 and table2 are fully buffered.
    Code Inspector suggests that this statement should be, e.g., rewritten using FOR ALL ENTRIES.
    Since FOR ALL ENTRIES is only possible for WHERE conditions of the SELECT statement, which means the internal table right after it is not available for the RESULT clause of the SELECT statement, can the above statement be rewritten? If yes, how?
    Thanks!

    hi ,
    select pkey1 tcol3 tcol4 pcol2 p~col3
          into table itab1
          from ( table1 as p left outer join table2 as t
                  on pkey1 = tkey1 and t~col2 = someValue ).
    <i>look below code</i>
    select * from  table2  into table int_tab2 where col2 = someValue.
    select key1 col2 col3  into table  int_tab1
    FOR ALL ENTRIES IN int_tab2
    WHERE key = int_tab2-key1.
    then use read statements for manipulations
    rgds
    Anver

  • How can I set the default home page for all new users in Firefox 4

    I'm trying to deploy FF 4.0rc1 in a corporate environment but I can't find a way to set the default home page or any other settings for that matter.
    Is there a way to set the default home page for all new users and lock it so that the users can't change home page?
    Best regards
    Jonas

    In Firefox 4 the template folder for new profiles (C:\Program Files\Mozilla Firefox\defaults\profile\
    ) doesn't exist. You can create that \defaults\profile\ folder and place a file user.js in it with the prefs that you want to initialize.
    See:
    *http://www-archive.mozilla.org/catalog/end-user/customizing/briefprefs.html
    You can also use a mozilla.cfg file to set the default value for prefs.<br />
    See: http://kb.mozillazine.org/Locking_preferences
    defaultPref(); // set new default value
    pref(); // set pref, but allow changes
    lockPref(); // lock pref, disallow changes

  • How can i change the number im using for FaceTime?

    Everytime i try to call someone on facetime it comes out as another number using the same apple id, how can i change that?

    Hello Lazboy1,
    The following article details both the processes for unlinking a phone number and correcting the lack of a phone number attached.
    iOS 6 and OS X Mountain Lion: Link your phone number and Apple ID for use with FaceTime and iMessage
    http://support.apple.com/kb/HT5538
    Cheers,
    Allen

  • How can I change the email I use for my Apple ID

    I deleted my email account because it got hacked and I want to change my Apple ID email

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico, Spanish is my native tongue. I do not speak English very well, however, I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    Manage your Apple ID -
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/

  • 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

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

  • 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

  • Hi Prerequestion of using for all entries

    Hi ,
       What is the prerequestion of using For All Entries. Could you answer to me.
    Thanks & Regards
    Raghava

    Hi,
    1.First check whether the internal table which to be used in FOR ALL ENTRIES is initial or not.IF it is not initial ,then use the table.Otherwise it will go for an infinite loop.
    2.Sort the internal table.
    Go through this
    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.
    Regards,
    Padmam.

  • How can I use a SCH-LC11 device in CHINA which bought from ebay. I am not Verizon customer but I prefer to using your 4G LTE Router . How can I get the unlock code? The device may have a bad ESN but I only use it in CHINA. Kindly looking forward your repl

    How can I use a SCH-LC11 device in CHINA which bought from ebay. I am not Verizon customer but I prefer to using your 4G LTE Router . How can I get the unlock code? The device may have a bad ESN but I only use it in CHINA. Kindly looking forward your reply. Thanks!

    It's good to read Antoniad's post.  It reassures me that I can use my new iPad as an international communication device which is the reason I purchased the thing.  However, I called Verizon today (my provider of cellular data) who told me that I can't just pop in a SIM card as you suggested.  He also said that he was from the "Pre-Pay" division of Verizon and he was certain that I couldn't do what I planned to do.  I was extremely disappointed as I had called Apple prior to buying the iPad and I read the algorhythm on the website for choosing an iPad before purchasing.  Those sources were quite specific and the information seemed clear.  I would be able to use my iPad to communicate through cellular connections while traveling on the road, literally, abroad.  I was told that I could pop in a data card wherever I was, just as you indicated in your message above, and voila I was good to go.  The Verizon rep definitively rained on that parade, but said that I might be able to do this if I have a "Post-Pay" account, a different area of Verizon.  I haven't had the chance to talk to this division yet, so I looked to Apple's Support for answers.  Maybe I will find out that I can use my iPad as an international communication device while traveling on the road afterall, however, it appears I may need a different type of account (Post-Pay), something I was never warned about. Can I switch to this kind of account?  I don't know.  I have to find out.  If you have any information about this issue, it would be good to share since I strongly suspect there are others who bought the iPad for the same purpose that I have.

  • How can we write the code for opening the command prompt and closing the

    how can we write the code in java for opening the command prompt and closing the cmd prompt from eclipse (cmd prompt should close when click on the turminate button in eclipse)

    rakeshsikha wrote:
    how can we write the code for opening the command prompt and closing theBy typing in Eclipse (which you seemingly have)?

  • How can i write the floats value in Unitronics vision230 plc using modbus Ethernet

           How can i write the Float value in unitronics Vision230 PLC usinsg modbus ethernet (MB Ethernet Master Query.vi) I  read and write  the 32 bit register,  for e.g i want to write the 23.45 value on 2nd add. of MF. And MF register is 32 bit register. I  read and write  the 32 bit register.
    Narendra.
    Solved!
    Go to Solution.

     Thanks Amit for your solution but i can not use the string to write the value because  MB Ethernet master Query.vi only accepet the integer value its not take string values or any other i.e floats values etc.....otherwise i have  no problem to write or read the 32 bit register values , only problem is that the MB Ethernet master Query.vi only accept the integer value there4 how can write the float value.
    Narendra
    Message Edited by Artemistech on 01-30-2009 11:06 PM

Maybe you are looking for