Joining VBAK and VBAP

Hi Guys,
Can you pls check the query and suggest best approch to improve the performance as its going for dump.
VBAP as 2,22,34,404
VBAK as 25,54,345
and
r_matnr as 96,000 records.
  SELECT vbapmatnr SUM( vbapkwmeng )
    FROM vbak INNER JOIN vbap ON vbakvbeln = vbapvbeln
    INTO TABLE t_xx
   WHERE audat BETWEEN w_pstdat AND w_inidat
     AND vkorg IN r_vkorg
     AND auart IN r_auart
     AND vbap~matnr IN r_matnr
     AND vbap~werks EQ p_werks
     AND vbap~pstyv IN s_pstyv
     GROUP BY vbap~matnr.
Regards,
Srinivas M

> Check for the View on VBAP AND VBAK that will help to increase the preformence
> instead of inner join
oh, a new option is recommended frequently in recent positing, after FAE is supported so much anymore.
BUT the View is only a dictionary defintion of a join, they are 100% identical on the database
There is not clear limit for the size of the ranges, usually in the order of 1000 or 2000. It will dump when whole resultings statement is above a limit, which is hard tto specify.
WHERE audat BETWEEN w_pstdat AND w_inidat
AND vkorg IN r_vkorg
AND auart IN r_auart
AND vbap~matnr IN r_matnr
AND vbap~werks EQ p_werks
AND vbap~pstyv IN s_pstyv
GROUP BY vbap~matnr.
This are actually several statements, which can be completely different. It depends which IN-Lists/Ranges are filled.
The join can react on that, it uses different accesses, if there are more conditions on vbak or
more vbap.
For the FAE you must programm two versions, one startung with vbak and one with vbak. And
you must determine which one will use. I doubt that you will better than the optimzer in the database.
Siegfried

Similar Messages

  • Performance problems selecting form vbak and vbap

    Hello,
    I am try to select data from the vbak and vbap databasetables. The tables have more than a million of entries. I tried my best with two related selectstatements and the 'FOR All ENTRIES' syntax. The query takes more than 30 minutes. Is there a more efficient way than the following query, for example an inner join?. Tanks.
    Regards, Lars.
    FORM firstselect.
       SELECT  kvkorg kvtweg kspart kauart k~kunnr
              kvsbed kaugru kvbeln kmandt
      FROM VBAK AS k
      INTO CORRESPONDING FIELDS OF TABLE t_outtab1
      WHERE  k~vkorg IN s_vkorg AND
             k~vtweg IN s_vtweg AND
             k~spart IN s_spart AND
             k~auart IN s_auart AND
             k~kunnr IN s_kunnr AND
             k~vsbed IN s_vsbed AND
             k~augru IN s_augru AND
             k~vbeln IN s_vbeln.
    ENDFORM.
    FORM secondselect.
         SELECT  pposnr pvstel p~werks
                  pabgru pmatnr p~kwmeng
                  pzzurmeng pvrkme pmandt pvbeln
          FROM VBAP AS p
          INTO CORRESPONDING FIELDS OF TABLE t_outtab2
              FOR ALL ENTRIES IN t_outtab1
          WHERE
              p~vstel IN s_vstel AND
              p~werks IN s_werks AND
              p~matnr IN s_matnr AND
              p~abgru IN s_abgru AND
             t_outtab1-mandt = p~mandt AND
              p~vbeln = t_outtab1-vbeln.
    ENDFORM.

    FORM firstselect.
    SELECT vkorg
           vtweg
           spart
           auart
           kunnr
           vsbed
           augru
           vbeln
           mandt
           FROM VBAK 
           INTO TABLE t_outtab1
    WHERE vkorg IN s_vkorg AND
    vtweg IN s_vtweg AND
    spart IN s_spart AND
    auart IN s_auart AND
    kunnr IN s_kunnr AND
    vsbed IN s_vsbed AND
    augru IN s_augru AND
    vbeln IN s_vbeln.
    ENDFORM.
    FORM secondselect.
    SELECT posnr
           vstel
           werks
           abgru
           matnr
           kwmeng
           zzurmeng
           vrkme
           mandt
          vbeln
      FROM VBAP TABLE t_outtab2
    FOR ALL ENTRIES IN t_outtab1
    WHERE  vbeln = t_outtab1-vbeln
    AND vstel IN s_vstel AND
    werks IN s_werks AND
    matnr IN s_matnr AND
    abgru IN s_abgru .
    ENDFORM.
    Hope this helps u.
    I will get u back with more answers.
    One more important thing see that the order which u r using in the select query is the same as that in the table this will affect the performs a lot.
    <i><b>The first field should be the vbeln and then see the order and change that first and the same order should be in the internal table taht u r defining also.
    If u do these things surely u can improve performance.</b></i>
    Message was edited by: Judith Jessie Selvi

  • Contract Sign Date from VBAK and VBAP and VEDA.

    Hi ,
    I need to fetch the Sales Document from VBAK and VBAP and VEDA with the contract sign date for sales document line item .
    Contract sign date is in selection screen as select options.
    Please let me know how to fetch the sales Document per line item from these 3 tables considering that A sales document could have many line items and each can have a different sign date.
    Thanks
    Sachin

    Hi,
    The link between all the tables VBAK, VBAP and VEDA is VBELN i.e sales document number.
    However, while fetching from VBAP and VEDA you would need to consider POSNR as well.
    As your ABAPer to code the logic using 'for all entries' method.
    Regards,
    Amit
    Edited by: Amit Iyer on Jun 23, 2011 12:28 PM

  • OBJNR is blank at VBAK and VBAP tables

    Dear collegues,
    There´s a strange situation on customer´s system. When end-user create a new quotation, the OBJNR field at VBAK and VBAP tables doesn´t fill itself, it remains blank. I believed that the field was filled when the document was saved. What´s wrong?
    Regards, Otávio.

    Hi,
    This might  be due to many reasons.Please check if there any dumps related to it in ST22/SM21.
    Also check if there any enough dialog/bckg work process to process the job.
    filling up takes more time depending on the no of records in the application tables.
    regards
    Nagaraju

  • Tables VBAK and VBAP

    Hi there!
    When i want to extract data ,partly related to header and partly related to item , what i do is, i give the conditions(header conditions like sales org.) for which i need data in VBAK and when i get the sales order numbers i exceute VBAP for these sales order to get item data....is this the correct way or is there a way to get the header as well as item data from the same table....Please suggest....

    Dear Swetha,
    If you want to pull data from a single table use T-code: SE16N.
    If you want to join multiple Tables then create a Query thrrough SQ00. You can select the required feild in this Query & generate a report based on required selection criteria..
    Hope this Helps..
    Thanks,
    Jignesh Mehta

  • Help needed for report on tables vbak and vbap

    Hello,
    I needed help in one of my work issues, this is my first project and Iam still learning. kindly help.
    I was asked to take erdat,vbeln,posnr from selection screen and compare it with the data already in tables vbap,vbak. If the data
    already exists and exception needs to be raised saying that the 'data exists',but if the data is not present in the tables the
    tables have to be updated. This has to be done using function module only.
    Then I have to write a REPORT calling the above function module and finally displaying the number of records updated and the
    list of them.
    I have started writing a function module:
    FUNCTION z_tableupdate.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(DATE) LIKE  VBAK-ERDAT DEFAULT SY-DATUM
    *"     VALUE(SALESORDERNO) LIKE  VBAK-VBELN
    *"     VALUE(ITEMNO) LIKE  VBAP-POSNR
    *"  EXPORTING
    *"     VALUE(EX_VBAP) LIKE  VBAP STRUCTURE  VBAP
    *"     VALUE(SYS) LIKE  SY-SYSID
    *"     VALUE(EX_VBAK) LIKE  VBAK STRUCTURE  VBAK
    *"  EXCEPTIONS
    *"      DATA_UPDATED
    *"      DATA_EXISTS
      SELECT * FROM vbak INTO vbak_wa WHERE erdat = date
                                        AND vbeln = salesorderno.
      ENDSELECT.
      SELECT * FROM vbap INTO vbap_wa WHERE posnr = itemno.
      ENDSELECT.
      IF sy-subrc EQ 0.
        ex_vbap = vbap_wa.
        ex_vbak = vbak_wa.
      ELSE.
        RAISE data_exists.
      ENDIF.
      sys = sy-sysid.
    ENDFUNCTION.
    How is the above code for function module, will this work??
    Now can I write a report to call the above function module and update the record?? if so, how to update ??? please help...Lots of thanks in advance.

    Hi
    Welcome to SDN forum
    Whay can't you write a simple report in SE38.
    why you are using Fun module
    Nothing wrong in it.
    But first become perfetc in reports in SE38 and then do using the fun modules
    write a simple select statement like
    SELECT AVBELN AERDAT BPOSNR BMATNR
    INTO TABLE ITAB
    FROM VBAK AS A JOIN VBAP ON
    AVBELN = BVBELN
    WHERE A~VBELN  IN  S_VBELN AND
                 A~ERDAT  IN  S_ERDAT AND
                 B~POSNR IN S_POSNR.
    IF SY-SUBRC <> O.
      WRITE: / 'No data found'.
    ENDIF.
    First write this in SE38 by defining a proper selection screen and internal tables
    then do as fun module
    see the doc for fun module
    Function Modules;
    Check this matter.
    Function Modules are Global ABAP programs created by SAP for reusable purpose.they have IMPORT,EXPORT and TABLE parameters, and EXCEPTIONS to through when error occurs.
    You can create them from TCode SE37.
    Go through the following doc:
    Function modules are cross-program, reusable procedures that are organized into function groups, and whose functions are implemented between the statements FUNCTION and ENDFUNCTION. Function modules and their interfaces are created in the Function Builder.
    Function Module Interfaces
    The parameter interface of a function module is defined in the Function Builder. It includes the definition of interface parameters and the specification of exceptions that can be triggered by a function module. The Function Builder automatically generates comment lines below the FUNCTION statement in the source code of the function module, which represent the interface of the function module with the following syntax:
    Syntax
    ... [IMPORTING parameters]
    [EXPORTING parameters]
    [CHANGING parameters]
    [TABLES table_parameters]
    [{RAISING|EXCEPTIONS} exc1 exc2 ...]
    The syntax and semantics of IMPORTING, EXPORTING, CHANGING, RAISING, and EXCEPTIONS mainly correspond to the definition of method interfaces with [CLASS-]METHODS. The additional option of defining table parameters using TABLES is obsolete.
    Interface parameters
    The interface parameters are defined on the relevant tab pages in the Function Builder.
    IMPORTING parameters are input parameters. When the function module is called, a suitable actual parameter must be specified for every non-optional input parameter. The content of the actual parameter is passed to the input parameter when the call is made. The content of an input parameter for which 'pass by reference' is defined cannot be changed in the function module.
    EXPORTING parameters are output parameters. When the function module is called, a suitable actual parameter can be specified for every output parameter. The content of an output parameter that is defined for 'pass by value' is transferred to the actual parameter if the function module is completed without errors. An output parameter that is defined for pass by reference is not initialized when the function module is called.
    CHANGING parameters are input and output parameters. When the function module is called, a suitable actual parameter must be specified for every non-optional input or output parameter. When the function module is called, the content of the actual parameter is passed to the input/output parameter, and when the function module is completed, the content of the input/output parameter is passed to the actual parameter.
    TABLES parameters are table parameters. Table parameters are obsolete CHANGING parameters that are typed as standard tables with a header line. If an internal table without a header line or a table body is passed as an actual parameter to a formal parameter of this type, an empty local header line is generated in the function module. If an internal table with a header line is used as an actual parameter, both the table body and the header line are passed to the function module. Pass by value is not possible in formal parameters defined using TABLES. Formal parameters defined with TABLES can be replaced by formal parameters defined with CHANGING. A local work area can be created for the internal table in the function module by using the addition LIKE LINE OF itab of the DATA statement.
    Exceptions
    The exception of a function module are defined on the Exceptions tab page in the Function Builder. Here you can select exception classes to define whether class-based exceptions are declared or non-class-based exception are defined. Class-based exceptions are represented in the above syntax by RAISING, and non-class-based exceptions are represented by EXCEPTIONS.
    The addition RAISING is used to declare class-based exceptions that can be propagated from the function module to the caller. Exceptions in the categories CX_STATIC_CHECK and CX_DYNAMIC_CHECK must be explicitly declared, otherwise a propagation can lead to an interface violation. A violation of the interface leads to the treatable exception CX_SY_NO_HANDLER. Exceptions of the category CX_NO_CHECK are implicitly always declared. The declaration of exceptions of the category CX_STATIC_CHECK is statically checked in the syntax check. For exceptions of the category CX_DYNAMIC_CHECK, the check is not performed until runtime. In a function module in which class-based exceptions are declared with the RAISING addition, the statement CATCH SYSTEM-EXCEPTIONS cannot be used. Instead, the relevant treatable exceptions should be handled in a TRY control structure.
    The addition EXCEPTIONS is used to define a list of non-class-based exceptions that can be triggered in the function module using the statements RAISE or MESSAGE RAISING. Exceptions defined in this way - as with formal parameters - are bound to the function module and cannot be propagated. If an exception of this type is triggered in a function module, and no return value has been assigned to it with the homonymous addition EXCEPTIONS of the CALL FUNCTION statement when the call was made, this leads to a runtime error.
    Note
    For new developments after release 6.10, SAP recommends that you work with class-based exceptions that are independent of the function module.
    RFC is a technology which is used to access a functions (Modules) from
    the remote systems.
    If a function module is set as remote enabled which can be access from
    the remote system via RFC.Eg: U can access the Remote enabled function modules in ur VB,Webdynpro,Java,Visual composer program.
    A function module can be set as remote enabled by SE37->Go to ur FM->click the option Button "remote enabled".
    But Normal function modules can not accessd from the remote system.
    Good Example for RFC enabled function module is : BAPI(Business Application Programming Interface)
    Note: All BAPIs are Remote enabled but not all remote enabled function modules are BAPI.
    CALLING A FUNCTION MODULE:
    1)In U ABAP Editor --> Click "Patter" ---> Selection Option Button "Call Function"
    --> Write the Corresponding FM name --> Hit Enter
    2)The appropriate import ,export Parameters will be displayed in ur editor
    3)Pass the Values Here.
    Also check these links.
    http://www.geocities.com/victorav15/sapr3/abapfun.html
    Check this link:
    http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
    Check this link:
    http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
    See the following links:
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
    Regards
    Anji

  • VBAK and VBAP

    When a sales order is created the entered data is mainly stored in VBAP and VBAK. Is it true?

    Hi,
    What you have said is correct. Also, for you to understand the tables which are used in SD, you can download the list of SD tables in the following path.
    http://www.erpgenie.com/abap/tables_sd.htm
    Hope this helps.
    Reward if thsi helsp.

  • Performance issue with joins on table VBAK, VBEP, VBKD and VBAP

    hi all,
    i have a report where there is a join on all 4 tables VBAK, VBEP, VBKD and VBAP.
    the report is giving performance issues because of this join.
    all the key fields are used for the joining of tables. but some of the non-key fields like vbap-vstel, vbap-abgru and vbep-wadat are also part of select query and are getting filled.
    because of these there is a performance issue.
    is there any way i can improve the performance of the join select query?
    i am trying "for all entries" clause...
    kindly provide any alternative if possible.
    thanks.

    Hi,
    Pls perform some of the below steps as applicable for the performance improvement:
    a) Remove join on all the tables and put joins only on header and item (VBAK & VBAP).
    b) code should have separate select for VBEP and VBKD.
    c) remove the non key fields from the where clause. Once you retrieve data from the database into the internal table, sort the table and delete the entries which are not part of the non-key fields like vstel, abgru and wadat.
    d) last option is you can create index in the VBAP & VBEP table with respect to the fields vstel, abgru & wadat ( not advisable)
    e) buffering option on database tables also possible.
    f) select only the fields into the internal table that are applicable for the processing logic and also the select query should contaian the field names in the same order as mentioned in the database table.
    Hope this helps.
    Regards
    JLN

  • Joining the Tables VBAK and CDHDR

    Hi All,
    I am a novice to SAP, and probably have the most basic question. I need to join the two tables VBAK and CDHDR and I dont see any common fields between them.
    I would need to do this for as generating a custom report that lists all the valid contracts created or changed within the period of selection. I also need to show the old value and the new value, the user ID of who made the change/creation and the date of the change.
    Anyhelp in this regard is highly appreciated and will be rewarded appropriately.
    Many thanks in anticipation.

    CDHDR is used for each and every table of SAP, so don't look for common key with your table.
    Look for records in CDHDR with OBJECTCLAS = 'VERKBELEG' and OBJECTID = VBAK-VBELN, and then in CDPOS with keys of CDHDR and tabname = 'VBAK'  and tabkey = VBAK-VBELN. (You also get VBAP and other tables under the same Id)
    Take a look at report RVSCD100
    Regards

  • VBAP, VBAK and KNA1

    Hey SD experts,
    I would like to link those three SAP tables :
    VBAP, VBAK and KNA1 in order to create a query.
    VBAP is the principal table, VBAK and KNA1 are additional ones.
    What intermediate table should I use to make it possible ?
    Thank you,
    Bahia.

    I'll explain to you in details:
    I'm trying to create an infoset.
    I choose "direct read of table" : VBAP
    Than, I add VBAK : VBAP-VBELN = VBAK-VBELN
    Than, KNA1: KNA1-KUNNR = VBAK-KUNNR
    When I try to generate the infoset, I get this warning message:
    Access error in code for table KNA1,  KNA1 has sequence number 01
    Fields from VBAK are not assigned to a field group
    Fields from KNA1 are not assigned to a field group
    Thank you

  • Realtionship between J_1IEXCHDR and VBAP or VBAK

    Hi All Expert,
    Hw ru.
    Please help me regarding relation ship between J_1IEXCHDR and VBAK or VBAP table.
    currently i am using rdoc in J_1IEXCHDR table but cant fetch data.
    PLease guide me which field i can use for relation ship.
    *SELECT *
    *    FROM J_1IEXCHDR
    *    INTO TABLE it_J_1IEXCHDR
    *    FOR ALL ENTRIES in IT_VBRK
    *    where rdoc = it_vbrk-VBELN.
    OR
    select single exnum from J_1IEXCHDR into itab-exnum
      where rdoc = it_vbak-vbeln.
      itab-exnum = J_1IEXCHDR-exnum.
    Thanking U,
    Bhavesh Panchal.

    Hi,
    Excise invoice is posted with reference to Billing document and not sales order. Hence, you would find billing doc no in J_1IEXCHDR-RDOC. To trace back to sales order no use VBFA(Sales document flow) table.
    Check FM SD_DOCUMENT_FLOW_GET
    Regards,
    Amit
    Edited by: Amit Iyer on Aug 28, 2009 12:09 PM

  • Joining vbak to cdhdr table for document changes

    Hi Expert
    I am hanging for a week in this project please need some advice
    I want to join vbak table with cdhdr and select
    vbak.vkbur (plant) and want to show that vkbur in the internal table of it_cdhdr
    so as to select only those plant belong to vkbur so how can I join base on the below coding................
    REPORT ZCHGDOC
    NO STANDARD PAGE HEADING LINE-SIZE 120.
    WRITE: sy-title, 40 'Page', sy-pagno.
    ULINE.
    TABLES: CDHDR,
             CDPOS,
             t001w,
             "VKBUR,
             "VBELN,
             VBAK,
             VBAP.
    SELECTION-SCREEN BEGIN OF BLOCK DOCUMENT WITH FRAME TITLE TEXT-701.
    SELECTION-SCREEN END OF BLOCK DOCUMENT.
    SELECT-OPTIONS:
                     V1 FOR VBAK-VKBUR,
                     S_WERKS for T001W-werks,
                     objectid for  cdhdr-objectid,
                     udate for cdhdr-udate.
    PARAMETER: USERNAME LIKE CDHDR-USERNAME.
    DATA: BEGIN OF IT_VBAP OCCURS 0,
             OBJECTCLAS LIKE CDHDR-OBJECTCLAS,
             OBJECTID LIKE CDHDR-OBJECTID,
             VBELN LIKE VBAP-VBELN,
              END OF IT_VBAP.
    DATA: BEGIN OF IT_CDHDR OCCURS 0,
             OBJECTCLAS LIKE CDHDR-OBJECTCLAS,
             OBJECTID LIKE CDHDR-OBJECTID,
             CHANGENR LIKE CDHDR-CHANGENR,
             USERNAME LIKE CDHDR-USERNAME,
             UDATE LIKE CDHDR-UDATE,
             UTIME LIKE CDHDR-UTIME,
             FNAME LIKE CDPOS-FNAME,
             TABNAME LIKE CDPOS-TABNAME,
             TABKEY LIKE CDPOS-TABKEY,
             VALUE_NEW LIKE CDPOS-VALUE_NEW,
             VALUE_OLD LIKE CDPOS-VALUE_OLD,
    END OF IT_CDHDR.
    DATA: WA LIKE LINE OF IT_CDHDR.
    DATA: WA LIKE LINE OF IT_CDPOS.
    DATA: BEGIN OF IT_CDPOS OCCURS 0,
             OBJECTCLAS LIKE CDHDR-OBJECTCLAS,
             OBJECTID LIKE CDHDR-OBJECTID,
             CHANGENR LIKE CDHDR-CHANGENR,
             TABNAME LIKE CDPOS-TABNAME,
             TABKEY LIKE CDPOS-TABKEY,
             FNAME LIKE CDPOS-FNAME,
             VALUE_NEW LIKE CDPOS-VALUE_NEW,
             VALUE_OLD LIKE CDPOS-VALUE_OLD,
    END OF IT_CDPOS.
    Move-corresponding it_cdhdr to wa.
    Move-corresponding it_cdpos to wa.
    SELECT OBJECTCLAS
            OBJECTID
            CHANGENR
            USERNAME
            UDATE
            UTIME FROM CDHDR
            INTO CORRESPONDING FIELDS OF TABLE IT_CDHDR
    WHERE OBJECTCLAS = 'VERKBELEG' or
          objectclas = 'BETRIEB'
          ORDER BY UDATE.
    WHERE OBJECTCLAS = 'VERKBELEG'
    OR OBJECTCLAS = 'BETRIEB' ORDER BY UDATE.
    Filter data based upon Plant selection criteria.
    IF NOT S_WERKS[] IS INITIAL.
    DELETE IT_CDHDR WHERE NOT OBJECTID IN S_WERKS.
    ENDIF.
    IF IT_CDHDR[] IS NOT INITIAL.
       SELECT OBJECTCLAS
              OBJECTID
              CHANGENR
              VALUE_NEW
              VALUE_OLD
              FNAME
              TABNAME
              TABKEY
              FROM CDPOS
              INTO CORRESPONDING FIELDS OF TABLE IT_CDPOS
              FOR ALL ENTRIES IN IT_CDHDR
              WHERE
              OBJECTCLAS = IT_CDHDR-OBJECTCLAS
              AND OBJECTID = IT_CDHDR-OBJECTID
              AND CHANGENR = IT_CDHDR-CHANGENR.
              "or tabname = 'VBAP'.
       SORT IT_CDPOS BY OBJECTCLAS OBJECTID CHANGENR.
    ENDIF.
    Add tables CDPOS DATA TO CDHDR.
    DATA: INDEX TYPE i.
    LOOP AT IT_CDHDR.
       INDEX = SY-TABIX.
       READ TABLE IT_CDPOS WITH KEY OBJECTCLAS = IT_CDHDR-OBJECTCLAS
       OBJECTID = IT_CDHDR-OBJECTID
       CHANGENR = IT_CDHDR-CHANGENR BINARY SEARCH.
       IF SY-SUBRC = 0.
         IT_CDHDR-VALUE_NEW = IT_CDPOS-VALUE_NEW.
         IT_CDHDR-VALUE_OLD = IT_CDPOS-VALUE_OLD.
         MODIFY IT_CDHDR INDEX index TRANSPORTING value_new value_old.
       ENDIF.
       WRITE:/ SY-DATUM,SY-UZEIT,
              50 'DOCUMENT CHANGE REPORT',
             80 'Page', SY-PAGNO,
    "  WRITE: / SY-REPID
              50 'DETAIL REPORT BY PLANT '.
       SKIP.
       ULINE.
    *& T O P - O F - P A G E *
    WRITE:/ 'UDATE:' ,SY-DATUM.
    FORMAT COLOR 4 INTENSIFIED on.
    Write: /35                           ' DOCUMENT CHANGES REPORT '.
       WRITE: /5 'DOCUMENT-NO'.
    20 'TABNAME', 30 'TEXT_CASE', 50 'FNAME'.
       WRITE: /5 'DATE',  20 'FNAME', 45 'CHANGE-NO',65 'OLD-VALUE',80 'NEW-VALUE',95 'USER-NAME'.
       ULINE.
       LOOP AT IT_CDHDR INTO WA.
       on change of wa-objectid.
       Write: / wa-objectid UNDER'DOCUMENT-NO' ."color col_key.
       ENDON.
    ULINE.
         " CDPOS-tabname UNDER'TABNAME', CDPOS-TEXT_CASE UNDER'TEXT_CASE',CDPOS-fname UNDER'FNAME'. "color col_key ,
         write: / wa-udate dd/mm/yyyy under'DATE' NO-GAP,wa-fname under'FNAME' NO-GAP,wa-changenr under 'CHANGE-NO',
         wa-value_old under'OLD-VALUE' LEFT-JUSTIFIED NO-GAP,
         wa-value_new under'NEW-VALUE' LEFT-JUSTIFIED NO-GAP ,wa-username under'USER-NAME' NO-GAP.
    ENDON.
    Move-corresponding it_cdhdr to wa.
    *Write: / wa-objectid UNDER'DOCUMENT-NO' "color col_key.
    *" CDPOS-tabname UNDER'TABNAME', CDPOS-TEXT_CASE UNDER'TEXT_CASE',CDPOS-fname UNDER'FNAME'. "color col_key ,
    *write: / wa-udate dd/mm/yyyy under'DATE' NO-GAP,wa-utime under'TIME' NO-GAP,wa-changenr under 'CHANGE-NO',
    ltrim(wa-value_old) under'OLD-VALUE' NO-GAP,
    *wa-value_new under'NEW-VALUE' NO-GAP ,wa-username under'USER-NAME' NO-GAP.
       ENDLOOP.
    ENDLOOP.

    Hai everybody.
    I am new to this forum. i got a job in abap recently. The below is my requirement.I want solution for this one. Anybody plz help me.
    The change logs were captured in DBTABLOG for table ZWPRFRUND (in transaction ZWPG).
    The only report which is currently used to get the change logs is RSVTPROT
    Now my requirement is,
    we need to display the change logs in the form of ALV.
    We should divert the changes to CDHDR table instead of DBTABLOG, then we can use the RSSCD100 to display change logs.
    The Important items for the change LOG needed in case of changes to table in “ZWPG” are,DATE ,TIME,USER,FIRST NAME,FILED NAME,OLD VALUE,NEW VALUE
    The above fields need to be displayed in the grid. In the above list “FIELD NAME” denotes any field of the table in the transaction in “ZWPG”
    Thanks & Regards,
    Sujatha.T.

  • Link VBAK AND LIPS

    Hi Experts,
    IS there any link between VBAK and LIPS (VBELN AND VGBEL). Data is flow from header level VBAK to Item level LIPS is correct or Item level to item level.
    Regards
    Rahul

    Dear Rahul1234 ,
    You can use the VBAK- VBELN or VBAP-VBELN
    Put the same in VBFA as preceding document and fetch subsequent document where subsequent document category is J(delivery)
    Now input that list in LIPS to get the required field.
    This will work. If your ABAPer is telling that the logic is not correct, then you may demonstrate the same using a query (table join VBAK-VBFA-LIPS)
    Thanks & Regards,
    Hegal K Charles

  • How to use Innerjoin b/w these 2 tables VBAK and CDHDR ?

    Hi,
              How to use Innerjoin b/w these 2 tables VBAK and CDHDR for retrieving of changed sales order data ?I nned the A select stmt with INNER JOIN for changed sales data.
    Thanks & Regards,
    gopi.

    Hi Gopi,
    You can use the code similar to below to read the changes to Sales order from CDHDR AND CDPOS
    FORM GET_CHANGES .
    * Get all the changes to Sales Order as well as Deliveries. Suppress
    * Non relevant change
      DATA : BEGIN OF SO_VBELN OCCURS 0 ,
           VBELN LIKE CDHDR-OBJECTID,
           END OF SO_VBELN.
      DATA : BEGIN OF DL_VBELN OCCURS 0 ,
           VBELN LIKE CDHDR-OBJECTID,
           END OF DL_VBELN.
      DATA TEMP_SO_VBELN LIKE SO_VBELN OCCURS 0 WITH HEADER LINE.
      DATA DATE_UNTIL LIKE SY-DATUM.
      DATA TIME_UNTIL LIKE SY-UZEIT .
      DATA DATE_FROM LIKE SY-DATUM.
      READ TABLE S_CHADT INDEX 1.
      LOOP AT IT_VBAP.
        AT NEW VBELN.
          MOVE IT_VBAP-VBELN TO TEMP_SO_VBELN.
          COLLECT TEMP_SO_VBELN.
        ENDAT.
      ENDLOOP.
      IF TEMP_SO_VBELN[] IS NOT INITIAL.
        SELECT OBJECTID AS VBELN FROM CDHDR
             INTO TABLE SO_VBELN
               FOR ALL ENTRIES IN TEMP_SO_VBELN
             WHERE  OBJECTCLAS EQ 'VERKBELEG'
             AND OBJECTID EQ TEMP_SO_VBELN-VBELN
             AND USERNAME IN S_CHABY
             AND UDATE IN S_CHADT.
      ENDIF.
      LOOP AT IT_LIPS INTO WA_LIPS.
        AT NEW VBELN.
          MOVE WA_LIPS-VBELN TO DL_VBELN.
          COLLECT DL_VBELN.
        ENDAT.
      ENDLOOP.
    * Changes in Sales Order.
      IF NOT  SO_VBELN[] IS INITIAL.
    * Get partner functions
        SELECT * INTO TABLE IT_TPART
          FROM TPART WHERE SPRAS EQ SY-LANGU.
        SELECT A~TABNAME A~FIELDNAME A~DATATYPE B~DDTEXT
           INTO CORRESPONDING FIELDS OF TABLE IT_FIELD
           FROM DD03L AS A INNER JOIN
                DD04T AS B
                ON A~ROLLNAME EQ B~ROLLNAME
                AND A~AS4LOCAL EQ B~AS4LOCAL
              WHERE ( A~TABNAME EQ 'VBAK'
                      OR A~TABNAME EQ 'VBAP'
                      OR A~TABNAME EQ 'VBEP'
                      OR A~TABNAME EQ 'VBPA'
                      OR A~TABNAME EQ 'VBUK'
                      OR A~TABNAME EQ 'VBKD' )
               AND  A~AS4LOCAL EQ 'A'
               AND A~AS4VERS EQ '0000'
               AND A~ROLLNAME NE SPACE
               AND B~DDLANGUAGE EQ SY-LANGU.
    * Preapare the exclusion table
        R_EXCL_FIELDS-OPTION = 'EQ'.
        R_EXCL_FIELDS-SIGN = 'I'.
        LOOP AT IT_FIELD WHERE DATATYPE EQ 'CURR'.
          R_EXCL_FIELDS-LOW = IT_FIELD-FIELDNAME.
          APPEND R_EXCL_FIELDS.
        ENDLOOP.
        R_EXCL_FIELDS-LOW = 'ARKTX'.
        APPEND R_EXCL_FIELDS.
        R_EXCL_FIELDS-LOW = 'LGORT'.
        APPEND R_EXCL_FIELDS.
        R_EXCL_FIELDS-LOW = 'TDDAT'.
        APPEND R_EXCL_FIELDS.
        R_EXCL_FIELDS-LOW = 'LDDAT'.
        APPEND R_EXCL_FIELDS.
        R_EXCL_FIELDS-LOW = 'MBDAT'.
        APPEND R_EXCL_FIELDS.
        R_EXCL_TABL-OPTION = 'EQ'.
        R_EXCL_TABL-SIGN = 'I'.
        R_EXCL_TABL-LOW = 'KONVC'.
        APPEND R_EXCL_TABL.
        R_EXCL_TABL-LOW = 'VBKD'.
        APPEND R_EXCL_TABL.
        LOOP AT SO_VBELN.
          REFRESH ITAB_CDHDR.
          DATE_FROM = S_CHADT-LOW.
          DATE_UNTIL = S_CHADT-HIGH.
          CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
            EXPORTING
              DATE_OF_CHANGE             = DATE_FROM
              OBJECTCLASS                = 'VERKBELEG'
              OBJECTID                   = SO_VBELN-VBELN
              TIME_OF_CHANGE             = TIME_UNTIL
              DATE_UNTIL                 = DATE_UNTIL
              USERNAME                   = ' '
            TABLES
              I_CDHDR                    = ITAB_CDHDR
            EXCEPTIONS
              NO_POSITION_FOUND          = 1
              WRONG_ACCESS_TO_ARCHIVE    = 2
              TIME_ZONE_CONVERSION_ERROR = 3
              OTHERS                     = 4.
          IF SY-SUBRC NE 0.
            CONTINUE.
          ENDIF.
          LOOP AT ITAB_CDHDR WHERE USERNAME IN S_CHABY.
            REFRESH IT_CDSHW.
            CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
              EXPORTING
                CHANGENUMBER            = ITAB_CDHDR-CHANGENR
              TABLES
                EDITPOS                 = IT_CDSHW
              EXCEPTIONS
                NO_POSITION_FOUND       = 1
                WRONG_ACCESS_TO_ARCHIVE = 2
                OTHERS                  = 3.
            IF SY-SUBRC EQ 0.
              PERFORM GET_ACTION .
            ENDIF.
          ENDLOOP.
        ENDLOOP.
      ENDIF.
    * Changes in Delivery
      IF NOT DL_VBELN[] IS INITIAL.
        REFRESH : IT_CDHDR , IT_CDPOS.
        SELECT  OBJECTCLAS OBJECTID CHANGENR USERNAME UDATE
               FROM CDHDR INTO CORRESPONDING FIELDS OF TABLE IT_CDHDR
             FOR ALL ENTRIES IN DL_VBELN
           WHERE  OBJECTCLAS EQ 'LIEFERUNG'
           AND OBJECTID EQ DL_VBELN-VBELN
           AND USERNAME IN S_CHABY
           AND UDATE IN S_CHADT
           AND CHANGE_IND EQ 'U'.
        LOOP AT IT_CDHDR.
          CONCATENATE SY-MANDT IT_CDHDR-OBJECTID
           INTO IT_CDHDR-TABKEY .
          CONDENSE  IT_CDHDR-TABKEY.
          MODIFY IT_CDHDR.
        ENDLOOP.
        IF NOT IT_CDHDR[] IS INITIAL.
          SELECT  * INTO TABLE IT_CDPOS FROM CDPOS
               FOR ALL ENTRIES IN IT_CDHDR
             WHERE  OBJECTCLAS EQ IT_CDHDR-OBJECTCLAS
             AND OBJECTID EQ IT_CDHDR-OBJECTID
             AND CHANGENR EQ IT_CDHDR-CHANGENR
             AND TABNAME EQ 'LIKP'
             AND TABKEY EQ IT_CDHDR-TABKEY
             AND FNAME IN ('WADAT','LFDAT','ROUTE','VSBED')
             AND CHNGIND EQ 'U' .
          LOOP AT IT_CDPOS .
            CLEAR  IT_DL_CHG-FLAG_RED.
            CASE IT_CDPOS-FNAME.
              WHEN 'WADAT'.
                MOVE 'Goods issue date changed' TO IT_DL_CHG-ACTION.
              WHEN 'LFDAT'.
                MOVE 'Delivery date changed' TO IT_DL_CHG-ACTION.
                MOVE 'X'  TO IT_DL_CHG-FLAG_RED.
              WHEN 'ROUTE'.
                MOVE 'Route Changed' TO IT_DL_CHG-ACTION.
              WHEN 'VSBED'.
                MOVE 'Shipping Condition Changed' TO IT_DL_CHG-ACTION.
              WHEN OTHERS.
            ENDCASE.
            AT NEW CHANGENR .
              READ TABLE IT_CDHDR WITH KEY OBJECTCLAS = IT_CDPOS-OBJECTCLAS
                                           OBJECTID = IT_CDPOS-OBJECTID
                                           CHANGENR = IT_CDPOS-CHANGENR
                                           BINARY SEARCH.
              MOVE IT_CDHDR-USERNAME TO  IT_DL_CHG-ERNAM.
              WRITE IT_CDHDR-UDATE TO  IT_DL_CHG-ERDAT.
            ENDAT.
            IT_DL_CHG-COUNTER = IT_DL_CHG-COUNTER + 1.
            MOVE IT_CDPOS-OBJECTID TO IT_DL_CHG-VBELN.
            MOVE IT_CDPOS-VALUE_OLD TO IT_DL_CHG-OLD_VAL.
            MOVE IT_CDPOS-VALUE_NEW TO IT_DL_CHG-NEW_VAL.
            INSERT TABLE IT_DL_CHG.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " GET_CHANGES
    Cheers
    VJ

  • SAP Query error for VBAK and KONV tables

    Dear Experts,
    Want to create SAP Query for below requirement but faced some error
    Step1) Extract the data from VBAK table w.r.t.  order type ,  Sale org and date range
    and collected the Sales order numbers and doc. condition record (KNUMV)
    Step 2)In table KONV (Transactional condition record data) in this table provided input as doc. condition record (KNUMV) with respect to condition type ABCD
    Manually i extracted data, there is no problem .
    But customer want to generate SAP Query for above requirement
    I tried to create but in t.code  SQ02 when i tried to join the table VBAK and KONV i faced the below error
    Table KONV cannot be used in a join.
    How  can I create SAP query for above requirement ???
    if its not possible then create Z report is the only solution ??????
    Thanks in advance

    Hello
    You can not create Query report with joining KONV. But there is one solution for your problem. You can create Query report by using Database VAV. In this logical database you will find all SD tables and also KONV. Use only those tables and fields which you want in your query report. I have checked this and its working
    Please try this and update the forum accordingly.
    Edited by: moazzamjii on Jun 30, 2011 12:13 PM

Maybe you are looking for

  • Version of application Server -- OIM 9.1.0.0

    What's the version of application Server supported for OIM (v 9.1.0.0)? I was install OAS 10.1.3 and in the middle of installation appears one information about "This version of OAS is not supported for this installation". Thanks again.

  • Indexes for group by query on table with 5million records

    Hi, Here is my query which is taking ages to run :      SELECT approved.budgetReferenceno                , approved.projects                , approved.allocations                , rptgen4                      , financialyear                , cashclas

  • After upgrading to OS X Mavericks now I can't print, any idea what I should do?

    i just upgraded my system to OS X Marvericks and now I can not print through our office network printer. Office printer is a Canon Image Runner Advance C5030 (Colored). Anybody have any idea what to do? Need help.

  • How can I determine what dns server the wifi client use within airport

    How can I determine what dns server the wifi client use within airport I want to use dns servers other then the one that airport extreme is using. For example I got the 172.16.1.1 (the default gateway - airport extreme), but I want to use the office

  • Presentation Navigation

    I'm hopeing someone might be able to help me out. I have my presentation ready to go, and can navigate backward and forward from slide to slide, but I can not get the slide that I am jumping to using my buttons to jump it to the first frame of the pr