JOIN VBRK VBRP : BAD performance

I have a big performance problem with this :
SELECT  vvbeln vfkart vfkdat vvbtyp vkunrg vvkorg v~bukrs
          bPOSNR bmatnr bfkimg bprsdt b~werks
          FROM VBRK As v
          JOIN VBRP AS b ON bvbeln = vvbeln
   APPENDING corresponding fields of table t_vbrk
         WHERE v~fkart IN s_fkart
           AND b~matnr IN s_matnr
           AND b~ean11 IN s_ean11.
Any idea to solve this issue to improve the perfromance ?
Thank you.

HI
Use for all entries instead of joins and remove corresponding fields of, use into table with exact strucutre fields.

Similar Messages

  • Joining VBRK, VBRP, VBAK, VBAP, LIKP, LIPS

    Hello,
    I just wanted to ask how to join the above subject in one table? Or it isnt possible?
    I read that joining 3 or more tables would degrade the performance But i need to get the data in those tables. Any help would greatly appreciated. Thanks!

    Hi,
    Please take a look at my program below. There you can see how to join the tables that you mentioned. Hope it helps...
    P.S. Please award points if it helps...
    *=====================================================================
    * Program Name : ZSD_ORDERSTAGE_V2
    * Author       : Aris Hidalgo
    * Date Created : June 5, 2007
    * Description  : Display sales orders status for a given customer
    *=====================================================================
    REPORT  zsd_orderstage_v2
            NO STANDARD PAGE HEADING
            MESSAGE-ID zsd.
    * Data Dictionary Table/s                      *
    TABLES: vbak,
            vttp.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    * Global Data/s                                *
    DATA: gt_fieldcat         TYPE lvc_t_fcat,
          ok_code             TYPE syst-ucomm,
          save_ok             TYPE syst-ucomm,
          g_repid             TYPE syst-repid,
          gs_layout           TYPE lvc_s_layo,
          gv_container        TYPE scrfname VALUE 'CUSTOM_CONTROL',
          grid1               TYPE REF TO cl_gui_alv_grid,
          custom_container    TYPE REF TO cl_gui_custom_container,
          grid2               TYPE REF TO cl_gui_alv_grid,
          dialogbox_container TYPE REF TO cl_gui_dialogbox_container,
          event_receiver      TYPE REF TO lcl_event_receiver.
    * Global Structure/s                           *
    TYPES: BEGIN OF t_output,
            creation_date  TYPE vbak-erdat,
            creation_time  TYPE vbak-erzet,
            sales_doc      TYPE vbak-vbeln,
            cust_code      TYPE vbak-kunnr,
            cust_desc      TYPE kna1-name1,
            ship_to_code   TYPE likp-kunnr,
            ship_to_desc   TYPE kna1-name1,
            po_num         TYPE vbak-bstnk,
            doc_type       TYPE vbak-auart,
            req_dlv_date   TYPE vbak-vdatu,
            so_status(02)  TYPE c,
            created_by     TYPE vbak-ernam,
            del_doc        TYPE likp-vbeln,
            bill_doc       TYPE vbrk-vbeln,
           END OF t_output.
    TYPES: BEGIN OF t_column,
            fname TYPE lvc_fname,
            level TYPE lvc_level,
           END OF t_column.
    * Global Internal Table/s                      *
    DATA: gt_output TYPE STANDARD TABLE OF t_output,
          gt_column TYPE STANDARD TABLE OF t_column.
    * Global Work Area/s                           *
    DATA: wa_output LIKE LINE OF gt_output.
    * SELECTION-SCREEN                             *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:     p_kunnr TYPE vbak-kunnr OBLIGATORY.
    SELECT-OPTIONS: s_vkgrp FOR vbak-vkgrp,
                    s_auart FOR vbak-auart,
                    s_erdat FOR vbak-erdat  OBLIGATORY,
                    s_ernam FOR vbak-ernam.
    SELECTION-SCREEN END OF BLOCK b1.
    */ CLASS DEFINITION/S
    CLASS lcl_process_data DEFINITION DEFERRED.
    *       CLASS lcl_get_data DEFINITION
    CLASS lcl_get_data DEFINITION.
      PUBLIC SECTION.
        TYPES: BEGIN OF t_vbak,
                vbeln TYPE vbak-vbeln,
                erdat TYPE vbak-erdat,
                erzet TYPE vbak-erzet,
                ernam TYPE vbak-ernam,
                auart TYPE vbak-auart,
                vdatu TYPE vbak-vdatu,
                bstnk TYPE vbak-bstnk,
                kunnr TYPE vbak-kunnr,
               END OF t_vbak.
        TYPES: BEGIN OF t_kna1,
                kunnr TYPE kna1-kunnr,
                name1 TYPE kna1-name1,
               END OF t_kna1.
        TYPES: BEGIN OF t_delivery,
                vgbel TYPE lips-vgbel,
                vbeln TYPE likp-vbeln,
                kunnr TYPE likp-kunnr,
               END OF t_delivery.
        TYPES: BEGIN OF t_billing,
                vbelv   TYPE vbfa-vbelv,
                vbtyp_n TYPE vbfa-vbtyp_n,
                vbeln   TYPE vbfa-vbeln,
               END OF t_billing.
        TYPES: BEGIN OF t_status,
                vbeln TYPE vbuk-vbeln,      "Sales and Distribution Document Number
                cmgst TYPE vbuk-cmgst,      "Overall status of credit checks
                lfstk TYPE vbuk-lfstk,      "Delivery status
                kostk TYPE vbuk-kostk,      "Overall picking / putaway status
                fkstk TYPE vbuk-fkstk,      "Billing status
                trsta TYPE vbuk-trsta,      "Transportation planning status
               END OF t_status.
        TYPES: BEGIN OF t_status_do,
                vbeln TYPE vbuk-vbeln,      "Delivery Document Number
                kostk TYPE vbuk-kostk,      "Overall picking / putaway status
                fkstk TYPE vbuk-fkstk,      "Billing status
                trsta TYPE vbuk-trsta,      "Transportation planning status
               END OF t_status_do.
        METHODS: get_sales_docs    FINAL,
                 get_customer_desc FINAL,
                 get_ship_to_desc  FINAL,
                 get_delivery_docs FINAL,
                 get_billing_docs  FINAL,
                 get_so_status     FINAL.
      PROTECTED SECTION.
        CLASS-DATA: gt_vbak            TYPE STANDARD TABLE OF t_vbak,
                    gt_kna1            TYPE HASHED   TABLE OF t_kna1
                                       WITH UNIQUE KEY kunnr,
                    gt_kna2            TYPE HASHED   TABLE OF t_kna1
                                       WITH UNIQUE KEY kunnr,
                    gt_delivery        TYPE STANDARD TABLE OF t_delivery,
                    gt_billing         TYPE STANDARD TABLE OF t_billing,
                    gt_status          TYPE STANDARD TABLE OF t_status,
                    gt_status_do       TYPE STANDARD TABLE OF t_status_do,
                    o_lcl_process_data TYPE REF TO lcl_process_data.
      PRIVATE SECTION.
        CLASS-DATA: wa_status LIKE LINE OF gt_status.
    ENDCLASS.                    "lcl_get_data DEFINITION
    *       CLASS lcl_process_data DEFINITION
    CLASS lcl_process_data DEFINITION INHERITING FROM lcl_get_data.
      PUBLIC SECTION.
        METHODS: combine_data FINAL
                   IMPORTING
                     im_sales_tab LIKE gt_vbak
                     im_cust_tab  LIKE gt_kna1
                     im_desc_tab  LIKE gt_kna2     OPTIONAL
                     im_dlv_tab   LIKE gt_delivery OPTIONAL
                     im_bill_tab  LIKE gt_billing  OPTIONAL
                   EXPORTING
                     ex_output    LIKE gt_output,
                 get_status
                   IMPORTING
                     im_so        TYPE vbak-vbeln
                     im_do        TYPE likp-vbeln   OPTIONAL
                   EXPORTING
                     ex_status    TYPE crmchar2.
      PRIVATE SECTION.
        DATA: lv_vbelv    TYPE vbfa-vbelv,
              lv_bill_doc TYPE vbfa-vbeln,
              lv_kunnr    TYPE vbpa-kunnr,
              lv_name1    TYPE kna1-name1,
              lv_parvw    TYPE vbpa-parvw,
              lv_flag1    TYPE flag.
    ENDCLASS.                    "lcl_process_data DEFINITION
    *       CLASS lcl_alv_routines DEFINITION
    CLASS lcl_alv_routines DEFINITION INHERITING FROM lcl_process_data.
      PUBLIC SECTION.
        TYPES: BEGIN OF t_status_history,
                 cr_hold(50)        TYPE c,
                 cr_rel_on(10)      TYPE c,
                 cr_rel_at(10)      TYPE c,
                 do_created_on(10)  TYPE c,
                 do_created_time(8) TYPE c,
                 picked_on(10)      TYPE c,
                 picked_time(8)     TYPE c,
                 inv_created_on(10) TYPE c,
                 dispatched_on(10)  TYPE c,
                 dispatched_at(10)  TYPE c,
               END OF t_status_history.
        TYPES: BEGIN OF t_confirmation,
                 podat TYPE likp-podat,
                 potim TYPE likp-potim,
               END OF t_confirmation.
        CLASS-DATA: wa_fieldcat       LIKE LINE OF gt_fieldcat,
                    gt_status_history TYPE STANDARD TABLE OF t_status_history,
                    gt_confirmation   TYPE STANDARD TABLE OF t_confirmation,
                    wa_status_history LIKE LINE OF gt_status_history,
                    wa_confirmation   LIKE LINE OF gt_confirmation,
                    wa_column         LIKE LINE OF gt_column,
                    gt_domain_val     TYPE STANDARD TABLE OF dd07v,
                    wa_domain_val     LIKE LINE OF gt_domain_val.
        METHODS: build_fieldcat FINAL,
                 popup_routines
                   IMPORTING
                     im_column LIKE gt_column
                     im_output LIKE wa_output
                   EXPORTING
                     ex_status_history LIKE gt_status_history
                     ex_confirmation   LIKE gt_confirmation,
                 get_domain_values FINAL
                   IMPORTING
                     value(im_tabname)    TYPE ddobjname
                     value(im_fieldname)  TYPE dfies-fieldname
                   EXPORTING
                     value(ex_values_tab) LIKE gt_domain_val.
      PRIVATE SECTION.
        CLASS-DATA: lt_dfies_tab TYPE STANDARD TABLE OF dfies,
                    wa_dfies_tab LIKE LINE OF lt_dfies_tab.
    ENDCLASS.                    "lcl_alv_routines DEFINITION
    *       CLASS lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver DEFINITION INHERITING FROM lcl_alv_routines FINAL.
      PUBLIC SECTION.
        METHODS: handle_double_click
                   FOR EVENT double_click OF cl_gui_alv_grid
                     IMPORTING
                       e_row
                       e_column,
                 handle_close
                   FOR EVENT close OF cl_gui_dialogbox_container
                     IMPORTING
                       sender,
                 handle_hotspot_click
                   FOR EVENT hotspot_click OF cl_gui_alv_grid
                     IMPORTING
                       e_row_id
                       e_column_id
                       es_row_no,
                 create_detail_list
                   IMPORTING
                     im_column         LIKE gt_column
                     im_status         LIKE gt_status_history
                     im_confirmation   LIKE gt_confirmation.
      PRIVATE SECTION.
        CLASS-DATA: o_lcl_alv_routines TYPE REF TO lcl_alv_routines.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    */ CLASS IMPLEMENTATION/S
    *       CLASS lcl_get_data IMPLEMENTATION
    CLASS lcl_get_data IMPLEMENTATION.
    * METHOD get_sales_docs
      METHOD get_sales_docs.
        SELECT vbeln erdat erzet ernam auart vdatu bstnk kunnr
          FROM vbak
          INTO TABLE gt_vbak
         WHERE erdat IN s_erdat
           AND ernam IN s_ernam
           AND auart IN s_auart
           AND vkgrp IN s_vkgrp
           AND kunnr =  p_kunnr.
        IF NOT gt_vbak[] IS INITIAL.
          CALL METHOD: me->get_customer_desc,
                           get_delivery_docs,
                           get_so_status,
                           get_billing_docs.
          CREATE OBJECT o_lcl_process_data.
          CALL METHOD o_lcl_process_data->combine_data
            EXPORTING
              im_sales_tab = gt_vbak
              im_cust_tab  = gt_kna1
              im_desc_tab  = gt_kna2
              im_dlv_tab   = gt_delivery
              im_bill_tab  = gt_billing
            IMPORTING
              ex_output    = gt_output.
        ELSE.
          MESSAGE i000 WITH text-032.
          LEAVE LIST-PROCESSING.
        ENDIF.
      ENDMETHOD.                    "get_sales_docs
    * METHOD get_customer_desc
      METHOD get_customer_desc.
        SELECT kunnr name1
          FROM kna1
          INTO TABLE gt_kna1
           FOR ALL ENTRIES IN gt_vbak
         WHERE kunnr = gt_vbak-kunnr.
      ENDMETHOD.                    "get_customer_desc
    * METHOD get_ship_to_desc
      METHOD get_ship_to_desc.
        SELECT kunnr name1
          FROM kna1
          INTO TABLE gt_kna2
           FOR ALL ENTRIES IN gt_delivery
         WHERE kunnr = gt_delivery-kunnr.
      ENDMETHOD.                    "get_ship_to_desc
    * METHOD get_delivery_docs
      METHOD get_delivery_docs.
        SELECT lips~vgbel likp~vbeln likp~kunnr
          FROM likp
         INNER JOIN lips
            ON likp~vbeln = lips~vbeln
          INTO TABLE gt_delivery
           FOR ALL ENTRIES IN gt_vbak
         WHERE lips~vgbel = gt_vbak-vbeln.
        IF NOT gt_delivery[] IS INITIAL.
          SORT gt_delivery ASCENDING BY: vgbel vbeln kunnr.
          DELETE ADJACENT DUPLICATES FROM gt_delivery COMPARING vgbel vbeln kunnr.
    *     Get ship-to description
          CALL METHOD me->get_ship_to_desc.
    *     Get status of delivery documents
          SELECT vbeln kostk fkstk trsta
            FROM vbuk
            INTO TABLE gt_status_do
             FOR ALL ENTRIES IN gt_delivery
           WHERE vbeln = gt_delivery-vbeln.
        ENDIF.
      ENDMETHOD.                    "get_delivery_docs
    * METHOD get_billing_docs
      METHOD get_billing_docs.
        SELECT vbelv vbtyp_n vbeln
          FROM vbfa
          INTO TABLE gt_billing
           FOR ALL ENTRIES IN gt_delivery
         WHERE vbelv   = gt_delivery-vbeln
           AND vbtyp_n = 'M'.
        SORT gt_billing ASCENDING BY: vbelv vbtyp_n vbeln.
        DELETE ADJACENT DUPLICATES FROM gt_billing COMPARING vbelv vbtyp_n vbeln.
      ENDMETHOD.                    "get_billing_docs
    * METHOD get_so_status
      METHOD get_so_status.
        DATA: lv_curr_so TYPE vbak-vbeln,
              lv_lines   TYPE i.
        FIELD-SYMBOLS: <fs_status>    LIKE LINE OF gt_status,
                       <fs_delivery>  LIKE LINE OF gt_delivery,
                       <fs_status_do> LIKE LINE OF gt_status_do.
        SELECT vbeln cmgst lfstk
          FROM vbuk
          INTO CORRESPONDING FIELDS OF TABLE gt_status
           FOR ALL ENTRIES IN gt_vbak
         WHERE vbeln = gt_vbak-vbeln.
        SORT gt_status_do BY vbeln ASCENDING.
        DESCRIBE TABLE gt_status LINES lv_lines.
        LOOP AT gt_status ASSIGNING <fs_status>.
          IF sy-tabix > lv_lines.
            EXIT.
          ENDIF.
          LOOP AT gt_delivery ASSIGNING <fs_delivery> WHERE vgbel = <fs_status>-vbeln.
            IF lv_curr_so = <fs_delivery>-vgbel.
              wa_status-vbeln = <fs_status>-vbeln.
              wa_status-cmgst = <fs_status>-cmgst.
              wa_status-lfstk = <fs_status>-lfstk.
              READ TABLE gt_status_do ASSIGNING <fs_status_do> WITH KEY vbeln = <fs_delivery>-vbeln
                                                                                BINARY SEARCH.
              IF sy-subrc = 0.
                wa_status-kostk = <fs_status_do>-kostk.
                wa_status-fkstk = <fs_status_do>-fkstk.
                wa_status-trsta = <fs_status_do>-trsta.
              ENDIF.
              APPEND wa_status TO gt_status.
              CLEAR wa_status.
            ELSE.
              READ TABLE gt_status_do ASSIGNING <fs_status_do> WITH KEY vbeln = <fs_delivery>-vbeln
                                                                                BINARY SEARCH.
              <fs_status>-kostk = <fs_status_do>-kostk.
              <fs_status>-fkstk = <fs_status_do>-fkstk.
              <fs_status>-trsta = <fs_status_do>-trsta.
            ENDIF.
            lv_curr_so = <fs_delivery>-vgbel.
          ENDLOOP.
        ENDLOOP.
      ENDMETHOD.                    "get_do_status
    ENDCLASS.                    "lcl_get_data IMPLEMENTATION
    *       CLASS lcl_process_data IMPLEMENTATION
    CLASS lcl_process_data IMPLEMENTATION.
    * METHOD combine_data
      METHOD combine_data.
        FIELD-SYMBOLS: <fs_sales_tab> LIKE LINE OF im_sales_tab,
                       <fs_cust_tab>  LIKE LINE OF im_cust_tab,
                       <fs_desc_tab>  LIKE LINE OF im_desc_tab,
                       <fs_dlv_tab>   LIKE LINE OF im_dlv_tab,
                       <fs_bill_tab>  LIKE LINE OF im_bill_tab.
        SORT gt_status BY vbeln ASCENDING.
        LOOP AT im_sales_tab ASSIGNING <fs_sales_tab>.
          CLEAR: lv_flag1, wa_output,lv_vbelv,
                 lv_bill_doc, lv_kunnr,
                 lv_name1, lv_parvw.
          wa_output-creation_date = <fs_sales_tab>-erdat.  "SO creation date
          wa_output-creation_time = <fs_sales_tab>-erzet.  "SO creation time
          wa_output-sales_doc     = <fs_sales_tab>-vbeln.  "Sales document
          wa_output-cust_code     = <fs_sales_tab>-kunnr.  "SO customer code
    *     Customer description
          READ TABLE im_cust_tab ASSIGNING <fs_cust_tab> WITH KEY kunnr = <fs_sales_tab>-kunnr.
          IF sy-subrc = 0.
            MOVE <fs_cust_tab>-name1 TO: wa_output-cust_desc.    "SO customer description
          ENDIF.
          wa_output-po_num       = <fs_sales_tab>-bstnk.   "PO number
          wa_output-doc_type     = <fs_sales_tab>-auart.   "SO document type
          wa_output-req_dlv_date = <fs_sales_tab>-vdatu.   "SO req. delivery date
          wa_output-created_by   = <fs_sales_tab>-ernam.   "SO created by
          READ TABLE im_dlv_tab ASSIGNING <fs_dlv_tab> WITH KEY vgbel = <fs_sales_tab>-vbeln.
          IF sy-subrc <> 0.
            CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
              EXPORTING
                input  = 'SH'
              IMPORTING
                output = lv_parvw.
    */Get ship-to party and description based from sales document
    * if delivery document is non-existent
            SELECT SINGLE kunnr
              FROM vbpa
              INTO lv_kunnr
             WHERE vbeln = <fs_sales_tab>-vbeln
               AND parvw = lv_parvw.             "Ship-to party
            IF sy-subrc = 0.
              SELECT SINGLE name1
                FROM kna1
                INTO lv_name1
               WHERE kunnr = lv_kunnr.
              IF sy-subrc = 0.
                wa_output-ship_to_code = lv_kunnr.
                wa_output-ship_to_desc = lv_name1.
              ENDIF.
            ENDIF.
    *       Sales order status
            CALL METHOD me->get_status
              EXPORTING
                im_so     = wa_output-sales_doc
              IMPORTING
                ex_status = wa_output-so_status.
            APPEND wa_output TO ex_output.
            CLEAR wa_output.
            CONTINUE.
          ENDIF.
    *     Ship-to code/party and delivery document
          LOOP AT im_dlv_tab ASSIGNING <fs_dlv_tab> WHERE vgbel = <fs_sales_tab>-vbeln.
            CLEAR: lv_flag1.
            wa_output-ship_to_code = <fs_dlv_tab>-kunnr.   "Ship-to code
            wa_output-del_doc      = <fs_dlv_tab>-vbeln.   "Delivery document
    *       Ship-to description
            READ TABLE im_desc_tab ASSIGNING <fs_desc_tab> WITH KEY kunnr = <fs_dlv_tab>-kunnr.
            IF sy-subrc = 0.
              wa_output-ship_to_desc = <fs_desc_tab>-name1.
            ENDIF.
    *       Sales order and delivery order status
            CALL METHOD me->get_status
              EXPORTING
                im_so     = wa_output-sales_doc
                im_do     = wa_output-del_doc
              IMPORTING
                ex_status = wa_output-so_status.
    *       Billing document
            LOOP AT im_bill_tab ASSIGNING <fs_bill_tab> WHERE vbelv   = <fs_dlv_tab>-vbeln
                                                          AND vbtyp_n =  'M'.
              CLEAR lv_flag1.
              IF lv_vbelv    = <fs_bill_tab>-vbelv AND
                 lv_bill_doc = <fs_bill_tab>-vbeln.
                CONTINUE.
              ENDIF.
              lv_vbelv    = <fs_bill_tab>-vbelv.
              lv_bill_doc = <fs_bill_tab>-vbeln.
              wa_output-bill_doc = <fs_bill_tab>-vbeln.    "Billing document
              MOVE 'X' TO lv_flag1.
              APPEND wa_output TO ex_output.
              CLEAR: wa_output-ship_to_code, wa_output-del_doc,
                     wa_output-so_status, wa_output-bill_doc.
              EXIT.
            ENDLOOP.
            IF lv_flag1 = 'X'.
              CONTINUE.
            ELSE.
              APPEND wa_output TO ex_output.
              CLEAR: wa_output-ship_to_code, wa_output-del_doc,
                     wa_output-ship_to_desc, wa_output-so_status.
            ENDIF.
          ENDLOOP.
        ENDLOOP.
        SORT ex_output BY sales_doc.
      ENDMETHOD.                    "combine_data
    * METHOD get_status
      METHOD get_status.
        FIELD-SYMBOLS: <fs_status>    LIKE LINE OF gt_status,
                       <fs_status_do> LIKE LINE OF gt_status_do.
    */Check the current stage of a given sales order in descending order
    * starting with the shipment status
        READ TABLE gt_status_do ASSIGNING <fs_status_do> WITH KEY vbeln = im_do
                                                                          BINARY SEARCH.
        IF sy-subrc = 0.
    *     Shipment/dispatch status
          IF <fs_status_do>-trsta = 'B' OR
             <fs_status_do>-trsta = 'C'.
            ex_status = 'SH'.
    *     Invoice status
          ELSEIF <fs_status_do>-fkstk = 'B' OR
                 <fs_status_do>-fkstk = 'C'.
            ex_status = 'IN'.
    *     Picking status
          ELSEIF <fs_status_do>-kostk = 'B' OR
                 <fs_status_do>-kostk = 'C'.
            ex_status = 'PS'.
          ENDIF.
        ENDIF.
        IF ex_status IS INITIAL.
          READ TABLE gt_status ASSIGNING <fs_status> WITH KEY vbeln = im_so
                                                                      BINARY SEARCH.
          IF sy-subrc = 0.
    *       Delivery order status
            IF <fs_status>-lfstk = 'B' OR
               <fs_status>-lfstk = 'C'.
              ex_status = 'DO'.
    *       Credit released
            ELSEIF <fs_status>-cmgst = 'A' OR
                   <fs_status>-cmgst = 'D'.
              ex_status = 'CR'.
    *       Credit hold
            ELSEIF <fs_status>-cmgst = 'B' OR
                   <fs_status>-cmgst = 'C'.
              ex_status = 'CH'.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDMETHOD.                    "get_status
    ENDCLASS.                    "lcl_process_data IMPLEMENTATION
    *       CLASS lcl_alv_routines IMPLEMENTATION
    CLASS lcl_alv_routines IMPLEMENTATION.
    * METHOD build_fieldcat
      METHOD build_fieldcat.
        REFRESH: gt_fieldcat.
        CLEAR wa_fieldcat.
        DEFINE m_fieldcat.
          add 1 to wa_fieldcat-col_pos.
          wa_fieldcat-fieldname   = &1.
          wa_fieldcat-tabname     = &2.
          wa_fieldcat-coltext     = &3.
          wa_fieldcat-outputlen   = &4.
          wa_fieldcat-fix_column  = &5.
          wa_fieldcat-just        = &6.
          wa_fieldcat-do_sum      = &7.
          wa_fieldcat-emphasize   = &8.
          wa_fieldcat-hotspot     = &9.
          append wa_fieldcat to gt_fieldcat.
        END-OF-DEFINITION.
        IF wa_column-fname = 'SO_STATUS'.
          m_fieldcat 'CR_HOLD'         'GT_STATUS_HISTORY'  text-002  '50' 'X' '' '' '' ''.
          m_fieldcat 'CR_REL_ON'       'GT_STATUS_HISTORY'  text-003  '18' 'X' '' '' '' ''.
          m_fieldcat 'CR_REL_AT'       'GT_STATUS_HISTORY'  text-004  '18' 'X' '' '' '' ''.
          m_fieldcat 'DO_CREATED_ON'   'GT_STATUS_HISTORY'  text-005  '13' 'X' '' '' '' ''.
          m_fieldcat 'DO_CREATED_TIME' 'GT_STATUS_HISTORY'  text-030  '15' 'X' '' '' '' ''.
          m_fieldcat 'PICKED_ON'       'GT_STATUS_HISTORY'  text-006  '12' 'X' '' '' '' ''.
          m_fieldcat 'PICKED_TIME'     'GT_STATUS_HISTORY'  text-031  '12' 'X' '' '' '' ''.
          m_fieldcat 'INV_CREATED_ON'  'GT_STATUS_HISTORY'  text-007  '15' 'X' '' '' '' ''.
          m_fieldcat 'DISPATCHED_ON'   'GT_STATUS_HISTORY'  text-008  '13' 'X' '' '' '' ''.
          m_fieldcat 'DISPATCHED_AT'   'GT_STATUS_HISTORY'  text-009  '13' 'X' '' '' '' ''.
        ELSEIF wa_column-fname = 'BILL_DOC'.
          m_fieldcat 'PODAT'          'GT_CONFIRMATION'    text-010  '17' 'X' '' '' '' ''.
          m_fieldcat 'POTIM'          'GT_CONFIRMATION'    text-011  '17' 'X' '' '' '' ''.
        ELSE.
          m_fieldcat 'CREATION_DATE' 'GT_OUTPUT' text-012 '10' 'X' '' '' '' ''.
          m_fieldcat 'CREATION_TIME' 'GT_OUTPUT' text-013 '10' 'X' '' '' '' ''.
          m_fieldcat 'SALES_DOC'     'GT_OUTPUT' text-014 '10' 'X' '' '' 'X' 'X'.
          m_fieldcat 'CUST_CODE'     'GT_OUTPUT' text-015 '16' 'X' '' '' '' ''.
          m_fieldcat 'CUST_DESC'     'GT_OUTPUT' text-016 '40' 'X' '' '' '' ''.
          m_fieldcat 'SHIP_TO_CODE'  'GT_OUTPUT' text-017 '15' 'X' '' '' '' ''.
          m_fieldcat 'SHIP_TO_DESC'  'GT_OUTPUT' text-018 '40' 'X' '' '' '' ''.
          m_fieldcat 'PO_NUM'        'GT_OUTPUT' text-019 '24' 'X' '' '' '' ''.
          m_fieldcat 'DOC_TYPE'      'GT_OUTPUT' text-020 '16' 'X' '' '' '' ''.
          m_fieldcat 'REQ_DLV_DATE'  'GT_OUTPUT' text-021 '21' 'X' '' '' '' ''.
          m_fieldcat 'SO_STATUS'     'GT_OUTPUT' text-022 '09' 'X' '' '' 'C400' ''.
          m_fieldcat 'CREATED_BY'    'GT_OUTPUT' text-023 '13' 'X' '' '' '' ''.
          m_fieldcat 'DEL_DOC'       'GT_OUTPUT' text-024 '18' 'X' '' '' '' ''.
          m_fieldcat 'BILL_DOC'      'GT_OUTPUT' text-025 '11' 'X' '' '' 'C600' ''.
        ENDIF.
      ENDMETHOD.                    "build_fieldcat
    * METHOD popup_routines
      METHOD popup_routines.
        READ TABLE im_column INDEX 1 INTO wa_column.
        FIELD-SYMBOLS: <fs_status> LIKE LINE OF gt_status.
        DATA: lv_datum TYPE syst-datum,
              lv_uzeit TYPE syst-uzeit.
        CLEAR: wa_status_history, lv_datum, lv_uzeit.
        REFRESH gt_status_history.
    */Popup routine if user clicked on the SO status
        IF wa_column-fname = 'SO_STATUS'.
          CALL METHOD me->get_domain_values
            EXPORTING
              im_tabname    = 'VBUK'
              im_fieldname  = 'CMGST'
            IMPORTING
              ex_values_tab = gt_domain_val.
    *     Credit hold
          READ TABLE gt_status ASSIGNING <fs_status> WITH KEY vbeln = im_output-sales_doc.
          IF sy-subrc = 0.
            wa_status_history-cr_hold = <fs_status>-cmgst.
          ENDIF.
          READ TABLE gt_domain_val INTO wa_domain_val WITH
                                    KEY domvalue_l = wa_status_history-cr_hold
                                    TRANSPORTING ddtext.
          IF sy-subrc = 0.
            wa_status_history-cr_hold = wa_domain_val-ddtext.
          ENDIF.
    *     Credit released date and time
          SELECT SINGLE udate utime
            FROM cdhdr
            INTO (lv_datum, lv_uzeit)
           WHERE objectid = im_output-sales_doc
             AND tcode    = 'VKM3'.
          IF sy-subrc = 0.
            WRITE lv_datum TO wa_status_history-cr_rel_on
            USING EDIT MASK '__/__/____'.
            CLEAR lv_datum.
            WRITE lv_uzeit TO wa_status_history-cr_rel_at
            USING EDIT MASK '__:__:__'.
            CLEAR lv_uzeit.
          ENDIF.
    *     DO creation date and time
          IF NOT im_output-del_doc IS INITIAL.
            SELECT SINGLE erdat erzet
              FROM likp
              INTO (lv_datum, lv_uzeit)
             WHERE vbeln = im_output-del_doc.
            IF sy-subrc = 0.
              WRITE lv_datum TO wa_status_history-do_created_on
              USING EDIT MASK '__/__/____'.
              CLEAR lv_datum.
              WRITE lv_uzeit TO wa_status_history-do_created_time
              USING EDIT MASK '__:__:__'.
              CLEAR lv_uzeit.
            ENDIF.
    *       Picking date and time
            SELECT SINGLE bdatu bzeit
              FROM ltak
              INTO (lv_datum, lv_uzeit)
             WHERE vbeln = im_output-del_doc.
            IF sy-subrc = 0.
              WRITE lv_datum TO wa_status_history-picked_on
              USING EDIT MASK '__/__/____'.
              CLEAR lv_datum.
              WRITE lv_uzeit TO wa_status_history-picked_time
              USING EDIT MASK '__:__:__'.
              CLEAR lv_uzeit.
            ENDIF.
          ENDIF.
    *     Invoice created on
          SELECT SINGLE erdat
            FROM vbrk
            INTO lv_datum
           WHERE vbeln = im_output-bill_doc.
          WRITE lv_datum TO wa_status_history-inv_created_on
          USING EDIT MASK '__/__/____'.
          CLEAR lv_datum.
    *     Dispatched on and dispatched at
          SELECT SINGLE tknum
            FROM vttp
            INTO vttp-tknum
           WHERE vbeln = im_output-del_doc.
          IF sy-subrc = 0.
            SELECT SINGLE dtabf uzabf
              FROM vttk
              INTO (lv_datum, lv_uzeit)
             WHERE tknum = vttp-tknum.
            WRITE lv_datum TO wa_status_history-dispatched_on
            USING EDIT MASK '__/__/____'.
            CLEAR lv_datum.
            WRITE lv_uzeit TO wa_status_history-dispatched_at
            USING EDIT MASK '__:__:__'.
            CLEAR lv_uzeit.
          ENDIF.
          APPEND wa_status_history TO gt_status_history.
          ex_status_history[] = gt_status_history[].
          CLEAR wa_status_history.
    */Popup routine if the user clicked on the billing document
        ELSEIF wa_column-fname = 'BILL_DOC'.
          IF NOT im_output-del_doc IS INITIAL.
            SELECT SINGLE podat potim
              FROM likp
              INTO (wa_confirmation-podat, wa_confirmation-potim)
             WHERE vbeln = im_output-del_doc.
            APPEND wa_confirmation TO gt_confirmation.
            ex_confirmation[] = gt_confirmation[].
            CLEAR wa_confirmation.
          ENDIF.
        ENDIF.
      ENDMETHOD.                    "popup_routines
    * METHOD get_domain_values
      METHOD   get_domain_values.
        CALL FUNCTION 'DDIF_FIELDINFO_GET'
          EXPORTING
            tabname              = im_tabname
            fieldname            = im_fieldname
            langu                = sy-langu
    *       LFIELDNAME           = ' '
    *       ALL_TYPES            = ' '
    *       GROUP_NAMES          = ' '
    *       UCLEN                =
    *     IMPORTING
    *       X030L_WA             =
    *       DDOBJTYPE            =
    *       DFIES_WA             =
    *       LINES_DESCR          =
          TABLES
            dfies_tab            = lt_dfies_tab
    *       FIXED_VALUES         =
    *     EXCEPTIONS
    *       NOT_FOUND            = 1
    *       INTERNAL_ERROR       = 2
    *       OTHERS               = 3
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        READ TABLE lt_dfies_tab INDEX 1 INTO wa_dfies_tab
                                        TRANSPORTING domname.
        CALL FUNCTION 'GET_DOMAIN_VALUES'
           EXPORTING
             domname               = wa_dfies_tab-domname
    *       TEXT                  = 'X'
    *       FILL_DD07L_TAB        = ' '
           TABLES
             values_tab            = ex_values_tab
    *       VALUES_DD07L          =
    *     EXCEPTIONS
    *       NO_VALUES_FOUND       = 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.
      ENDMETHOD.                    "get_domain_values
    ENDCLASS.                    "lcl_alv_routines IMPLEMENTATION
    *       CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
    * METHOD handle_double_click
      METHOD handle_double_click.
        IF e_column = 'SO_STATUS' OR
           e_column = 'BILL_DOC'.
          CREATE OBJECT: o_lcl_alv_routines.
          CLEAR: wa_output.
          REFRESH: gt_fieldcat,
                   gt_column,
                   gt_status_history,
                   gt_confirmation.
          MOVE: e_column-fieldname TO wa_column-fname,
                e_column-hierlevel TO wa_column-level.
          APPEND wa_column TO gt_column.
    *     Get record based on what the user clicked
          READ TABLE gt_output INDEX e_row-index INTO wa_output.
    *     Build fieldcatalog depending on what the user clicked
          CALL METHOD o_lcl_alv_routines->build_fieldcat.
    *     Call popup routine/s
          CALL METHOD o_lcl_alv_routines->popup_routines
            EXPORTING
              im_column         = gt_column
              im_output         = wa_output
            IMPORTING
              ex_status_history = gt_status_history
              ex_confirmation   = gt_confirmation.
          CALL METHOD me->create_detail_list
            EXPORTING
              im_column       = gt_column
              im_status       = gt_status_history
              im_confirmation = gt_confirmation.
        ENDIF.
      ENDMETHOD.                    "handle_double_click
    * METHOD handle_close
      METHOD handle_close.
        CALL METHOD sender->set_visible
          EXPORTING
            visible = space.
      ENDMETHOD.                    "handle_close
    * METHOD handle_hotspot_click
      METHOD handle_hotspot_click.
        READ TABLE gt_output INDEX e_row_id INTO wa_output.
        IF NOT wa_output-sales_doc IS INITIAL
           AND e_column_id = 'SALES_DOC'.
          SET PARAMETER ID 'AUN' FIELD wa_output-sales_doc.
          CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDMETHOD.                    "handle_hotspot_click
    * METHOD create_detail_list
      METHOD create_detail_list.
        DATA: lv_caption(200) TYPE c.
        CLEAR wa_column.
    *   Create popup window
        CREATE OBJECT dialogbox_container
            EXPORTING
              top = 100
              left = 150
              lifetime = cntl_lifetime_dynpro
              caption = lv_caption
              width = 800
              height = 200.
        CREATE OBJECT grid2
            EXPORTING i_parent = dialogbox_container.
    *   Trigger event when user closes the popup window
        SET HANDLER event_receiver->handle_close FOR dialogbox_container.
        READ TABLE im_column INDEX 1 INTO wa_column.
    *   Display popup window
        IF wa_column-fname = 'SO_STATUS'.
          gs_layout-grid_title = text-026.
          CALL METHOD grid2->set_table_for_first_display
           EXPORTING
    *        i_structure_name = 'T_OUTPUT'
             is_layout        = gs_layout
           CHANGING
             it_outtab        = gt_status_history
             it_fieldcatalog  = gt_fieldcat.
        ELSEIF wa_column-fname = 'BILL_DOC'.
          gs_layout-grid_title = text-027.
          CALL METHOD grid2->set_table_for_first_display
           EXPORTING
    *        i_structure_name = 'T_OUTPUT'
             is_layout        = gs_layout
           CHANGING
             it_outtab        = gt_confirmation
             it_fieldcatalog  = gt_fieldcat.
        ENDIF.
        CALL METHOD cl_gui_control=>set_focus
          EXPORTING
            control = grid2.
      ENDMETHOD.                    "create_detail_list
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    * START-OF-SELECTION                           *
    START-OF-SELECTION.
      DATA: o_lcl_get_data TYPE REF TO lcl_get_data.
      CREATE OBJECT o_lcl_get_data.
      CALL METHOD o_lcl_get_data->get_sales_docs.
    * END-OF-SELECTION                             *
    END-OF-SELECTION.
      CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS '100'.
      SET TITLEBAR  'TITLE100'.
      DATA: o_lcl_alv_routines TYPE REF TO lcl_alv_routines,
            gv_text            TYPE string,
            gv_name1           TYPE kna1-name1,
            gv_date_low(10)    TYPE c,
            gv_date_high(10)   TYPE c.
      CREATE OBJECT o_lcl_alv_routines.
      g_repid = sy-repid.
      IF custom_container IS INITIAL.
        CREATE OBJECT custom_container
          EXPORTING
            container_name = gv_container
          EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc NE 0.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = text-028.
        ENDIF.
        CREATE OBJECT grid1
          EXPORTING
            i_parent = custom_container.
    *   Build fieldcatalog for initial display
        CALL METHOD o_lcl_alv_routines->build_fieldcat.
        SELECT SINGLE name1
          FROM kna1
          INTO gv_name1
         WHERE kunnr = p_kunnr.
        WRITE: s_erdat-low  TO gv_date_low  USING EDIT MASK '__/__/____',
               s_erdat-high TO gv_date_high USING EDIT MASK '__/__/____'.
        CONCATENATE: gv_name1 'from:' gv_date_low '-' gv_date_high
               INTO gv_text
          SEPARATED BY space.
        gs_layout-grid_title = gv_text.
    *   Display initial window
        CALL METHOD grid1->set_table_for_first_display
          EXPORTING
    *        i_structure_name = ''
            is_layout        = gs_layout
          CHANGING
            it_outtab        = gt_output
            it_fieldcatalog  = gt_fieldcat.
        CREATE OBJECT event_receiver.
    *   Trigger event when user double clicks initial window
        SET HANDLER event_receiver->handle_double_click FOR grid1.
    *   Trigger event when user clicks hotspot field
        SET HANDLER event_receiver->handle_hotspot_click FOR grid1.
      ENDIF.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = grid1.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      save_ok = ok_code.
      CASE save_ok.
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
          CALL METHOD custom_container->free.
          CALL METHOD cl_gui_cfw=>flush.
          IF sy-subrc <> 0.
            CALL FUNCTION 'POPUP_TO_INFORM'
              EXPORTING
                titel = g_repid
                txt2  = sy-subrc
                txt1  = text-029.
          ENDIF.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT

  • How to Join VBRK, VBRP and BSEG

    Dear Guys
    I have Billing No from VBRP/VBRK and want to join these tables with BSEG to pick Accounting Doc No.
    How to Join these tables.
    Thanks

    Hi,
    What you can do is to use FM AC_DOCUMENT_RECORD. Please check my example below:
    MOVE: 'VBRK'          TO lv_awtyp,
                  wa_vbrk-vbeln TO lv_awref,
                  '2007'      TO lv_aworg.
            CALL FUNCTION 'AC_DOCUMENT_RECORD'
              EXPORTING
                i_awtyp            = lv_awtyp
                i_awref            = lv_awref
                i_aworg            = lv_aworg
    *           I_AWSYS            = ' '
    *           I_AWTYP_INCL       = ' '
    *           I_AWTYP_EXCL       = ' '
    *           I_BUKRS            = ' '
    *           I_VALUTYP          = '0'
                x_dialog           = ''
              TABLES
                t_documents        = lt_documents
              EXCEPTIONS
                no_reference       = 1
                no_document        = 2
                OTHERS             = 3
            IF sy-subrc <> 0.
              MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            ENDIF.
    Hope it helps...
    P.S. Please award points if it helps...

  • I want to join the table vbrk,vbrp,konv but konv is cluster table .

    Hi
       konv is the cluster table . so   I  want to join the table vbrk,vbrp,konv and fields are vbeln, knumv is possible .
    if it isn't possible. what is the another method output is doc. no.(vbrp-vbeln) condition doc. no.(vbrk-knumv) , condition(konv-kschl), tax rate(konv-mwsk1), quantitty(vbrp-fkimg) .reply pls... as soon as possible..

    hi
    good
    1) Open
        Select
               Mard~matnr
               Makt~maktx
          From Makt
          Inner Join Mard
          on    Maktmatnr = Mardmatnr
          Where Makt~Spras = SY-LANGU
    2) Native Oracle
          SELECT Mard.matnr,
                 Makt.maktx
          From Makt, Mard
          Where Makt.mandt = Mard.mandt
            And Makt.matnr = Mard.matnr
            And Makt.mandt = :SY-MANDT
            And Makt.spras = :SY-LANGU
    3) KONV is Cluster - BAD LUCK!
        Select VBRK~VBELN
               VBRP~POSNR
               KONV~KSCHL
               KONV~KWERT    
          From ( VBRK Inner Join VBRP
                 On VBRKVBELN = VBRPVBELN )
               Inner Join KONV
                 On  VBRKKNUMV = KONVKNUMV
                 And VBRPPOSNR = KONVKPOSN
    4) KONV is Cluster - BAD LUCK!
        Select KONV~KNUMV
               KONV~KPOSN
               KONV~KSCHL
               KONV~KWERT    
          From KONV
          Where KONV~KNUMV in (
               Select VBRK~KNUMV
                 From VBRK Inner Join VBRP
                 On VBRKVBELN = VBRPVBELN
                Where VBRKKNUMV = KONVKNUMV
                  And VBRPPOSNR = KONVKPOSN
    5) Open
             Select VBRP~MATNR
                    Sum( VBRP~NETWR )
              From VBRP
              Group By VBRP~MATNR 
    6) Native Oracle        
             Select VBRP.MATNR ,
                    Sum( VBRP.NETWR )
              From VBRP
              Where mandt = :sy-mandt
              Group By VBRP.MATNR         
    7) Native Oracle
             Select VBRP.MATNR ,
                    Count( VBRP.NETWR ),
                    Sum( VBRP.NETWR )
              From VBRP
              Where mandt = :sy-mandt
              Group By VBRP.MATNR    
    8) Open
             Select VBRP~MATNR
                    makt~maktx
                    Sum( VBRP~NETWR )
              From VBRP inner Join MAKT
                On VBRPMATNR = MAKTMATNR
              Where MAKT~SPRAS = SY-LANGU
              Group By VBRPMATNR maktmaktx      
    9) Native Oracle         
             Select VBRP.MANDT,
                    VBRP.MATNR,
                    MAKT.MAKTX,
                    Sum( VBRP.NETWR )
              From VBRP , MAKT
             Where  VBRP.MANDT = MAKT.MANDT
               And  VBRP.MATNR = MAKT.MATNR
               And  MAKT.SPRAS = :SY-LANGU
              Group By VBRP.MANDT, VBRP.MATNR, MAKT.MAKTX   
    10) Open          
         SELECT EKET~EBELN 
                EKET~EINDT 
                EKET~WAMNG 
                EKET~WEMNG 
          From  ( ekko INNER JOIN ekpo
                  ON  ekkomandt = ekpomandt
                  AND ekkoebeln = ekpoebeln
                INNER JOIN eket
                ON  ekpomandt = eketmandt
                AND ekpoebeln = eketebeln
                AND ekpoebelp = eketebelp
                AND EKET~WAMNG > 0
                AND EKETWAMNG <> EKETWEMNG
         Where EKPO~MATNR = 'NB220'
           And EKPO~WERKS  In ('P001', 'P004', 'L004')
           And EKKO~BSTYP = 'F'
           And EKKO~BSART = 'UB'
           And EKPO~ELIKZ <> 'X'
           And EKKO~LOEKZ <> 'X'     
    11) Native Oracle      
         SELECT EKET.EBELN, 
                EKET.EINDT, 
                EKET.WAMNG, 
                EKET.WEMNG 
          FROM  ( ekko INNER JOIN ekpo
                  ON  ekko.mandt = ekpo.mandt
                  AND ekko.ebeln = ekpo.ebeln
                INNER JOIN eket
                ON  ekpo.mandt = eket.mandt
                AND ekpo.ebeln = eket.ebeln
                AND ekpo.ebelp = eket.ebelp
                AND EKET.WAMNG > 0
                AND EKET.WAMNG <> EKET.WEMNG
         Where EKPO.MATNR = 'NB220'
           And EKPO.WERKS  In ('P001', 'P004', 'L004')
           And EKKO.BSTYP = 'F'
           And EKKO.BSART = 'UB'
           And EKPO.ELIKZ <> 'X'
           And EKKO.LOEKZ <> 'X'
    thanks
    mrutyun^

  • Vbrk and Vbrp tables performance problem

    Hi all,
    The below query is taking lot of time in QAS i need to decrease the time without affecting the logic.....
      SELECT vbrk~kunag
           vbkd~bstkd
           vbkd~bstdk
           INTO TABLE c_tab_po FROM vbrp
           INNER JOIN vbrk ON vbrkmandt = vbrpmandt AND vbrk~vbeln =
           vbrp~vbeln
           INNER JOIN vbkd ON vbkdmandt = vbrpmandt AND vbkd~vbeln =
           vbrp~aubel
                              AND vbkd~posnr = con_zposnr
           WHERE vbrp~vbeln EQ nast-objky.
      DELETE ADJACENT DUPLICATES FROM c_tab_po COMPARING ALL FIELDS.
    *Getting the other Invoices based on the customer PO number
      IF c_tab_po[] IS NOT INITIAL.
        SELECT
        vbrk~kunag
        vbkd~bstkd
        vbkd~bstdk
        vbkdposex_e vbrkvkorg
        vbrpvbeln vbrpposnr vbrp~erdat
               vbpakunnr vbrpaubel vbrpaupos vbakerdat
               vbrpmatnr vbrkmwsbk vbrp~netwr
               vbrkvaldt vbrkzterm vbrk~vbtyp
                INTO TABLE g_tab_invoice FROM vbrp
                INNER JOIN vbrk ON vbrkmandt = vbrpmandt AND vbrk~vbeln =
                vbrp~vbeln
                INNER JOIN vbkd ON vbkdmandt = vbrpmandt AND vbkd~vbeln =
                vbrp~aubel
                               AND vbkd~posnr = con_zposnr
                INNER JOIN vbpa ON vbpamandt = vbrpmandt AND vbpa~vbeln =
                vbrp~aubel
                               AND vbpaposnr = con_zposnr AND vbpaparvw =
                               con_parvw
                INNER JOIN vbak ON vbakmandt = vbakmandt AND vbak~vbeln =
                vbrp~aubel
                FOR ALL entries IN c_tab_po
                    WHERE vbrk~kunag EQ c_tab_po-kunag AND
                    vbkd~bstkd EQ c_tab_po-bstkd AND
                    vbkd~bstdk EQ c_tab_po-bstdk.
      ENDIF.

    Hi Younus,
    First join seems to be oku2026
    But you are querying Db tables multiple times to avoid this.
    Fetch the fields
    vbkdposex_e vbrkvkorg
    vbrpvbeln vbrpposnr vbrp~erdat
    vbrpaubel vbrpaupos
    vbrpmatnr vbrkmwsbk vbrp~netwr
    vbrkvaldt vbrkzterm vbrk~vbtyp
    in the first join itself.
    SELECT vbrk~kunag
    vbkd~bstkd
    vbkd~bstdk
    vbkd~posex_e vbrk~vkorg
    vbrp~vbeln vbrp~posnr vbrp~erdat
    vbrp~aubel vbrp~aupos
    vbrp~matnr vbrk~mwsbk vbrp~netwr
    vbrk~valdt vbrk~zterm vbrk~vbtyp
    INTO TABLE c_tab_po FROM vbrp
    INNER JOIN vbrk ON vbrk~mandt = vbrp~mandt AND vbrk~vbeln =
    vbrp~vbeln
    INNER JOIN vbkd ON vbkd~mandt = vbrp~mandt AND vbkd~vbeln =
    vbrp~aubel
    AND vbkd~posnr = con_zposnr
    WHERE vbrp~vbeln EQ nast-objky.
    then Just join VBPA & VBAK and get required data.
    Thanks,
    Sudha

  • I want to join the table vbrk,vbrp,konv and fields are vbeln, knumv.

    i want to join the table vbrk,vbrp,konv and fields are vbeln, knumv is possible .
    if it isn't possible. what is the another method output is doc. no.(vbrp-vbeln) condition doc. no.(vbrk-knumv) , condition(konv-kschl), tax rate(konv-mwsk1), quantitty(vbrp-fkimg) .reply pls... as soon as possible..

    Hi..
    This is the Join :
    SELECT VBAKVBELN VBRKKNUMV
                 VBRP~FKIMG
                 KONV-KSCHL  KONV~MWSK`
           FROM VBRK
           INNER JOIN VBRP
           ON VBRKVBELN = VBRPVBELN
           INNER JOIN KONV
           ON KONVKNUMV = VBRKKNUMV
           INTO TABLE <ITAB>
    WHERE <CONDITION>.
    REWARD IF HELPFUL.

  • How to create analytic view with tables  VBRK VBRP KONV ?

    Hi Gurus,
    What is the best way to combine in a analytic view tables VBRK VBRP and KONV for better optimization or
    how to make the relationship tables VBRK VBRP KONV with better performance in Hana Studio ?
    This analytic view should be used in a calculation view to the final calculations.
    Thanks !

    Hi Rogerio,
    Greetings.
    Basically , when you design your analytic views , while designing your data foundation , you can directly join the tables with the corresponding key attributes . Analytic views are capable of optimizing the join operation when we access the view.Logic of joining is purely depends on your business requirement
    Sreehari.

  • Reporting on master data customer and bad performances : any workaround ?

    Hello,
    I've been asked to investiguate on bad performances encountered when performing reporting
    on the specific master data zcustomer.
    Basically this master data has a quite similar design that 0customer, there are 96000 entries in the master data table.
    A simple query has been developed : the reporting is done on the master data zcustomer and its attributes : no key figure, no calculation, no restriction ...
    Nevertheless, the query can not be executed .. the query runs around 10 minute in rsrt, then the private memory is exhausted and then a short dump is generated.
    I tried to buid a very simple query on 0customer, this time, without the attributes ... and it took more than 30 sec before I get the results.
    I checked the queries statistics :
    3.x Analyzer Server 10 sec
    OLAP: Read Texts : 20 sec
    How is it that it is so long to performthe reporitng on those master data, while in the same time If i try to display the content in SAP by choosing "maintain master data", I have an immediate answer.
    I there any workaround ?
    Any help would be really appreciated.
    thank you.
    Raoul

    Hi.
    How much data have you got in the cube?
    If you make no restrictions, you are asking the system to return data for all 96.000 customers. That is one thing that might take some time.
    Also, using the attributes of this customer object, fx making selection or displaying several of them, means that the system has to run through the 96.000 records in masterdata to know what goes where in the report.
    When you display the masterdata, you are by default displaying just the 250 or so first hits, and you are not joining against any cube or sorting the result set, so that is fast.
    You should make some kind of restriction on other things than zcustomer (time, org.unit, version, etc, to limit the dataset from the cube, but also a restriction on one of the zcustomer attribs, with an index for that maybe, and performance should improve.
    br
    Jacob

  • Bad Performance in a query into table BKPF

    Hi forum i have a really problem in the second query under the table
    BKPF.. some body cans help me, please
    *THIS IS THE QUERY UNDER MSEG
      SELECT tmsegmblnr tmkpfbudat tmsegbelnr tmsegbukrs tmseg~matnr
             tmsegebelp tmsegdmbtr tmsegwaers tmsegwerks tmseg~lgort
             tmsegmenge tmsegkostl
      FROM mseg AS tmseg JOIN mkpf AS tmkpf ON tmsegmblnr = tmkpfmblnr
      INTO CORRESPONDING FIELDS OF TABLE it_docs
      WHERE
        tmseg~bukrs IN se_bukrs AND
        tmkpf~budat IN se_budat AND
        tmseg~mjahr = d_gjahr AND
        ( tmsegbwart IN se_bwart AND tmsegbwart IN (201,261) ).
      IF sy-dbcnt > 0.
    I CREATE AWKEY FOR CONSULTING BKPF
        LOOP AT it_docs.
          CONCATENATE it_docs-mblnr d_gjahr INTO it_docs-d_awkey.
          MODIFY it_docs.
        ENDLOOP.
    THIS IS THE QUERY WITH BAD BAD PERFOMANCE
    I NEED KNOW "BELNR" FOR GO TO THE BSEG TABLE
        SELECT belnr awkey
        FROM bkpf
        INTO CORRESPONDING FIELDS OF TABLE it_tmp
        FOR ALL ENTRIES IN it_docs
        WHERE
          bukrs = it_docs-bukrs AND
          awkey = it_docs-d_awkey AND
          gjahr = d_gjahr AND
          bstat = space .
    THNKS

    Hi Josue,
    The bad performance is because you're not specifying the primary keys of the table BKPF in your WHERE condition; BKPF usually is a big table.
    What you really need is to create a new index on database for table BKPF via the ABAP Dictionary on fields BUKRS, AWKEY, GJAHR & BSTAT. You'll find the performace of the program will significantly increase after the new index is activated. But I would talk to the Basis first to confirm they have no issues if you create a new index for BKPF on the database system.
    Hope this helps.
    Cheers,
    Sougata.

  • Relation field between table VBRK/VBRP and BSEG

    Can any body guide on the common fields between VBRK/ VBRP and BSEG, except field "assignment".

    Hi,
    If you know the accounting document number, Goto SE16. enter BSEG table and enter.
    Enter the accounting document number in selection screen. E.g 90000498.
    You will get multiple lines. E.g normal billing document(Not credit memo /debit memo)
    Customer information will be available in posting key 01 line (Header). And Item information will be avilable in Posting key 50 line.
    List of fields available in Header.
    Billing document number
    Customer
    Payment terms
    Amount.
    Company code
    Controlling area
    Reconciliation account number
    Assignment
    Item level information in Posting key 50.
    Material
    Plant
    Amount
    Tax amount
    Tax code
    As per my knowledge for reporting purpose we don't use BSEG  bcoz of performance issue.
    BKPF -  Accounting document Header
    BSID
    BSIS
    Regards,
    Chandra

  • Link betwwen KONA and VBRK/VBRP

    Hi
    please suggest me the link between KONA and VBRK/VBRP and
    KONP and VBRK/VBRP
    I want to give link of rebate agreement and invoice no/Inv Qty
    My requirement is I want a report where i can see Under one Rebate agreement ,how many Commercial  Invoice use
    e.g.  Rebate Agreement no -125 ( for 10 Rs / unit)
    I have created 10 Invoice for 10 qty each so accrual Amount is 10* 10= 100
    I want such report where for agreement No 125- 10 Invoice No should be reflected.
    I don't want to go into VBO2 and go to verification level that concept i know
    i want one report where i will see all
    Regards
    Hemant

    You can go via KONH - KONV to VBRP but you will have big performance issues especially with the KONV table when you enter the condition record number from KONH only.
    Much easier go to KONH enter your Agreement number. Get the KNUMH from your rebate agreement and enter it in Table S136. This will give you all the invoices associated with your rebate.
    Good Luck.

  • CMP 6.1 Entity bad performance.

    I'am using entity 1.1 EJB on WL 6.1 and facing very bad performances:
    around 150ms for an insert (i have 20 columns).
    When accessing an order interface to read 2 fields in a session bean method: around
    90 ms.
    I'am very disapointed and confused. What should I look up for
    to increase the performance ? Any important tuning or parameters ? Should I use EJB
    2.0 to have significant perf ?
    Thanks for any advice because we are thinking to switch all the application on stored
    procedures. A solution without Entity and fewer stateless session beans.
    My config:
    WL: 6.1 on Sun sparc
    SGBD: Sybase
    Entity: WebLogic 6.0.0 EJB 1.1 RDBMS (weblogic-rdbms11-persistence-600.dtd)
    Thanks

    Historically its hard to get good performance & scalability out of sybase
    without using stored procs. Using dynamic sql on sybase just doesnt do as
    well as procs. Oracle on the other hand can get very close to stored proc
    speed out of well written dynamic sql.
    As far as weblogic goes, my experience is the focus of their testing for db
    related stuff is Oracle, then DB2, then MSSQLServer. Sybase is usually last
    on the list.
    As far as the 6.1 cmp, haven't used it much, but because of these other
    things I would be cautious about using it with Sybase.
    Joel
    "Antoine Bas" <[email protected],> wrote in message
    news:3cc7cdcf$[email protected]..
    >
    I'am using entity 1.1 EJB on WL 6.1 and facing very bad performances:
    around 150ms for an insert (i have 20 columns).
    When accessing an order interface to read 2 fields in a session beanmethod: around
    90 ms.
    I'am very disapointed and confused. What should I look up for
    to increase the performance ? Any important tuning or parameters ? ShouldI use EJB
    2.0 to have significant perf ?
    Thanks for any advice because we are thinking to switch all theapplication on stored
    procedures. A solution without Entity and fewer stateless session beans.
    My config:
    WL: 6.1 on Sun sparc
    SGBD: Sybase
    Entity: WebLogic 6.0.0 EJB 1.1 RDBMS(weblogic-rdbms11-persistence-600.dtd)
    >
    Thanks

  • Bad performance when open a bi publisher report in excel

    We use bi publisher(xml publisher) to create a customized report. For a small report, user like it very much. But for a bigger report, users complain about the performance when they open the file.
    I know it is not a native excel file, that may cause the bad performance. So I ask my user to save it to a new file as a native excel format. The new file still worse than a normal excel file when we open it.
    I did a test. We try to save a bi publish report to excel format, the size shrink to 4Mb. But if we "copy all" and "Paste Special" value only to a new excel file, the size is only 1Mb.
    Do I have any way to improve that, users are complaining everyday. Thanks!
    I did a test today.
    I create a test report
    Test 1: Original file from BIP in EBS is 10Mb. We save it in my local disk, when we open the file, it takes 43 sec.
    Test 2: We save the file in native excel format, the file size is 2.28Mb, it takes 7 sec. to open.
    Test 3: We copy all cell and "PasteSpecial" to a new excel file with value only. The file size is 1.66Mb, it takes only 1 sec to open.
    Edited by: Rex Lin on 2010/3/31 下午 11:26

    EBS or Standalone BIP?
    If EBS see this thread for suggestions on performance tuning and hints and tips:
    EBS BIP Performance Tuning - Definitive Guide?
    Note also that I did end up rewriting my report as PL/SQL producing a csv file and have done with several large reports in BIP on EBS.
    Cheers,
    Dave

  • Bad performance updating purchase order (ME22N)

    Hello!
    Recently, we face bad performance updating purchase orders using transaction ME22N. The problem occurs since we implemented change documents for a custom table T. T is used to store additional data to purchase order positions using BAdIs ME_PROCESS_PO_CUST and ME_GUI_PO_CUST.
    I've created a change document C_T for T using transaction SCDO. The update module of the change document is triggered in the method POST of BAdI ME_PROCESS_PO_CUST.
    Checking transaction SM13, I recognized that the update requests of ME22n have status INIT for several minutes before they are processed. I also tried to exclude the call of the update module for change document C_T (in Method POST) - the performance problem still occurs!
    The problem only occurs with transaction ME22N, thus I assume that the reason is the new change document C_T.
    Thanks for your help!
    Greetings,
    Wolfgang

    I agree with vikram, we don't have enough information, even not a small hint on usage of this field, so which answer do you expect (The quality of an answer depends ...) This analysis must be executed on your system...
    From a technical point of view, the BAPI_PO_CHANGE has EXTENSIONIN table parameter, fill it using structure BAPI_TE_MEPOITEM[X] alreading containing CI_EKPODB (*) and CI_EKPODBX (**)
    Regards,
    Raymond
    (*) I guess you have used this include
    (**) I guess you forgot this one (same field names but data element always BAPIUPDATE)

  • Bad performance in web intelligence reports

    Hi,
    We use Business Objects with Web Intelligence documents and Crystal Reports.
    We are supporting bad performance when we use the reports specilly when we need to change the drill options
    Can someone telling me if exists some best practices to improve performance? What features should i look to?
                      Best Regards
                            João Fernandes

    Hi,
    Thank you for your interest. I know that this a issue with many variables because that i need information about anything that could cause bad performance.
    For bad performance i mean the time that we take running and refreshing reports data.
    We have reports with many lines but the performance is bad even when a few users are in the system
                                 Best Regards
                                         João Fernandes

Maybe you are looking for

  • How to Tell if the Song is iTunes Plus before purchase

    Sometimes I hear a song on the Internet radio and want to make a purchase via the iTunes Store. There is no search function in the actual iTunes Plus part of the store is there? If I search for the song I want to download at the regular store I used

  • Problem with window repaint and scrollbars in edit mode (LabVIEW 8.0.1)

    I am running LabVIEW 8.0.1 in Windows XP SP3.  For my main VI, I ran into a strange problem about 5 months ago.  The front panel window - in both edit mode and run mode - stopped repainting itself on the right side which is most visible when you scro

  • Server certificate

    Hi How to use "server certificate" to develop HTTPS or SSL proxy server.Can any one give me detail in steps.

  • Coherence with berkeley db environment configuration problem in weblogic

    Hi i am new to coherence and i developed a web application. in my app coherence is a cache and berkely db is a backend store. i configured the coherence-config.xml correctly as per the instructions in the oracle site.the problem is when i try to put

  • Adobe air 2.6 gpu font scaled down

    Hi, When i use the gpu to publish my adobe air 2.6 ios project, when i run it on iphone the font in the texfields is scale down twice is size, but online on the first time that i run the application, when i enter on differents area the font size is n