Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

!!Urgent!! help needed for CDHDR FM

hello everyone,

I need to read the changes done for material. When I'm testing the function module through se37, it runs fine. Also, I am able to go and see the changes done by me in the contents of cdhdr. Following is my code, can someone tell me what I'm missing here:

*********************************************************

data: ins_data type string,

upd_data type string.

parameters:

p_b_date like CDHDR-UDATE obligatory, "Begin Date

p_e_date like CDHDR-UDATE obligatory, "End Date

p_b_time like CDHDR-UTIME obligatory, "Begin Time

p_e_time like CDHDR-UTIME obligatory. "End Time

data: begin of i_pt_cdhdr occurs 0.

include structure cdhdr.

data: end of i_pt_cdhdr.

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

EXPORTING

DATE_OF_CHANGE = p_b_date

OBJECTCLASS = 'MATERIAL'

TIME_OF_CHANGE = p_b_time

USERNAME = SY-UNAME

DATE_UNTIL = p_e_date

TIME_UNTIL = p_e_time

TABLES

I_CDHDR = i_pt_cdhdr

EXCEPTIONS

NO_POSITION_FOUND = 1

WRONG_ACCESS_TO_ARCHIVE = 2

TIME_ZONE_CONVERSION_ERROR = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

open dataset v_data1 for output

in text mode encoding default.

loop at i_pt_cdhdr.

if i_pt_cdhdr-change_ind = 'I'.

At First.

concatenate 'Material' 'Inserted' into ins_data separated by ' '.

concatenate 'Object ID' 'Document Change Number' 'Username' 'Creation Date' 'Time changed' 'Transaction' 'Change indicator' 'Language'

into ins_data separated by ' '.

transfer ins_data to v_data1.

Endat.

*Load data for inserted material

concatenate i_pt_cdhdr-objectid i_pt_cdhdr-changenr i_pt_cdhdr-username i_pt_cdhdr-udate i_pt_cdhdr-utime i_pt_cdhdr-tcode i_pt_cdhdr-change_ind i_pt_cdhdr-langu

into ins_data separated by ' '.

transfer ins_data to v_data1.

*Message if no material inserted

else.

concatenate 'No material' 'inserted.' into ins_data.

transfer ins_data to v_data1.

*Check for Update indicator

if i_pt_cdhdr-change_ind = 'U'.

*Load headings first

At First.

concatenate 'Material' 'Updated' into ins_data separated by ' '.

concatenate 'Object ID' 'Document Change Number' 'Username' 'Creation Date' 'Time changed' 'Transaction' 'Change indicator' 'Language'

into upd_data separated by ','.

transfer upd_data to v_data1.

Endat.

*Load data for inserted material

concatenate i_pt_cdhdr-objectid i_pt_cdhdr-changenr i_pt_cdhdr-username i_pt_cdhdr-udate i_pt_cdhdr-utime i_pt_cdhdr-tcode i_pt_cdhdr-change_ind i_pt_cdhdr-langu

into upd_data separated by ','.

transfer upd_data to v_data1.

*Message if no material updated

else.

concatenate 'No material' 'updated.' into upd_data.

transfer upd_data to v_data1.

endif.

endif.

endloop.

*Close file on Application Server

close dataset v_data1.

*********************************************************

In short, I need to read changes for material Inserted or Updated and load it to the Application Server. In the function module, i_pt_cdhdr is not getting populated. SY-SUBRC is 1.

Please let me know how to resolve this.

Many Thanks.

Regards,

Fred.

Tags:
Former Member
replied

Just before calling the function module , put a break point, now run it, check the values that you are passsing, are then coming correctly?

YYYYMMDD

HHMMSS

Regards,

Rich Heilman

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question