Performing a Select Using 'IN' with an Internal Table

Hello
I defined an internal table called tempbeh. I am able to fill the table with values.
However, I do get an error with the second select. There is a problem with the code snippet
AND   beh_unique_id NOT IN tempbeh..
I am being told that the row structure of the table tempbeh is not correct.
I do NOT get any errors when I remove the code
AND   beh_unique_id NOT IN tempbeh.
Any ideas........    I'd do a prayer if somebody could help, and make me understand why I get an error in the first place.
Thank you very much....Robert
Here is the code:
DATA: BEGIN OF tempbeh OCCURS 1,
        beh like zwopti_bv_out-BEH_UNIQUE_ID,
      END OF tempbeh.
SELECT beh_unique_id FROM zwopti_bv_out
      INTO tempbeh
      WHERE udate IN s_dat.
      APPEND tempbeh.
    ENDSELECT.
SELECT
    zw~beh_unique_id zw~udate
    zw~utime zw~longitude zw~latitude
    zw~process zw~state zw~hint_nr
    zw~hint_txt zw~anl_unique_id
    zw~stp_unique_id zw~ordernr
    zw~order_laufnr zw~aedat
    zw~zztransp_nr
    zw~adrkey z5~tournr
    z10~abfallart
    z5~rmnr
    zwopti_eapos_in~sequence
    equi~zzgroesse
    zws09~behkennung
    zws09~beschreib
    FROM zwopti_bv_out AS zw
    Inner JOIN zwt05 AS z5 ON zw~ordernr = z5~tourid
    LEFT OUTER JOIN zwt10 AS z10
    ON zw~ordernr = z10~tourid AND zw~order_laufnr = z10~tourelemnr
    LEFT OUTER JOIN zwopti_eapos_in
    ON zw~quell_key = zwopti_eapos_in~quell_key
    INNER JOIN equi ON zw~beh_unique_id = equi~equnr
    INNER JOIN zws09 ON equi~zzfatyp = zws09~behkennung
      INTO  TABLE lt_bv_out
      WHERE beh_unique_id     IN s_sernr
      AND   equi~zzgroesse    IN s_behgr
      AND   zw~zztransp_nr    IN s_tid
      AND   stp_unique_id     IN s_stpl
      AND   zw~adrkey         IN x_adrkey
      AND   z5~tournr         IN s_tour
      AND   zw~hint_nr        IN s_hint
      AND   zws09~behkennung  IN s_behart
      AND   beh_unique_id NOT IN tempbeh.

Hi,
Try like this....
ranges : r_tempbeh for <tablename>-beh_unique_id.
r_tempbeh-sign = 'I'.
r_tempbeh-option = 'EQ'.
SELECT beh_unique_id FROM zwopti_bv_out
      INTO tempbeh
      WHERE udate IN s_dat.
      APPEND tempbeh.
          r_tempbeh-LOW = beh_unique_id .
  APPEND R_TEMPBEH.
    ENDSELECT.
SELECT
    zwbeh_unique_id zwudate
    zwutime zwlongitude zw~latitude
    zwprocess zwstate zw~hint_nr
    zwhint_txt zwanl_unique_id
    zwstp_unique_id zwordernr
    zworder_laufnr zwaedat
    zw~zztransp_nr
    zwadrkey z5tournr
    z10~abfallart
    z5~rmnr
    zwopti_eapos_in~sequence
    equi~zzgroesse
    zws09~behkennung
    zws09~beschreib
    FROM zwopti_bv_out AS zw
    Inner JOIN zwt05 AS z5 ON zwordernr = z5tourid
    LEFT OUTER JOIN zwt10 AS z10
    ON zwordernr = z10tourid AND zworder_laufnr = z10tourelemnr
    LEFT OUTER JOIN zwopti_eapos_in
    ON zwquell_key = zwopti_eapos_inquell_key
    INNER JOIN equi ON zwbeh_unique_id = equiequnr
    INNER JOIN zws09 ON equizzfatyp = zws09behkennung
      INTO  TABLE lt_bv_out
      WHERE beh_unique_id     IN s_sernr
      AND   equi~zzgroesse    IN s_behgr
      AND   zw~zztransp_nr    IN s_tid
      AND   stp_unique_id     IN s_stpl
      AND   zw~adrkey         IN x_adrkey
      AND   z5~tournr         IN s_tour
      AND   zw~hint_nr        IN s_hint
      AND   zws09~behkennung  IN s_behart.
DELETE LV_BV_OUT WHERE beh_unique_id    NOT IN R_TEMPBEH.
Regards,
Nagaraj

Similar Messages

  • Using where condition with dynamic internal table

    Hi Friends.
    How to use where condition with dynamic internal table ?
    Regards,
    Amit Raut

    Hai Amit
    REPORT  ZDYNAMIC_SELECT                         .
    TABLES: VBAK.
    DATA: CONDITION TYPE STRING.
    DATA: BEGIN OF ITAB OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    END OF ITAB.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
    CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
    INTO CONDITION SEPARATED BY SPACE.
    SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
    WHERE (CONDITION).
    LOOP AT ITAB.
    WRITE 'hello'.
    ENDLOOP.
    Thanks & Regards
    Sreenivasulu P

  • Can we perform Join operation using SQLCall with Datatabae Query

    Hi,
    I am working on Toplink SQLCall query. I am performing join operation but, it is giving error.
    so please, any can tell me . we can perform join operation using SQLCall with Database Query
    Thanking You.

    You can use joining with SQLCall queries in TopLink, provided your SQL returns all of the required fields.
    What is the query you are executing and what error are you getting?

  • ABAP to XML with several internal tables

    hi,
    i have to make a XML file with this structure :
    <Order>
      <OrderHeader>
          <i>...[fields of header]...</i>
      </OrderHeader>
      <OrderItem>
          <i>...[fields of item 10]...</i>
      </OrderItem>
      <OrderItem>
          <i>...[fields of item n]...</i>
      </OrderItem>
    </Order> 
    and that for several orders...
    I don't know anything about XML, XLST and since 1 day just start to read doc, tutorial.. and i can't say i'm understanding everythings..
    so, in a first step, i have tried to export several Order headers :
    I have done a XSLT (thanks to another topic/replies in the forum) and call it with CALL TRANSFORMATION and it works good...
    now,and here i need a little help, i would like to know :
    1-is it possible to work with 2 internal tables and in this case, how to make XLST looping all item for each header?
    2-or should i use only one internal table with deep structure?
    Regards,
    Christophe
    The XSLT
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sapxsl="http://www.sap.com/sapxsl" version="1.0">
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <Order>
          <xsl:for-each select="//item">
            <OrderHeader>
              <OrderNo>
                <xsl:value-of select="AUFNR"/>
              </NoOT>
            </OrderHeader>
          </xsl:for-each>
        </Order>
      </xsl:template>
    </xsl:transform>

    Hi,
    Here is the sample code.
    * Databases
    TABLES:
      makt,                                "Mat description
      marc,                                "Material / plant
      t001w,                               "plant name
      bhdgd.                               "Batch heading
    * Internal tables
    DATA:
      BEGIN OF gt_marc OCCURS 0,
        werks LIKE marc-werks,
        matnr LIKE marc-matnr,
      END OF gt_marc,
    * Table to be downloaded as xml. Each line stores start and end tags
    * and the value
      BEGIN OF gt_xml OCCURS 0,
        line(120),
      END OF gt_xml,
      g_maktx(120).
    * User-input
    SELECT-OPTIONS:
      s_werks FOR marc-werks,
      s_matnr FOR marc-matnr.
    START-OF-SELECTION.
    * Extract all required data
      PERFORM main_processing.
    END-OF-SELECTION.
      SORT gt_marc BY werks matnr.
      LOOP AT gt_marc.
        AT FIRST.                          "First tag must be root
          CLEAR gt_xml.
          gt_xml-line = '<LOCATIONS>'.
          APPEND gt_xml.
          CLEAR gt_xml.
        ENDAT.
        AT NEW werks.                      "At new plant
          PERFORM read_plant.
          FORMAT COLOR 4 ON.
          SKIP 1.
          WRITE :/ gt_marc-werks, t001w-name1.
          FORMAT COLOR 4 OFF.
          CLEAR gt_xml.
          gt_xml-line = ' <PLANT>'.
          APPEND gt_xml.
          CLEAR gt_xml.
          CONCATENATE ' <NUMBER>' gt_marc-werks '</NUMBER>'
          INTO gt_xml-line.
          APPEND gt_xml.
          CLEAR gt_xml.
          CONCATENATE ' <NAME>' t001w-name1 '</NAME>' INTO gt_xml-line.
          APPEND gt_xml.
          CLEAR gt_xml.
          gt_xml-line = ' </PLANT>'.
          APPEND gt_xml.
          CLEAR gt_xml.
        ENDAT.
        PERFORM read_description.
        CLEAR gt_xml.
        gt_xml-line = ' <MATERIAL>'.
        APPEND gt_xml.
        CLEAR gt_xml.
        CONCATENATE ' <NAME>' g_maktx '</NAME>'
        INTO gt_xml-line.
        APPEND gt_xml.
        CLEAR gt_xml.
        CONCATENATE ' <NUMBER>' gt_marc-matnr '</NUMBER>'
        INTO gt_xml-line.
        APPEND gt_xml.
        CLEAR gt_xml.
        gt_xml-line = ' </MATERIAL>'.
        APPEND gt_xml.
        CLEAR gt_xml.
    * display data
        FORMAT COLOR 2 ON.
        WRITE :/ gt_marc-matnr, makt-maktx.
        FORMAT COLOR 2 OFF.
      ENDLOOP.
    * The last tag must be the root closing tag --*
      gt_xml-line = '</LOCATIONS>'.
      APPEND gt_xml.
      CLEAR gt_xml.
      CALL FUNCTION 'DOWNLOAD'
           EXPORTING
                filename = 'C:PLANT1.XML'
                filetype = 'ASC'
           TABLES
                data_tab = gt_xml.
    TOP-OF-PAGE.
      MOVE sy-title TO bhdgd-line1.
      MOVE sy-repid TO bhdgd-repid.
      MOVE sy-uname TO bhdgd-uname.
      MOVE sy-datum TO bhdgd-datum.
      MOVE '0' TO bhdgd-inifl.
      MOVE '132' TO bhdgd-lines.
      FORMAT INTENSIFIED ON COLOR COL_HEADING.
      PERFORM batch-heading(rsbtchh0).     "report header
    *  Form READ_PLANT
    FORM read_plant.
    * Get plant name
      CLEAR t001w.
      SELECT SINGLE name1
        INTO t001w-name1
        FROM t001w
       WHERE werks EQ gt_marc-werks.
    ENDFORM.                               " READ_PLANT
    *  Form MAIN_PROCESSING
    FORM main_processing.
    * Material and plant basic data
      SELECT werks matnr
        INTO TABLE gt_marc
        FROM marc
       WHERE werks IN s_werks
         AND matnr IN s_matnr.
    ENDFORM.                               " MAIN_PROCESSING
    *  Form READ_DESCRIPTION
    FORM read_description.
    * Material name
      CLEAR g_maktx.
      SELECT SINGLE maktx
        INTO g_maktx
        FROM makt
       WHERE matnr EQ gt_marc-matnr
         AND spras EQ 'E'.
    * Replace special character
      DO.
        REPLACE '&' WITH '*ù%;' INTO g_maktx.
        IF NOT sy-subrc IS INITIAL. EXIT.ENDIF.
      ENDDO.
      DO.
        REPLACE '*ù%;' WITH '&amp;' INTO g_maktx.
        IF NOT sy-subrc IS INITIAL. EXIT.ENDIF.
      ENDDO.
      DO.
        REPLACE '/' WITH '&#47;' INTO g_maktx.
        IF NOT sy-subrc IS INITIAL. EXIT.ENDIF.
      ENDDO.
    ENDFORM.                               " READ_DESCRIPTION
    Hope this helps.If so,kindly reward points.

  • ALV reprot With four internal tables

    Hi all,
    Could any one please tell what is function module we have to use for displaying four internal tables in a single ALV REPORT.
    Thanks & regards
    Vardhan

    This is the code for displaying ALV using containers.. u need to create 4 containers in one screen and need to display data...
    I would suggest you to get all the data into one internal table and display.. for more clarity u can give diff colors for diff table data using field catalog..
                                        *& Report  ZTRPSD110                                                   *
                                        * TITLE: Statement of Export Report for Tata Tetley                    *
                                        * PURPOSE:Statement of Export Report for Tata Tetley                   *
                                        * A. Start-of-selection:                                               *
                                        * 1. In get_billing_data using the selection screen parameters get the *
                                        *     billing data from billing header(VBAK) and Item (VBAP)           *
                                        * 2.  Get the SHIP-TO partner data from VBPA using Customer number as  *
                                        *     one condition and store in it_vbpa_sh
                                        * 9.  Popultae the ALV display table
                                        * B. End-of-selection:
                                        *    Call screen 9000 and display data in ALV
                                        REPORT  ztrps110  MESSAGE-ID zttl  LINE-SIZE 130.
                                                                                    TABLES: vbrk.
                                                                                    * CONSTANTS
                                        CONSTANTS :
                                        c_x(1)        TYPE c VALUE 'X',
                                        c_zxto        TYPE vbak-auart VALUE 'ZXTO',
                                        c_e           TYPE spras VALUE 'E',
                                        c_000000      TYPE posnr VALUE '000000',
                                        c_ship_to     TYPE parvw VALUE 'WE'.      "Ship To Party
                                                                                    * Table Types
                                        TYPES: BEGIN OF ty_vbrk_vbrp,
                                        vbeln TYPE vbrk-vbeln,    "Billing doc
                                        posnr TYPE vbrp-posnr,    "Billing item
                                        aubel TYPE vbrp-aubel,    "Sales order
                                        waerk TYPE vbrk-waerk,    "Doc currency
                                        mvgr1 TYPE vbrp-mvgr1,    "Material group 1
                                        mvgr3 TYPE vbrp-mvgr3,    "Material group 3
                                        mvgr4 TYPE vbrp-mvgr4,    "Material group 4
                                        matnr TYPE vbrp-matnr,    "Material no
                                        ntgew TYPE vbrp-ntgew,    "Net wt
                                        gewei TYPE vbrp-gewei,    "Wt unit
                                        kzwi1 TYPE vbrp-kzwi1,                             "Subtotal 1
                                        kursk TYPE vbrp-kursk,    "Exchange rate
                                        END   OF ty_vbrk_vbrp.
                                                                                    TYPES: BEGIN OF ty_data,
                                        land1 TYPE vbpa-land1,
                                        landx TYPE t005t-landx,
                                        mvgr3 TYPE vbrp-mvgr3,
                                        mvgr4 TYPE vbrp-mvgr4,
                                        bezei3 TYPE tvm3t-bezei,
                                        bezei4 TYPE tvm4t-bezei,
                                        ntgew_tea_bag TYPE vbrp-ntgew,
                                        ntgew_pkt_tea TYPE vbrp-ntgew,
                                        ntgew_bulk_tea TYPE vbrp-ntgew,
                                        kzwi1_tea_bag TYPE vbrp-kzwi1,    "Subtotal 1 Tea Bag
                                        kzwi1_pkt_tea TYPE vbrp-kzwi1,    "Subtotal 1 Pkt Tea
                                        kzwi1_bulk_tea TYPE vbrp-kzwi1,   "Subtotal 1 Bulk Tea
                                        ntgew_tot TYPE vbrp-ntgew,
                                        kzwi1_tot TYPE vbrp-kzwi1,
                                        line_color(4) TYPE c,  "For line color
                                        END OF ty_data.
                                        TYPES: BEGIN OF ty_vbpa,
                                        vbeln TYPE vbpa-vbeln,
                                        land1 TYPE vbpa-land1,
                                        END OF ty_vbpa.
                                        TYPES: BEGIN OF ty_t005t,
                                        land1 TYPE t005t-land1,
                                        landx TYPE t005t-landx,
                                        END OF ty_t005t.
                                        TYPES: BEGIN OF ty_tvm3t,
                                        mvgr3 TYPE tvm3-mvgr3,
                                        bezei TYPE tvm3t-bezei,
                                        END OF ty_tvm3t.
                                        TYPES: BEGIN OF ty_tvm4t,
                                        mvgr4 TYPE tvm4-mvgr4,
                                        bezei TYPE tvm4t-bezei,
                                        END OF ty_tvm4t.
                                                                                    DATA: it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp,
                                        wa_vbrk_vbrp TYPE ty_vbrk_vbrp,
                                        it_vbpa TYPE STANDARD TABLE OF ty_vbpa,
                                        wa_vbpa TYPE ty_vbpa,
                                        it_data TYPE STANDARD TABLE OF ty_data,
                                        wa_data TYPE ty_data,
                                        it_t005t TYPE STANDARD TABLE OF ty_t005t,
                                        wa_t005t TYPE ty_t005t,
                                        it_tvm3t TYPE STANDARD TABLE OF ty_tvm3t,
                                        wa_tvm3t TYPE ty_tvm3t,
                                        it_tvm4t TYPE STANDARD TABLE OF ty_tvm4t,
                                        wa_tvm4t TYPE ty_tvm4t.
                                                                                    * Global data for grand total
                                        DATA:
                                        w_tot_ntgew_tea_bag TYPE vbrp-ntgew,
                                        w_tot_ntgew_pkt_tea TYPE vbrp-ntgew,
                                        w_tot_ntgew_bulk_tea TYPE vbrp-ntgew,
                                        w_tot_ntgew_tot TYPE vbrp-ntgew,
                                        w_tot_kzwi1_tea_bag TYPE vbrp-kzwi1,
                                        w_tot_kzwi1_pkt_tea TYPE vbrp-kzwi1,
                                        w_tot_kzwi1_bulk_tea TYPE vbrp-kzwi1,
                                        w_tot_kzwi1_tot TYPE vbrp-kzwi1.
                                                                                    * Global data definitions for ALV
                                        DATA :
                                        * ALV Grid container
                                        w_alv_container TYPE REF TO cl_gui_custom_container,
                                        * ALV Grid
                                        w_alv_grid      TYPE REF TO cl_gui_alv_grid,
                                        w_layo          TYPE        lvc_s_layo,     "For layout
                                        wt_fieldcat     TYPE        lvc_t_fcat,     "For field catalog
                                        okcode          TYPE         okcode,        "OK Code
                                        w_to(2)         TYPE         c,
                                        w_title         TYPE        string.
                                        *-------------- START OF SELECTION SCREEN ----------------------------*
                                        SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
                                        * Billing Date
                                        SELECT-OPTIONS: s_fkdat FOR vbrk-fkdat MEMORY ID vf OBLIGATORY NO-EXTENSION.
                                        SELECTION-SCREEN:SKIP 1.
                                        SELECTION-SCREEN: END OF BLOCK b1.
                                        *-------------- END OF SELECTION SCREEN ------------------------------*
                                                                                    *-------------   EVENT START-OF-SELECTION  -------------------------------*
                                        START-OF-SELECTION.
                                                                                    * Get billing data from Delivery header(VBRK) and item (VBRP)
                                        PERFORM get_billing_data.
                                        * Get ship-to country
                                        PERFORM get_ship_to_data.
                                        * Get material group description 3
                                        PERFORM get_material_group_3.
                                        * Get material group description 4
                                        PERFORM get_material_group_4.
                                        * Form the ALV Grid title
                                        PERFORM form_title.
                                        * Process data
                                        PERFORM process_data.
                                        * Populate text descriptions
                                        PERFORM populate_description.
                                                                                    *-------------   EVENT END-OF-SELECTION  -------------------------------*
                                        END-OF-SELECTION.
                                        * Set the text to when date high is there
                                        IF NOT s_fkdat-high IS INITIAL.
                                        w_to = 'to'(c16).
                                        ENDIF.
                                        * Call the scren 9000 for ALV Display
                                        CALL SCREEN 9000.
                                        *&      Form  get_billing_data
                                        * Get billing data from Delivery header(VBRK) and item (VBRP)
                                        * & store in internal table it_vbrk_vbrp
                                        FORM get_billing_data .
                                        REFRESH: it_vbrk_vbrp.
                                                                                    * Select Billing data by joining VBRK & VBRP and store in it_vbrk_vbrp
                                        SELECT a~vbeln
                                        b~posnr
                                        b~aubel
                                        a~waerk
                                        b~mvgr1
                                        b~mvgr3
                                        b~mvgr4
                                        b~matnr
                                        b~ntgew
                                        b~gewei
                                        b~kzwi1
                                        b~kursk
                                        FROM vbrk AS a INNER JOIN vbrp AS b
                                        ON a~vbeln = b~vbeln
                                        INTO TABLE it_vbrk_vbrp
                                        WHERE a~fkdat IN s_fkdat
                                        * Consider only non-deleted document
                                        AND fksto = space
                                        * Billing doc type should be ZXTB
                                        AND fkart = 'ZXTB'
                                        AND pstyv = c_zxto.
                                        IF sy-subrc <> 0.
                                        MESSAGE i999(zttl) WITH 'No data is there'(m06).
                                        LEAVE LIST-PROCESSING.
                                        ENDIF.
                                        ENDFORM.                    " get_billing_data
                                        *&      Form  get_ship_to_data
                                        * Get Ship-To party data
                                        FORM get_ship_to_data .
                                        DATA: l_it_vbpa TYPE STANDARD TABLE OF ty_vbpa.
                                        REFRESH: it_vbpa, it_t005t.
                                        IF NOT it_vbrk_vbrp[] IS INITIAL.
                                        SELECT vbeln
                                        land1
                                        FROM vbpa
                                        INTO TABLE it_vbpa
                                        FOR ALL ENTRIES IN it_vbrk_vbrp
                                        WHERE vbeln = it_vbrk_vbrp-aubel
                                        AND posnr = c_000000
                                        AND parvw = c_ship_to.
                                        IF sy-subrc <> 0.
                                        MESSAGE i999(zttl) WITH 'Exporter country not maintained'(m02).
                                        LEAVE LIST-PROCESSING.
                                        ELSE.
                                        SORT it_vbpa BY vbeln.
                                        * Create an unique and sorted driver table
                                        l_it_vbpa[] = it_vbpa[].
                                        SORT l_it_vbpa BY land1.
                                        DELETE ADJACENT DUPLICATES FROM l_it_vbpa COMPARING land1.
                                        IF NOT l_it_vbpa[] IS INITIAL.
                                        * Get the country description from T005t table
                                        SELECT land1
                                        landx
                                        FROM t005t
                                        INTO TABLE it_t005t
                                        FOR ALL ENTRIES IN l_it_vbpa
                                        WHERE spras = c_e
                                        AND  land1 = l_it_vbpa-land1.
                                        IF sy-subrc = 0.
                                        SORT it_t005t BY land1.
                                        ENDIF.
                                        ENDIF.
                                        ENDIF.
                                        ENDIF.
                                        ENDFORM.                    " get_ship_to_data
                                        *&      Form  get_material_group_3
                                        * Get material group 3
                                        FORM get_material_group_3 .
                                        DATA: l_it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp.
                                        REFRESH: it_tvm3t.
                                        * Create an unique and sorted driver table
                                        l_it_vbrk_vbrp[] = it_vbrk_vbrp[].
                                        SORT l_it_vbrk_vbrp BY mvgr3.
                                        DELETE ADJACENT DUPLICATES FROM l_it_vbrk_vbrp COMPARING mvgr3.
                                        IF NOT l_it_vbrk_vbrp[] IS INITIAL.
                                        SELECT mvgr3
                                        bezei
                                        FROM tvm3t
                                        INTO TABLE it_tvm3t
                                        FOR ALL ENTRIES IN l_it_vbrk_vbrp
                                        WHERE mvgr3 = l_it_vbrk_vbrp-mvgr3.
                                        IF sy-subrc = 0.
                                        SORT it_tvm3t BY mvgr3.
                                        ENDIF.
                                        ENDIF.
                                        ENDFORM.                    " get_material_group_3
                                        *&      Form  get_material_group_4
                                        * Get material group 4
                                        FORM get_material_group_4 .
                                        DATA: l_it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp.
                                        REFRESH: it_tvm4t.
                                        * Create an unique and sorted driver table
                                        l_it_vbrk_vbrp[] = it_vbrk_vbrp[].
                                        SORT l_it_vbrk_vbrp BY mvgr4.
                                        DELETE ADJACENT DUPLICATES FROM l_it_vbrk_vbrp COMPARING mvgr4.
                                        IF NOT l_it_vbrk_vbrp[] IS INITIAL.
                                        SELECT mvgr4
                                        bezei
                                        FROM tvm4t
                                        INTO TABLE it_tvm4t
                                             FOR ALL ENTRIES IN l_it_vbrk_vbrp
                                             WHERE mvgr4 = l_it_vbrk_vbrp-mvgr4.
                                             IF sy-subrc = 0.
                                               SORT it_tvm4t BY mvgr4.
                                             ENDIF.
                                           ENDIF.
                                        ENDFORM.                    " get_material_group_4
                                        *&      Form  process_data
                                        * Process the data and do summation and populate final display table
                                        FORM process_data .
                                                                                    LOOP AT it_vbrk_vbrp INTO wa_vbrk_vbrp.
                                             CLEAR: wa_data, wa_vbpa.
                                             READ TABLE it_vbpa INTO wa_vbpa WITH KEY
                                                                          vbeln = wa_vbrk_vbrp-aubel
                                                                          BINARY SEARCH.
                                             IF sy-subrc = 0.
                                               wa_data-land1 = wa_vbpa-land1.
                                             ENDIF.
                                                                                    wa_data-mvgr3 = wa_vbrk_vbrp-mvgr3.
                                             wa_data-mvgr4 = wa_vbrk_vbrp-mvgr4.
                                                                                    * Do an unit conversion of the quamtity
                                             CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
                                               EXPORTING
                                                 input                      = wa_vbrk_vbrp-ntgew
                                        *      NO_TYPE_CHECK              = 'X'
                                        *      ROUND_SIGN                 = ' '
                                                unit_in                    = wa_vbrk_vbrp-gewei
                                                unit_out                   = 'TO' "Metric tonn
                                              IMPORTING
                                                output                     = wa_vbrk_vbrp-ntgew
                                              EXCEPTIONS
                                                conversion_not_found       = 1
                                                division_by_zero           = 2
                                                input_invalid              = 3
                                                output_invalid             = 4
                                                overflow                   = 5
                                                type_invalid               = 6
                                                units_missing              = 7
                                                unit_in_not_found          = 8
                                                unit_out_not_found         = 9
                                                OTHERS                     = 10.
                                             IF sy-subrc <> 0.
                                               wa_vbrk_vbrp-ntgew = wa_vbrk_vbrp-ntgew.
                                             ENDIF.
                                        * Convert the currency from Customer currency to local
                                        * currency by multiplying with kursk
                                             wa_vbrk_vbrp-kzwi1 =  wa_vbrk_vbrp-kzwi1 * wa_vbrk_vbrp-kursk.
                                        * Convert the amount to Lacks by dividing with 100000
                                            wa_vbrk_vbrp-kzwi1 = wa_vbrk_vbrp-kzwi1 / 100000.       "DV1K905028
                                        * When MVGR1 is between A to F use the amount as TEA_BAG
                                             IF wa_vbrk_vbrp-mvgr1 BETWEEN 'A' AND 'F'.
                                               wa_data-ntgew_tea_bag = wa_vbrk_vbrp-ntgew.
                                               wa_data-kzwi1_tea_bag = wa_vbrk_vbrp-kzwi1.
                                             ENDIF.
                                        * When MVGR1 is between G to L use the amount as TEA_BAG
                                             IF wa_vbrk_vbrp-mvgr1 BETWEEN 'G' AND 'L'.
                                               wa_data-ntgew_pkt_tea = wa_vbrk_vbrp-ntgew.
                                               wa_data-kzwi1_pkt_tea = wa_vbrk_vbrp-kzwi1.
                                             ENDIF.
                                        * When MVGR1 is between G to L use the amount as TEA_BAG
                                             IF wa_vbrk_vbrp-mvgr1 = 'M'.
                                               wa_data-ntgew_bulk_tea = wa_vbrk_vbrp-ntgew.
                                               wa_data-kzwi1_bulk_tea = wa_vbrk_vbrp-kzwi1.
                                             ENDIF.
                                                                                    COLLECT wa_data INTO it_data.
                                           ENDLOOP.
                                        ENDFORM.                    " process_data
                                        *&      Form  populate_description
                                        * Populate the description fields
                                        FORM populate_description .
                                           LOOP AT it_data INTO wa_data.
                                             CLEAR: wa_t005t.
                                             READ TABLE it_t005t INTO wa_t005t WITH KEY land1 = wa_data-land1
                                                                                    BINARY SEARCH.
                                             IF sy-subrc = 0.
                                               wa_data-landx = wa_t005t-landx.
                                             ENDIF.
                                        * Read description of Material group 3
                                             CLEAR wa_tvm3t.
                                             READ TABLE it_tvm3t INTO wa_tvm3t WITH KEY
                                                                      mvgr3 = wa_data-mvgr3
                                                                      BINARY SEARCH.
                                             IF sy-subrc = 0.
                                               wa_data-bezei3 = wa_tvm3t-bezei.
                                             ENDIF.
                                        * Read description of Material group 4
                                             CLEAR wa_tvm4t.
                                             READ TABLE it_tvm4t INTO wa_tvm4t WITH KEY
                                                                      mvgr4 = wa_data-mvgr4
                                                                      BINARY SEARCH.
                                             IF sy-subrc = 0.
                                               wa_data-bezei4 = wa_tvm4t-bezei.
                                             ENDIF.
                                        * Get the grand totals
                                             wa_data-ntgew_tot = wa_data-ntgew_tea_bag
                                                      + wa_data-ntgew_pkt_tea
                                                      + wa_data-ntgew_bulk_tea.
                                                                                    wa_data-kzwi1_tot = wa_data-kzwi1_tea_bag
                                                      + wa_data-kzwi1_pkt_tea
                                                      + wa_data-kzwi1_bulk_tea.
                                                                                    MODIFY it_data FROM wa_data TRANSPORTING landx
                                                                                    bezei3
                                                                                    bezei4
                                                                                    ntgew_tot
                                                                                    kzwi1_tot.
                                        * Summattion of grand totals
                                             w_tot_ntgew_tea_bag  = w_tot_ntgew_tea_bag  + wa_data-ntgew_tea_bag.
                                             w_tot_ntgew_pkt_tea  = w_tot_ntgew_pkt_tea  + wa_data-ntgew_pkt_tea.
                                             w_tot_ntgew_bulk_tea  = w_tot_ntgew_bulk_tea  + wa_data-ntgew_bulk_tea.
                                             w_tot_ntgew_tot  = w_tot_ntgew_tot  + wa_data-ntgew_tot.
                                                                                    w_tot_kzwi1_tea_bag  = w_tot_kzwi1_tea_bag  + wa_data-kzwi1_tea_bag.
                                             w_tot_kzwi1_pkt_tea  = w_tot_kzwi1_pkt_tea  + wa_data-kzwi1_pkt_tea.
                                             w_tot_kzwi1_bulk_tea  = w_tot_kzwi1_bulk_tea  + wa_data-kzwi1_bulk_tea.
                                             w_tot_kzwi1_tot  = w_tot_kzwi1_tot  + wa_data-kzwi1_tot.
                                                                                    ENDLOOP.
                                        * Append a grand Total row at the end
                                           CLEAR wa_data.
                                           wa_data-landx = 'Grand Total:'.
                                           wa_data-ntgew_tea_bag = w_tot_ntgew_tea_bag.
                                           wa_data-ntgew_pkt_tea = w_tot_ntgew_pkt_tea.
                                           wa_data-ntgew_bulk_tea = w_tot_ntgew_bulk_tea.
                                           wa_data-ntgew_tot = w_tot_ntgew_tot.
                                           wa_data-kzwi1_tea_bag = w_tot_kzwi1_tea_bag.
                                           wa_data-kzwi1_pkt_tea = w_tot_kzwi1_pkt_tea.
                                           wa_data-kzwi1_bulk_tea = w_tot_kzwi1_bulk_tea.
                                           wa_data-kzwi1_tot = w_tot_kzwi1_tot.
                                           wa_data-line_color    = 'C310'.
                                           APPEND wa_data TO it_data.
                                        ENDFORM.                    " populate_description
                                        *&      Module  STATUS_9000  OUTPUT
                                        * Initialise PF-STATUS and title
                                        MODULE status_9000 OUTPUT.
                                           SET PF-STATUS 'MAIN9000'.
                                           SET TITLEBAR 'TITLE_9000'.
                                        ENDMODULE.                 " STATUS_9000  OUTPUT
                                        *&      Module  initialize_9000  OUTPUT
                                        *       text
                                        MODULE initialize_9000 OUTPUT.
                                        * Call the ALV grid to display data
                                           PERFORM display_alv_grid.
                                        ENDMODULE.                 " initialize_9000  OUTPUT
                                        *&      Module  USER_COMMAND_9000  INPUT
                                        * Module to handle User Command
                                        MODULE user_command_9000 INPUT.
                                           CASE okcode.
                                             WHEN 'BACK'.
                                               SET SCREEN 0.
                                               CLEAR okcode.
                                               LEAVE SCREEN.
                                             WHEN 'CANCEL'.
                                               SET SCREEN 0.
                                               CLEAR okcode.
                                               LEAVE SCREEN.
                                             WHEN 'EXIT'.
                                               CLEAR okcode.
                                               LEAVE PROGRAM.
                                             WHEN OTHERS.
                                           ENDCASE.
                                        ENDMODULE.                 " USER_COMMAND_9000  INPUT
                                        *&      Form  display_alv_grid
                                        * Display the data in ALV Grid
                                        FORM display_alv_grid .
                                           IF w_alv_container IS INITIAL.
                                        * Create the alv container object
                                             CREATE OBJECT w_alv_container
                                               EXPORTING
                                                 container_name = 'ALV_GRID'
                                               EXCEPTIONS
                                                   cntl_error                  = 1
                                                   cntl_system_error           = 2
                                                   create_error                = 3
                                                   lifetime_error              = 4
                                                   lifetime_dynpro_dynpro_link = 5
                                                   OTHERS                      = 6.
                                             IF sy-subrc <> 0.
                                               MESSAGE e999(zttl) WITH 'Problem in ALV display'(t04).
                                             ENDIF.
                                        * Create the ALV grid object. The parent is the ALV container
                                             CREATE OBJECT w_alv_grid
                                               EXPORTING
                                                 i_parent = w_alv_container
                                               EXCEPTIONS
                                                 error_cntl_create = 1
                                                 error_cntl_init   = 2
                                                 error_cntl_link   = 3
                                                 error_dp_create   = 4
                                                 OTHERS            = 5.
                                                                                    IF sy-subrc <> 0.
                                               MESSAGE e999(zttl) WITH 'Problem in ALV display'(t04).
                                             ENDIF.
                                        * This subrotine creates the field catalog and
                                        * store in internal table lt_fieldcat
                                             PERFORM prepare_fieldcat CHANGING wt_fieldcat.
                                                                                    * Layout design
                                             w_layo-no_toolbar = ''.
                                        * Not to allow totaling feature
                                             w_layo-no_totline = c_x.
                                        * Report title
                                        *    w_layo-grid_title = text-004.
                                             w_layo-grid_title = w_title.
                                                                                    w_layo-zebra      = c_x.    "Alternating line color (striped)
                                             w_layo-cwidth_opt = c_x.    "Optimize column width
                                             w_layo-sel_mode   = 'A'.    "Selection Mode
                                        * Name of the color field
                                             w_layo-info_fname = 'LINE_COLOR'."For row color
                                        * Call the method to display the data in ALV grid
                                             CALL METHOD w_alv_grid->set_table_for_first_display
                                               EXPORTING
                                                 i_save                        = 'A'
                                                 is_layout                     = w_layo
                                               CHANGING
                                                 it_outtab                     = it_data[]
                                                 it_fieldcatalog               = wt_fieldcat
                                               EXCEPTIONS
                                                 invalid_parameter_combination = 1
                                                 program_error                 = 2
                                                 too_many_lines                = 3
                                                 OTHERS                        = 4.
                                                                                    IF sy-subrc <> 0.
                                               MESSAGE e999(zttl) WITH text-t04.
                                             ENDIF.
                                           ELSE.
                                        * If the container & grid object is alreadt there reuse them
                                             CALL METHOD w_alv_grid->refresh_table_display
                                               EXCEPTIONS
                                                 finished = 1
                                                 OTHERS   = 2.
                                             IF sy-subrc <> 0.
                                               MESSAGE e999(zttl) WITH text-t04.
                                             ENDIF.
                                           ENDIF.
                                           IF okcode = 'CANCEL'.
                                             EXIT.
                                           ENDIF.
                                        ENDFORM.                    " display_alv_grid
                                        *&      Form  prepare_fieldcat
                 

  • Regarding Select query to select only 1000 records in Internal Table.

    Hello Friends,
    Please explain me to how to Select only 1000 records from data base table?
    For Example
    SELECT *  INTO TABLE ITAB                          OR            SELECT * INTO ITAB 
         FROM EKKO                                                                  FROM EKKO
    WHERE EBLEN IN S_EBLEN.                                            WHERE EBLEN IN S_EBLEN
    (Currently i am using)                                                       UP TO 1000 ROWS.
                                                                                    ENDSELECT.  (I do not want to use)
                                                                                    In this case Internal table may be store more then 1000 records. But i want to select first 1000 records.
    Please explain me.
    Regards
    Amit

    Hi,
    TABLES : ekko.
    selection-screen begin of block b1 with frame title text_t01.
    SELECT-OPTIONS: S_EBELN for ekko-EBELN.
    selection-screen end of block b1.
    DATA itab TYPE STANDARD TABLE OF ekko.
    SELECT *
      FROM ekko
      INTO TABLE itab
      UP TO 1000 ROWS
      WHERE EBELN IN S_EBELN.
    Thanks,
    Sri.

  • Im trying to update db table in  user exit, with the internal table

    Im trying to update db table in user exit, with the internal table
    my scenario:
    loop at itekpo.
    updating itekpo -
    > at the end of user exit the db table ekpo have to be updated
    endloop.
    Im updating internal table, using 
    MODIFY itekpo TRANSPORTING INCO1 INCO2  WHERE ebeln = itekpo-ebeln
    where itekpo is internal table, but it is not updating the db table 'ekpo'.
    i also tried updating ekpo directly !
    Thanks in advance

    Hi,
    you can search in the forum itself,
    Try this link for instance
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=tocreateaBADI&adv=false&sortby=cm_rnd_rankvalue
    You can find a code for finding BADI as a report with the following Transaction
    finding badis
    How to find BADIs
    Reward if helpful
    Regards
    Byju

  • 2 different  tables   in the main window with same internal table data

    Hi All,
    can we have 2 diffterent  tables with same internal table data into its work area in the main window.Is it possible or we will get any run time error.?
    is it like having 2 nested loop with same internal table ?
    ex : loop at itab1 into wa_itab.
           loop at itab1 into wa_itab.
    endloop.
    endloop.
    can we use like this?

    Hi,
    there will not be any error ...but what is the use of it...
    do you need to have a controlled way of display ...of the data...
    If so then you create another workarea in the global definitions of the same type and then use it...
    Regards,
    Ram

  • How to use aggregate function on internal table

    hi experts,
    I am beginner in abap.I want to use sum function on internal table.
    I have structure as follow:
    types: begin of ty_ftab,
           docno TYPE bkpf-belnr,
           comcode TYPE bkpf-bukrs,
           year TYPE bkpf-gjahr,
           line_itm type bsad-buzei,
           cust type bsad-kunnr,
           amt type bsad-dmbtr,
    end of ty_ftab.
    data: it_ftab type table of ty_ftab,
               wa_ftab type ty_ftab.
    i fetched data successfully into it_ftab from bkpf and bsad table and displyed into alv.
    now i want sum of amt using group by cust and want to display like
    cust        total_amt      
    in next screen...
    displying part is not important but how can i do sum of amt according to cust value? Is there in way to query on internal table?

    Hi,
    try this code,
    data : i_sort  TYPE TABLE OF slis_sortinfo_alv
      w_sort like LINE OF i_sort.
    sort it_ftab by cust.
    w_sort-subtot = 'X'.
    w_sort-fieldname = 'AMT'.
    w_sort-tabname = 'it_ftab'.
    APPEND w_sort to i_sort.
    In fieldcatalog :
    w_fcat-fieldname = 'AMT'.
    w_fcat-tabname  = 'it_ftab'.
    w_fcat-do_sum = 'X'.
    In REUSE_ALV_GRID_DISPLAY  FUNCTION MODULE  provide the it_sort.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *  EXPORTING
    *    I_INTERFACE_CHECK                = ' '
    *    I_BYPASSING_BUFFER                = ' '
    *    I_BUFFER_ACTIVE                  = ' '
    *    I_CALLBACK_PROGRAM                = ' '
    *    I_CALLBACK_PF_STATUS_SET          = ' '
    *    I_CALLBACK_USER_COMMAND          = ' '
    *    I_CALLBACK_TOP_OF_PAGE            = ' '
    *    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_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
    *    I_HTML_HEIGHT_TOP                = 0
    *    I_HTML_HEIGHT_END                = 0
    *    IT_ALV_GRAPHICS                  =
    *    IT_HYPERLINK                      =
    *    IT_ADD_FIELDCAT                  =
    *    IT_EXCEPT_QINFO                  =
    *    IR_SALV_FULLSCREEN_ADAPTER        =
    *  IMPORTING
    *    E_EXIT_CAUSED_BY_CALLER          =
    *    ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          =
    *  EXCEPTIONS
    *    PROGRAM_ERROR                    = 1
    *    OTHERS                            = 2
      IF sy-subrc <> 0.
    * Implement suitable error handling here
      ENDIF.

  • Using colspan with nested html tables

    Please see my question on stackoverflow at:
    using colspan with nested html tables - Stack Overflow

    You should be posting in the Dreamweaver forum.  This is not a design
    question as such is it? Dreamweaver forum is the most busiest forum on
    Adobe portal and you are very likely to get the response and a solution
    almost quickly.
    <https://forums.adobe.com/community/dreamweaver>
    Good luck.

  • Select entries present in an internal table using a range of key values

    Hi guys,
    I have an internal table tb_bseg.
    It contains the vendor code (lifnr), document number (belnr) and other fields.
    How can I select values so that it may follow my (lifnr) range values in the selection screen?
    SELECT belnr lifnr gsber mwskz hwbas wrbtr anln1 aufnr prctr projk nplnr kostl FROM bseg INTO TABLE tb_bseg
             WHERE bukrs = pa_bukrs
             AND belnr = tb_bkpf-belnr
             AND gjahr = tb_bkpf-gjahr.
            AND lifnr IN cd_lifnr. ??? can I use something like this?
    Please guide me regarding this.
    Best regards,
    Reymar

    Hi Reymar,
    You are right . You can use that way. So your select query will be
    SELECT belnr lifnr gsber mwskz hwbas wrbtr anln1 aufnr prctr projk nplnr kostl FROM bseg INTO TABLE tb_bseg
    WHERE bukrs = pa_bukrs
    AND belnr = tb_bkpf-belnr
    AND gjahr = tb_bkpf-gjahr
    AND lifnr IN cd_lifnr.
    where cd_lifnr is the selection screen field.
    declare it as
    SELECT-OPTIONS :
      CD_LIFNR FOR BSEG-LIFNR.
    Regards,
    Swapna.
    Edited by: NagaSwapna Thota on Sep 4, 2008 5:19 PM

  • SELECT-OPTIONS can u use it to read internal table ?????

    Hello All,
       I am trying to read an internal table with the select-options statement. I am getting a syntax error so i am hoping i am just coding it incorrectly. Can someone tell me what is wrong here is the if statement :
    if p_begdte in t_rpt-datab and
           p_enddte in t_rpt-datbi.
        else.
           exit.
        endif.
    thanks scott

    This is not working?
    tables: a916.
    * Beg valid date *
    data text021(29).
    selection-screen begin of line.
    selection-screen comment 1(30) text-021 for field p_begdte.
    selection-screen position 32.
    select-options: p_begdte for a916-datab default '20041101' to
    '99991231'.
    selection-screen end of line.
    * End valid date *
    data text022(29).
    selection-screen begin of line.
    selection-screen comment 1(30) text-022 for field p_enddte.
    selection-screen position 32.
    select-options: p_enddte for a916-datbi default '20041101' to
    '99991231'.
    selection-screen end of line.
    start-of-selection.
    <b>Loop at t_rpt.
    if t_rpt-datab in p_begdte
      and t_rpt-datbi in p_endte.
    * do something
    else.
    exit.
    endif
    Endloop.</b>
    Regards,
    Rich Heilman

  • Help to work with 2 internal table with tricky  use

    HI ,
    I have 2 internal table one with new data and one with old data (same structure ) and i want to combine the 2 of them to final table .
    what i need to do here is little bit tricky
    The  table is build like this :
    mandt
    User
    user_data
    valid
    if there is no different from the user data from table old to table new the user data in the final table should look like this
    000
    user1
    userdata1
    X
    000
    user1
    userdata2
    X
    IF there is difference between of them the table entries in final table should like this
    000
    user1
    userdata3
    X
    000
    user1
    userdata4
    X
    000
    user1
    userdata1
    "Valid field is empty -abap false  since the user dont have this data (userdata1) any more
    000
    user1
    userdata2
    "Valid field is empty -abap false  since the user dont have this data (userdata2) any more
    1. alwayes table new is coming with data that is valid field = abap_true
       and should be change the user entries just if there is new entries are diffrent than the old one .
    2. table new can have new users with data so it enter the new users to final table with valid entry = abap_true
    3. if in the new table there is no user which exist in the old table the user in the final table
    should stay with the same entries but the valid entry should be abap false
    What is the best way to do that ?
    Regards
    Chris
    Edited by: Chris Teb on Nov 15, 2009 10:39 AM

    HI
    I have table with entries like that that i read from DB (i call it itab_old)
    old_itab
    mandt     User      user data      timestemp      valid
    0     usr1      User_data1     X     TRUE
    0     usr1      User_data2     X     TRUE
    0     usr1      User_data3     X     TRUE
    0     usr2      User_data1     X     TRUE
    0     usr2      User_data2     X     TRUE
    0     usr2      User_data3     X     TRUE
    0     usr2      User_data4     X     TRUE
    0     usr3     User_data1     X     TRUE
    0     usr3     User_data2     X     TRUE
    0     usr3     User_data3     X     TRUE
    assume the user entry for usr 1 is changing i.e. (new entries in table itab_new) the table should look like this
    new_itab
    mandt     User      user data      timestemp      valid
    0     usr1      User_data4     Y     TRUE
    0     usr1      User_data2     Y     TRUE
    0     usr1      User_data6     Y     TRUE
    0     usr2      User_data1     Y     TRUE
    0     usr2      User_data2     Y     TRUE
    0     usr2      User_data3     Y     TRUE
    0     usr2      User_data4     Y     TRUE
    and the final_itab should look like that
    usr1 old entries are mark as false and new recoreds is enter to the table for him ,
    usr2 have the same entries so it not change
    final_itab
    mandt     User      user data      timestemp      valid
    0     usr1      User_data1     X     FALSE
    0     usr1      User_data2     X     FALSE
    0     usr1      User_data3     X     FALSE
    0     usr2      User_data1     X     TRUE
    0     usr2      User_data2     X     TRUE
    0     usr2      User_data3     X     TRUE
    0     usr2      User_data4     X     TRUE
    0     usr3     User_data1     X     TRUE
    0     usr3     User_data2     X     TRUE
    0     usr3     User_data3     X     TRUE
    0     usr1      User_data4     Y     TRUE
    0     usr1      User_data2     Y     TRUE
    0     usr1      User_data6     Y     TRUE
    0     usr7     User_data1     X     TRUE
    0     usr7     User_data2     X     TRUE
    0     usr7     User_data3     X     TRUE
    last thing there is option that new user will come in table new_itab that is not exist in old table for this user we need to create new entry in final table (like user 7 )
    Thanks in advance
    Chris
    Edited by: Chris Teb on Nov 15, 2009 10:50 PM

  • How to make use of a global internal table in SAP BW during transfer rules

    HI friends,
    I am ABAP consultant working on some APO info cubes. I have an issue during the upload of planning area data into APO info cube.
    Please help.
    I am using a transfer routine to find the TECHWEEK from a data base table ZGC_CALWEEK based on the on the calender month and calender week.
    Code I am writing is like below.
    *       FORM COMPUTE_/BIC/ZCALWEEK
    * Compute value of InfoObject ZCALWEEK
    * in communication structure /BIC/CSZT6DPPA
    * Technical properties:
    *     field name      = /BIC/ZCALWEEK
    *     data element    = /BIC/OIZCALWEEK
    *     data type       = NUMC
    *     length          = 000006
    *     decimals        = 000000
    *     ABAP type       = N
    *     ABAP length     = 000006
    *     reference field =
    * Parameters:
    *  -->  RECORD_NO       Record number
    *  -->  TRAN_STRUCTURE  Transfer structure
    *  <--  RESULT          Return value of InfoObject
    *  <->  G_T_ERRORLOG    Error log
    *  <--  RETURNCODE      Return code (to skip one record)
    *  <--  ABORT           Abort code (to skip whole data package)
    FORM COMPUTE_/BIC/ZCALWEEK
      USING    RECORD_NO LIKE SY-TABIX
               TRAN_STRUCTURE TYPE TRANSFER_STRUCTURE
               G_S_MINFO TYPE RSSM_S_MINFO
      CHANGING RESULT TYPE /BIC/OIZCALWEEK
               G_T_ERRORLOG TYPE rssm_t_errorlog_int
               RETURNCODE LIKE SY-SUBRC
               ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel datapackage
    *$*$ begin of routine - insert your code only below this line        *-*
    * DATA: l_s_errorlog TYPE rssm_s_errorlog_int.
    DATA: LV_WEEK         TYPE ZGC_CALWEEK-APOWEEK,
            LV_MONTH        TYPE ZGC_CALWEEK-APOMONTH,
            LV_TECH_WEEK    TYPE ZGC_CALWEEK-TECHWEEK.
      LV_WEEK   = TRAN_STRUCTURE-CALWEEK.
      LV_MONTH  = TRAN_STRUCTURE-CALMONTH.
      SELECT SINGLE TECHWEEK INTO LV_TECH_WEEK
        FROM ZGC_CALWEEK CLIENT SPECIFIED
        WHERE  MANDT = SY-MANDT
        AND  APOWEEK  = LV_WEEK
        AND   APOMONTH = LV_MONTH.
      IF SY-SUBRC IS INITIAL.
        RESULT = LV_TECH_WEEK.
      ELSE.
        RETURNCODE = 1.
        ENDIF.
    *$*$ end of routine - insert your code only before this line         *-*
    ENDFORM.
    There are more than 50-80 million records that wil be transferred from planning area to info cube. The select statment is giving pathetic performance as this has to run 50-80 million times.
    After adding the select statment to find the TECHWEEK it is taking 4 times the time that used to take before writing the select statment.
    Is there a way that I can first fetch the data from ZGC_CALWEEK to one internal table and that internal table can be used using read statment during the transfer routine instead of writing select statement here.
    Please help in this case?

    Hi Ashutosh,
    Thanks for the reply,
    The structure of the ZGC_CALWEEK is as below. I have already created a secondary index on the table for this table for the fields APO WEEK and APO MONTH. This didn't help much on the performance.
    I am also planning to keep the ZGC_CALWEEK database table to be fully buffered and this may definitely improve the performance but I need to reduce the data base hits as less as possible.
    MANDT                           MANDT                           CLNT     3     0     Client
    TECHWEEK                           ZTECHWEEK                           NUMC     6     0     Technical Week
    FROMDATE_TECH     DATUM                           DATS     8     0     Date
    TODATE_TECH     DATUM                           DATS     8     0     Date
    APOWEEK                           /BI0/OICALWEEK     NUMC     6     0     Calendar year / week
    FROMDATE_APO     DATUM                            DATS     8     0     Date
    TODATE_APO     DATUM                            DATS     8     0     Date
    APOMONTH                           /BI0/OICALMONTH     NUMC     6     0     Calendar year/month
    The table ZGC_CALWEEK is in APO system, where the transfer rules are being executed.
    As you mentioned START ROUTINE, In the start routine Can I create an internal table let's say GT_CALWEEK with structure ZGC_CALWEEK and pull all the records (I have a max of 2000 records in this table) from ZGC_CALWEEK to GT_CALWEEK and Can I used the same internal table GT_CALWEEK in the transfer routine to read the TECHWEEK from internal table.
    Thank you very much again for you reply. Any help regarding this would be greatly appreciated.
    Best regards,
    Siva

  • To fetch selective fields from DATABASETABLE into Internal TABLE

    Hi Friends,
    I have declared an internal table with fields for e.g. A , B , C , D.
    This does not have any records as of now.
    I have to fetch data from a DATABASE TABLE with fields A , B , X , Y , Z having records .
    I only need records for fields A B fron DB table.Can any one pls tell how can I do that with performance issues in mind as lots of records are there.
    I had written a query where:
    SELECT A B from dbtab
                        into CORRESPONDING FIELDS of table it_table.
    It_table i had defined with only two fields A B.
    Is this correct?
    Please tell wats the way to do it as I am new to ABAP.
    THANKS in ADVANCE..

    Hi.....
    What mentioned in all above answers is very helpful for ur requirement...
    and...
       Here some Steps to increase the performence of your programs...
    >Use Select Single when only one row is expected
    >Use Select Where rather than Selectu2026Check
    >Use Select with aggregate functions (SUM, MAX, MINu2026)
    >Use a View instead of nested Selects
    >Use Select column specific instead of select * for few fields
    >Use Selectu2026Into Table rather than Select...Move Corru2026Apend
    >Use Join extension with Select if possible
    >Use special operators (CO, CA, CS) rather than code your own
    >Use Delete Adjacent Duplicates rather than manual processing
    >Specify key fields for Readu2026Binary Search
    >Use Loop At Where rather than Loop Atu2026Check
    >Copy Internal Tables with TAB_DEST() = TAB_SRC()
    >Specify the sort key as restrictively as possible
    >Use Append To, Insert Into, Collect Into rather than Move
    >Compare tables with If Tab1() = Tab2()u2026
    >Use Delete ITAB Whereu2026 instead of Loop At ITAB Whereu2026Delete..
    >Use Case statements instead of If-constructions
    >Use Call Functions wisely, Performs use less memory
    >Use While instead of Do Exit
    >Use Type I for Indices
    >Keep Occurs clause realistic or use 0
    >Use COMMIT WORK as appropriate to free the Data Base and preserve work
    >
    >Avoid:
    >Using Shift inside a While-loop
    >Leaving unneeded declarations in your program
    >Using Move-corresponding for just a few fields
    >Excessive nested includes within function calls
    >Using DB field names if the value will be changed
    >Using Occurs clause if only the header is needed
    Thanks,
    Naveen.I

Maybe you are looking for