Register Login

Material Changes for CDHDR CDPOS

Updated May 18, 2018

Hello,
I would like to extract all the material changes for CDHDR CDPOS.
Do you have a program sample for this or idea for optimization ?
Thank's for your help


Comments

  • 08 Aug 2013 6:52 am rekha
    Table CDHDR and CDPOS stores changes (e.g change data in Material Master, changes to Purchase Req (PR), Purch Orders, Contracts, Sales Orders, and many more) to a lot of SAP documents.

    REPORT ZPOCHANGE LINE-SIZE 132 NO STANDARD PAGE HEADING

    LINE-COUNT 065(001)

    MESSAGE-ID VR.

    TABLES: DD04T,

    CDHDR,

    CDPOS,

    DD03L,

    DD41V,

    T685T,

    VBPA,

    TPART,

    KONVC,

    EKKO.

    SELECT-OPTIONS: XUDATE FOR CDHDR-UDATE,

    XNAME FOR CDHDR-USERNAME,

    XEBELN FOR EKKO-EBELN,

    XLIFNR FOR EKKO-LIFNR.



    SELECTION-SCREEN SKIP.

    TEXT-001 - Sorting Sequence

    SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.

    PARAMETERS: SUDATE RADIOBUTTON GROUP R1,

    SNAME RADIOBUTTON GROUP R1,

    SOBID RADIOBUTTON GROUP R1.

    SELECTION-SCREEN END OF BLOCK BLK1.



    DATA: WFLAG,

    WCHANGENR LIKE CDHDR-CHANGENR.



    DATA: INDTEXT(60) TYPE C.



    DATA: BEGIN OF ICDHDR OCCURS 50.

    INCLUDE STRUCTURE CDHDR.

    DATA: END OF ICDHDR.



    DATA: BEGIN OF ICDSHW OCCURS 50.

    INCLUDE STRUCTURE CDSHW.

    DATA: END OF ICDSHW.



    DATA: BEGIN OF EKKEY,

    EBELN LIKE EKET-EBELN,

    EBELP LIKE EKET-EBELP,

    ETENR LIKE EKET-ETENR,



    END OF EKKEY.



    DATA: BEGIN OF ITAB OCCURS 50,

    BEGIN OF EKKEY,

    EBELN LIKE EKET-EBELN,

    EBELP LIKE EKET-EBELP,



    ETENR LIKE EKET-ETENR,

    END OF EKKEY,

    CHANGENR LIKE CDHDR-CHANGENR,

    UDATE LIKE CDHDR-UDATE,

    UTIME LIKE CDHDR-UTIME,

    USERNAME LIKE CDHDR-USERNAME,

    CHNGIND LIKE CDSHW-CHNGIND,

    FTEXT LIKE CDSHW-FTEXT,

    OUTLEN LIKE CDSHW-OUTLEN,

    F_OLD LIKE CDSHW-F_OLD,

    F_NEW LIKE CDSHW-F_NEW,

    END OF ITAB.

    DATA: OLD_OBJECTID LIKE CDHDR-OBJECTID.



    FIELD-SYMBOLS: , .



    SELECT * FROM EKKO WHERE EBELN IN XEBELN AND

    LIFNR IN XLIFNR.

    CLEAR CDHDR.

    CLEAR CDPOS.

    CDHDR-OBJECTCLAS = 'EINKBELEG'.

    CDHDR-OBJECTID = EKKO-EBELN.

    PERFORM GETCHGDOCS.

    ENDSELECT.



    IF SUDATE = 'X'.

    SORT ITAB BY UDATE EKKEY-EBELN CHANGENR EKKEY-EBELP

    EKKEY-ETENR.

    ELSEIF SNAME = 'X'.

    SORT ITAB BY USERNAME EKKEY-EBELN CHANGENR EKKEY-EBELP

    EKKEY-ETENR.

    ELSE.

    SORT ITAB BY EKKEY-EBELN CHANGENR EKKEY-EBELP EKKEY-ETENR.

    ENDIF.



    LOOP AT ITAB.

    CLEAR: INDTEXT, EKKEY.

    CASE ITAB-CHNGIND.

    WHEN 'U'.

    INDTEXT(50) = ITAB-FTEXT.

    INDTEXT+51 = TEXT-020.

    CONDENSE INDTEXT.

    WHEN 'D'.

    INDTEXT = TEXT-021.

    WHEN 'E'.

    INDTEXT(5) = ITAB-FTEXT.

    INDTEXT+51 = TEXT-021.

    CONDENSE INDTEXT.

    WHEN 'I'.

    INDTEXT = TEXT-022.

    ENDCASE.

    RESERVE 4 LINES.

    IF WCHANGENR NE ITAB-CHANGENR.

    WCHANGENR = ITAB-CHANGENR.

    EKKEY = ITAB-EKKEY.

    WRITE:/ ITAB-UDATE UNDER 'Change Date',

    ITAB-UTIME UNDER 'Time',

    ITAB-USERNAME UNDER 'User Name',

    ITAB-EKKEY-EBELN UNDER 'PO No',

    ITAB-EKKEY-EBELP UNDER 'Item',

    ITAB-EKKEY-ETENR UNDER 'Sch No',

    INDTEXT UNDER 'Changes'.

    ELSEIF ITAB-EKKEY NE EKKEY.

    WRITE:/ ITAB-EKKEY-EBELP UNDER 'Item',

    ITAB-EKKEY-ETENR UNDER 'Sch No',

    INDTEXT UNDER 'Changes'.



    ENDIF.



    CASE ITAB-CHNGIND.

    WHEN 'U'.

    ASSIGN ITAB-F_OLD(ITAB-OUTLEN) TO .

    ASSIGN ITAB-F_NEW(ITAB-OUTLEN) TO .

    WRITE: / TEXT-023 UNDER 'Changes',

    .

    WRITE: / TEXT-024 UNDER 'Changes',

    .

    WHEN 'E'.

    ASSIGN ITAB-F_OLD(ITAB-OUTLEN) TO .

    WRITE: TEXT-023 UNDER 'Changes',

    .

    ENDCASE.

    SKIP.

    ENDLOOP.





    TOP-OF-PAGE.

    WRITE:/ SY-DATUM,SY-UZEIT,

    50 'P U R C H A S E O R D E R H I S T O R Y',

    120 'Page', SY-PAGNO.

    WRITE: / SY-REPID,

    60 'Purchase Orders Changes'.

    SKIP.

    ULINE.

    IF SUDATE = 'X'.

    WRITE:/001 'Change Date',

    014 'Time',

    024 'User Name',

    038 'PO No',

    050 'Item',

    057 'Sch No',

    065 'Changes'.

    ELSEIF SOBID = 'X'.

    WRITE:/001 'PO No',

    013 'Item',

    020 'Sch No',

    028 'Change Date',

    041 'Time',

    051 'User Name',

    065 'Changes'.

    ELSE.

    WRITE:/001 'User Name',

    015 'Change Date',

    028 'Time',

    038 'PO No',

    050 'Item',

    057 'Sch No',

    065 'Changes'.

    ENDIF.

    ULINE.



    FORM GETCHGDOCS.

    CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

    EXPORTING

    DATE_OF_CHANGE = CDHDR-UDATE

    OBJECTCLASS = CDHDR-OBJECTCLAS

    OBJECTID = CDHDR-OBJECTID

    TIME_OF_CHANGE = CDHDR-UTIME

    USERNAME = CDHDR-USERNAME

    TABLES

    I_CDHDR = ICDHDR

    EXCEPTIONS

    NO_POSITION_FOUND = 1

    OTHERS = 2.



    CHECK SY-SUBRC EQ 0.

    DELETE ICDHDR WHERE CHANGE_IND EQ 'I'.

    CHECK NOT ICDHDR[] IS INITIAL.

    LOOP AT ICDHDR.

    CHECK ICDHDR-UDATE IN XUDATE.

    CHECK ICDHDR-USERNAME IN XNAME.

    CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

    EXPORTING CHANGENUMBER = ICDHDR-CHANGENR

    IMPORTING HEADER = CDHDR

    TABLES EDITPOS = ICDSHW

    EXCEPTIONS NO_POSITION_FOUND = 1

    OTHERS = 2.

    CHECK SY-SUBRC EQ 0.

    LOOP AT ICDSHW.

    CHECK ICDSHW-TEXT_CASE EQ SPACE.

    MOVE-CORRESPONDING ICDSHW TO ITAB.

    MOVE-CORRESPONDING ICDHDR TO ITAB.

    MOVE ICDSHW-TABKEY+3 TO ITAB-EKKEY.

    APPEND ITAB.

    ENDLOOP.

    ENDLOOP.

    ENDFORM.

    *

    END OF PROGRAM
  • 08 Aug 2013 7:17 am Sushma
    Your Functional Analyst should give you the hints and what changes you want to extract (the first one, the last one all of them, those that meet some specification?) Once you have a full specification, then you can give us more information about your problem and perhaps we'd be able to help you with this issue (IMO, your question is too general...)

    BTW, If you want to have a good , you may want to use hashed tables to maintain records read from cdhdr and cdpos. Hashed tables have a good access ratio and have a good behaviour when you're inserting records into them.
  • 08 Aug 2013 7:18 am Sushma
    Hi,

    There are standard Fms (and probably BAPIs) also which read CHD* tables. Check in SE11 with where used functionality..
  • 08 Aug 2013 7:18 am Sushma
    Hi,

    The way we track material changes on our Retail installation is done this
    way. Hope these hints will help.

    Take a look at package : WBBC (Retail - Assortment list)

    View : V_TBD62 is used to maintain field that are relevant for changes.
    Fields flag for "change document" are allowed in Material master tables and
    pricing conditions.

    Table : BDCP2 is used since ECC 6.0. Still CDHDR and CDPOS contain
    changes.

    IDOC : WBBDL and WPDWGR

    Program RWDPOSIN and RWDBBUPD are used to generate the IDOCs.
  • 08 Aug 2013 7:18 am Sushma
    CHANGEDOCUMENT_READ_RANGES
  • 08 Aug 2013 7:18 am Sushma
    If you have authorization to run transaction SE38 or SA38, you can execute the program "RSSCD1TS", Display Change Documents. Enter Object class "MATERIAL". You can restrict your output by a specific user, dates, or specific table. If you leave the Tablee name blank, it will bring up changes to tables: MLAN, MAKT, MARA, MARC, MARD, MBEW, MARM, The output also provide the t-code used to make the change
  • 08 Aug 2013 7:19 am Sushma
    SAP transaction AUT10 reads tables CDHDR and CDPOS (we have this in R3 4.7) . You would need to select either relevant material master tables/fields (MARA, MARC, etc) or relevant T-cde (MM02) in your selection (or both to refine your search). You can also select by user, date/time, etc. . Report shows before and after data for each change, wih change number, if used. Very easy to use and very powerful.
  • 08 Aug 2013 7:20 am amit butola
    Ok, thanks for all your answers.

    The ?RSSCD1TS program is ok. There are also RSSCD100, RSSCD200 but my program is specific : select data recovery and select current data.
    For the data recovery it's ok but for current data, it's not ok.

    ?We were left to recover any changes to 'MARA-LAEDA > p_date' but there are too many changes. I could only column of my output file

    I would change's material for :

    MM06 (delete material)
    MM01 (create material)
    MM02 but for MM02 only for :

    - MARA-MTART
    - MARA-EAN11
    - MARA-MMSTA
    - MARA-LABOR
    - MARA-MEINS
    - MARC-SERNP
    - MAKT-MAKTX
    - ADV Text
    - MLAN-TAXIM
    - MVKE-PRODH
    - MVKE-VRKME
    - AUSP-ATWRT
    - MARM-UMREN
    - MARM-UMREZ
    - KONP-KBETR

    ?ME11 and ME12 for :

    - EINA-LIFNR
    - EINA-LSTNR
    It's OK with CDHDR-OBJECTCLAS = 'INFOSATZ'

    And then also changes for :

    ?the sales price 'P5' with validity date
    ?the info record price created
    ?VAT amount

    We selected prices condition into A508/KONP, A018/KONP and A002/MLAN

    How to select only these changes and with best times. Is it in CDHDR/CDPOS or in where other table ?
    BR

×