Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function Module to Read Change Documents from Tables CDHDR & CDPOS

Former Member
0 Kudos

Hi,

I am looking for a Functional Module that reads the change document from Tables CDHDR & CDPOS. If the same document is changed more than once, I want to process the latest change on the document. Can you please suggest me a suitable FM for this requirement.

Appreciate your help in Advance!

Thanks,

Kannan

1 ACCEPTED SOLUTION

Former Member
4 REPLIES 4

Former Member

Hi

Use this function modules,

CHANGEDOCUMENT_READ_HEADERS

CHANGEDOCUMENT_READ_POSITIONS

Check this sample code.

cdhdr-objectclas = 'MATERIAL'.

cdhdr-objectid = t_mara-matnr.

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 period.

CHECK icdhdr-username IN name.

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-matnr.

APPEND itab.

ENDLOOP.

ENDLOOP.

ENDFORM. "CHANGEDOCUMENT_READ

Rgds

Siva

Edited by: siva prasad on Apr 22, 2009 5:29 AM

faisal_altaf2
Active Contributor
0 Kudos

Hi,

Sorry, Removed i think was not Relevant

Best Regards,

Faisal

Edited by: Faisal Altaf on Apr 22, 2009 10:32 AM

Former Member

Former Member
0 Kudos

Hi,

Check this FM

/BEV2/ED_READ_CHANGE_DOCUMENTS

Regards,

Jyothi CH.