Table CDHDR and CDPOS Usage

Client have a request: Is there a report that lists XDC status changes, and date the change was made? Client want to find out when the materials were moved out of status 31, other than looking 1 by 1 through MM03. 

You have choice of the followings:

1) Program "RSSCD1TS", Display Change Documents, may be helpful. Use Object Class "MATERIAL" and the applicable Table Name and date range. 

2) SAP Transaction code AUT10 interrogates the CDHDR and CDPOS tables. In the selection screen for this transaction enter MM02 as the transaction code (for the change) and MARA as table and MSTAV as field. You have further options to enter (e.g.) date or date range (of change), user, etc. 

3) You have two options. 

The first one, is to make a SELECT to the CDPOS with OBJECTCLASS = 'MATERIAL', TABNAME (the one that has the movement type), also de FIELDNAME, the FIELDVALUE '31', and the CHANGE_IND 'U' (for Update, I for Insert). 

After this SELECT, you must do a SELECT to the CDHDR, which contains the Dates of this CHANGENUMBERS you already searched. With this information, you just have to SORT i_cdhdr BY udate DESCENDING. 

Sample Coding:

***This example is for the NetPrice Value changed for POs 

SELECT objectclas 

objectid 

changenr 

tabkey 

FROM cdpos 

INTO TABLE i_cdpos 

WHERE objectclas EQ 'EINKBELEG' "EINKBELEG is for POs, you should use MATERIAL objectclas 

AND objectid EQ i_ebeln-ebeln 

AND tabname EQ 'EKPO' "This is the table where the ME23N stores the NetPrice field 

AND fname EQ 'NETPR' 

AND chngind EQ 'U'. 

IF sy-subrc EQ 0. 

SORT i_cdpos2 BY objectid ASCENDING 

changenr DESCENDING 

tabkey ASCENDING . 

SELECT objectid 

changenr 

udate 

FROM cdhdr 

INTO TABLE i_cdhdr2 

FOR ALL ENTRIES IN i_cdpos2 

WHERE objectclas EQ i_cdpos2-objectclas 

AND objectid EQ i_cdpos2-objectid 

AND changenr EQ i_cdpos2-changenr. 

IF sy-subrc = 0. 

SORT i_cdhdr2 

BY objectid ASCENDING changenr DESCENDING udate DESCENDING . 

ENDIF. 
 

The second option is to use the FM 'CHANGEDOCUMENT_READ'. 

CALL FUNCTION 'CHANGEDOCUMENT_READ' 

EXPORTING 

objectclass = 'EINKBELEG' 

objectid = l_objectid 

tablekey = l_tabkey 

tablename = 'EKPO ' 

TABLES 

editpos = i_editpos 

EXCEPTIONS 

no_position_found = 1 

wrong_access_to_archive = 2

time_zone_conversion_error = 3 

OTHERS = 4. 

You should place the cursor on the Movement Type field, press F1 and then Technical information, and you will know which table and field you must use. 

ABAP Tips

See Also
How Loop Works in Internal Tables

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP ERP Modules, Basis, ABAP and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.