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: 

Adding new entries to CDHDR / CDPOS via program

Former Member
0 Kudos

Hello,

another interesting idea from customer.

We need to add entries to tables CDHDR / CDPOS for changes to objects like material or

BOM which are from external programs.

(There is a DB where data of e.g. material from SAP System is modified and we need to have such changes documented in the named tables in our R/3 system).

But simply adding entries in these tables via rfc prog. is not working, because new change documents are not displayed in material master in SAP system.

So it seems that there is something which needs to be added because we need the changes to be displayed via such SAp functions.

Another question is the numbering of change documents. I think we need to update the counter for change numbers too.

Can you give any help! This would be great!

Best regards

Dirk

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

For tracing the change logs of manually made changes or some changes done from some custom program, I hope this will not require any CDHDR and CDPOS needs to be updated.

For viewing those changes, for that data base table or custom table in SM30, change logs, select the Append Table Changes check box to view the changes done manually.

For logging these changes, using the function module CHANGEDOCUMENT_OPEN, CHANGEDOCUMENT_SINGLE_CASE, and CHANGEDOCUMENT_CLOSE write the changes done at 01 event (Before saving the entries) of the table you required.

I hope this will fulfill your requirement.

Regards,

Santhosh.

8 REPLIES 8

Former Member
0 Kudos

Hi, u Can Try This....

call function 'SD_SALES_DOCUMENT_ENQUEUE'

exporting

vbeln = itab_in-vbeln

i_crm_lock_mode = crm_lock_mode

exceptions

foreign_lock = 2

system_failure = 3.

lk_uname = sy-msgv1.

case sy-subrc.

when 2. "* other user has doc locked

message i042 with itab_in-vbeln lk_uname into msgtext.

write:/ msgtext.

continue.

when 3.

message i043 into msgtext. "* general can not be locked

write:/ msgtext.

continue.

endcase.

- after update -> call function 'DEQUEUE_ALL'.

1. CHANGEDOCUMENT_OPEN

2. in any sequence

CHANGEDOCUMENT_SINGLE_CASE (for each changed Single case table)

CHANGEDOCUMENT_MULTIPLE_CASE (for each changed Multiple case table)

CHANGEDOCUMENT_TEXT_CASE (for text changes)

3. CHANGEDOCUMENT_CLOSE

0 Kudos

Hello jinku,

after some testing of your named FBs we have found a way how to process with our issue.

a) create a change document with the named FMs

by adding a "real change"

-> use FCODE = EXTE (not existing in SAP)

b) modify the CDPOS entries for value old / value new with our related changes from external

We checked for a change on a table field (here in MARA/MAKT) with only one entry resulting in CDPOS

which is MAKT-MAKTX for us.

Good luck for us:

- the change from a) is not used in the field of the transaction (no change in MAKTX, no idea why) but the change document overview in MM02/MM03 will display our external change information.

So we don´t need to do a second call to modify the field back to its original value.

Thank you for your help bringing us to the idea how to proceed!

Best regards

Dirk

Former Member
0 Kudos

Hi,

For tracing the change logs of manually made changes or some changes done from some custom program, I hope this will not require any CDHDR and CDPOS needs to be updated.

For viewing those changes, for that data base table or custom table in SM30, change logs, select the Append Table Changes check box to view the changes done manually.

For logging these changes, using the function module CHANGEDOCUMENT_OPEN, CHANGEDOCUMENT_SINGLE_CASE, and CHANGEDOCUMENT_CLOSE write the changes done at 01 event (Before saving the entries) of the table you required.

I hope this will fulfill your requirement.

Regards,

Santhosh.

Former Member
0 Kudos

Hello,

thank you for your answers. But I think I need to be more clear.

We need to add change documents for changes in an external DB into the change document history of SAP.

So we have to create NEW entries in CDHDR and CDPOS!

Best regards

Dirk

0 Kudos

Hi Dirk,

If u want to track changes made in ur custom table then u can change the technical settings of ur table and check the log data changes checkbox. Any modification done in this table will be logged into DBTABLOG table.

Regards,

Anil N.

0 Kudos

Hello,

no, I do not need to update any table in SAP but in an SQL database.

But we need to add change documents to CDHDR and CDPOS with a separate FNAME to

show that there were changes in this database.

This should be done via rfc.

The reason begind is that the user need to know about theses changes.

But I need to uodate the change no. with each insert in CDHDR/CDPOS so that it will be counted correctly in the change document tables and I need to display the "external change documents" in the

related transactions for material, BOM and documents (DIS).

Looks like this is a really bad idea!

And we have to work on it!

So, if you have any ideas.... please!

Best regards

Dirk

0 Kudos

<<copy&pasted_removed_by_moderator>>

The sample code is from the below website...

http://www.geocities.com/mpioud/Z_ALV_CDHDR_CDPOS.html

Edited by: Vijay Babu Dudla on Apr 28, 2009 9:03 AM

Former Member
0 Kudos

have a look at my last post to this thread