Skip to Content

Generally, while handling Outbound IDocs, it sometimes is diffucult to Error Out the IDocs forecefully when there is a requirement for the Developer to do the same. This may be because, prior to ERP 6.0, we did not have the Concept of Enhancement Framework. If someone would like to add his own Functionality before the IDoc is transmitted to the Middleware, one of the Options that one would have is to Customize the Development of the Selection Program and then incorporate the additional Functionalities required which cannot be coded in the Customer Exits available in any of the Outbound Selection Program.

             In this blog, I would like to bring out the Visible feature of the new Enhancement Framework available in ECC 6.0 which I’ve implemented for one of the Customers. The Scenario is when an Outbound Delivery is Saved or an Outbound Shipment is Saved, then the Output Type defined for that particular business document is processed and the IDoc is sent to the Ship-To Party as part of Delivery Notification or Advanced Shipment Notification.

             When Couple of Custom Segments and Fields are to be added to the Standard IDoc Type DELVRY05 or SHPMNT05, one way of Error Handling is to make the Segment Mandatory in the IDoc Definition itself so that if the Segment is missing in the IDoc, the IDoc is generated with an Error. However, we need to Understand that the Segment will not be populated if none of the Fields of the Segment contain Data. If any of the Fields are populated, then the Segment will be populated automatically. Now, the Enhancement that we use for Transportation EDI is V56K0001 (Transaction Code SMOD) in which we make use of the Customer Function EXIT_SAPLV56K_002 to populate the Custom Fields & Segments in the IDoc for Delivery & Shipment.

             One of the Methods that we follow for forcing the Outbound IDoc to Error out is to define an Internal Table, lets say, I_ERR_TAB with the following Structure.



               FLDNAM TYPE STRING,

          End of TY_ERR_TAB.



             Now, lets say there are 4 Fields which need to be Populated in the Custom Segment Z1EDL20 as a Child Segmen of the Standard Delivery Header Segment E1EDL20. If there is data for only 3 Fields, then rest of the two fields will not be populated. So, populate the Missing Segment Name & Field Name in the Error Table as below.

            WA_ERR_TAB-SEGNAM = ‘Z1EDL20’.

            WA_ERR_TAB-FLDNAM  = ‘TEXT1’.



            After Populating the I_ERR_TAB, construct a Unique Memory ID to which you can Export the Internal Table I_ERR_TAB. Example could be a Combination of the User Name and the String ASN followed by the SY-MANDT (Client Number) to make it a Unique. Ex: XYZASN900.

           Any outbound Selection Program accesses the Function Module IDOC_CREATE_ON_DATABASE to store the IDoc Number on the Database which is our Trump Card. Go to the Transaction Code SE37, Open the Function Module IDOC_CREATE_ON_DATABASE in display mode. Click on the Enhance Icon available on the Application Tool bar. Create an Implicit Enhancement Implementation, say ZI_ERR_HANDLING_ASN. Here, use the same Memory ID which we’ve constructed in the Customer Exit mentioned above and import the Internal Table I_ERR_TAB from the same Memory ID. We need to make Sure to define the variables in the same Structure as we’ve done in the Customer Function. Define another Internal Table of type BDIDOCSTAT to update the IDoc Status. If there are any entries in the I_ERR_TAB, then transfer the Contents of the Internal Table I_ERR_TAB to the Respective varaiables of the Internal Table I_IDOC_STATUS of type BDIDOCSTAT with an Error Status 26. Once this is done, finally we need to Call the Function Module IDOC_STATUS_WRITE_TO_DATABASE and pass the IDoc Number and the Internal Table I_IDOC_STATUS which will update the IDoc in the Database with an Error Status.

           This mechanism is helpful when there is a Requirement for the Developers not only to Error out the IDocs, but also to Send a Mail to a designated Person or a Group whenever any Outbound Delivery IDoc fails with respect to a Specific Output Type. We can use the Function Module SO_NEW_DOCUMENT_ATT_SEND_API1 to Trigger E-Mail to the intended Users / Group of Users when there is an Error in the IDoc, especially with respect to the Custom Segments.

          I hope this would be helpful for the Developers who work on IDoc Programming.

To report this post you need to login first.


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

  1. Subramanian PL
    Hi Venkat,
    Even though most of them who have worked in ECC6.0 know the concept of Enhancements, it is good to know how you can send mail about the errors using this new feature.


  2. Balaji A
    I ran into the similar situation earlier in ECC 5.0 with outbound IDocs. Couldn’t provide exactly what client had asked for as enhancement framework was not there at that time. The solution mentioned in the blog is a perfect fit.

    Your blog clearly explains the benefit of enhancement framework  with a very good example.

    Good Work !


Leave a Reply