Skip to Content

Introduction

Sometimes there is a requirement where we need to make some changes in delivery header through custom program but we need to update the change log of delivery for those changes.

Like here we are discussing a case where we need to update the LIKP table of delivery header through ABAP code like deleting or changing some header field’s value. LIKP is a standard Sales and Distribution table available within R/3 SAP systems depending on the version and release level.

As changes done directly in delivery header get reflected in Changes option of Environment tab of header. Our requirement is to achieve similar thing when changes are done through program code not in the delivery directly.

STEPS:

How updation of change log is done in SAP:

The change log of delivery header is updated through CDHDR and CDPOS tables.

  1. e.g.Let’s take an outbound delivery 82342514 and make changes in it’s header.

/wp-content/uploads/2014/09/1_532393.jpg

Go to header in change mode.

/wp-content/uploads/2014/09/2_532427.jpg

Currently, the shipment reason maintained is ‘Complete Delevery Bl’.

Let’s remove it.

/wp-content/uploads/2014/09/3_532428.jpg

And save the delivery.

After saving the delivery, shipment reason (TRSPG) gets removed in LIKP.

/wp-content/uploads/2014/09/4_532429.png

Also, the updation in LIKP is followed by CDHDR and CDPOS tables updation.

Following entries appear in tables CDHDR  and CDPOS.

/wp-content/uploads/2014/09/5_532433.png

/wp-content/uploads/2014/09/7_532434.png

As we can see from above tables, all the data regarding the change we did is recorded in CDHDR table along with a ‘change number’ which is used for searching in CDPOS table for that particular change .The new value and old value are also specified in the CDPOS table.

Since, these tables got updated , changes are also reflected in Change log of delivery.

Go to Environment -> Changes in delivery’s header.

/wp-content/uploads/2014/09/9_532435.jpg

This thing we need to remember regarding changes done in master data that they get recorded in these two tables and can be used in custom reports or functionalities based on transactional change and master data change.

As in this case, we have made change direct in delivery , so it’s getting reflected in these tables but in case we update it through custom code we need to update CDHDR and CDPOS tables also through our code.

STEPS for updating CDHDR and CDPOS tables through custom program.

1.    Before updating LIKP table in custom code, extract the old values of LIKP in a work area.

2.    After updating LIKP, take the new values of LIKP for that particular vbeln in a work area.

3.    Call Function module ‘CHANGEDOCUMENT_OPEN’ passing vbeln as object id, object class as ‘LIEFERUNG’. Please note that proper object class needs to be specified. In this case it is ‘LIEFERUNG’ , since the object being discussed is delivery data.

4.    Call function module ‘CHANGEDOCUMENT_SINGLE_CASE‘ passing tablename as LIKP, workarea_new as new values work area and workarea_old as old LIKP values work area.

5.    Call function module ‘CHANGEDOCUMENT_CLOSE’ passing the values given below .This FM will  provide a change number LIKE  CDHDRCHANGENR. This indicates that CDHDR and CDPOS tables are getting updated through these function modules along with change number.

Summary: As we have updated these tables, we are able to update the change log of delivery through this.Reference code can be found in attached document.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Raymond Giuseppi

    Risk with this kind of code is to forget to update some other tables : Suppose you have BW on your system, and the Datasource extractor use those fields, here the changes wont be reported to BW as FM  MCEX_UPDATE_12 wont be called.

    Also for delivery, you could have use FM LIEFERUNG_WRITE_DOCUMENT which wraps the change documents FM.

    Regards,

    Raymond

    (0) 

Leave a Reply