Using IDoc / Output Type special processing options

Share on Facebook15Share on LinkedIn0Tweet about this on TwitterShare on Google+0
Please Share!!

We had a specific requirement for creating Sales Order from Purchase Orders within the same SAP system. This was to happen in scenarios where we had an inter-company Purchase Order – a Plant in say Country X raises a PO for a Material which can be produced by another Plant in Country Y. Now both plants belong to the same Company but will have different Company Codes.

Normally for a PO we have a normal outbound EDI 850 (IDoc Type: ORDERS05) going to an external system (say EDI) using a middleware like SAP PI.

Then we also have the inbound EDI 850 (same IDoc Type) which creates a sales order (Transaction VA01) in SAP ECC.

In this case for Purchase Order (Application ‘EF’), instead of triggering the normal EDI 850 outbound to XI (Medium – ‘6’ for EDI) for our custom output type, we can use medium ‘8’ (Special Function). Then we need to specify a program and subroutine name. The subroutine should be like this:

The global structure nast is available in this subroutine. Here you can get the object key (objky) which will contain the PO number in this case.

[adToAppearHere]

The custom logic can be written as per our requirement. The triggering of the output conditions can be defined by the access sequences and routines associated with it. Only when the given conditions are satisfied, then the output condition is triggered which then calls the custom logic implemented in the subroutine.

For our scenario, in this structure we can get the PO data from concerned tables using the PO number available in nast.

This data can be populated into the IDoc structures and Inbound IDoc created using function module IDOC_INBOUND_WRITE_TO_DB. If you want this IDoc to be posted, you can do the same using IDOC_START_INBOUND.

Also Read: Sending Inbound IDocs from SAP Program

A good approach for doing this would be to do the IDoc population and triggering logic in background or a separate task.

Another quite useful trick for populating standard outbound IDocs for say PO’s in any custom program is by calling the standard SAP function module associated with that output type / outbound process code. Like example for PO if you want to populate the standard ORDERS05 outbound IDoc in your custom program, you can do the same just by calling IDOC_OUTPUT_ORDERS.

Note that in this case we would need to send the control data in wa_edidc and a dummy (but valid) PO number and other details in wa_nast. The user exits associated with this EDI / IDoc will also get triggered for this case. Any further customization during population can be done there.

The populated IDoc can then easily be created and transmitted using MASTER_IDOC_DISTRIBUTE.

If you want to get such practical issues and resolutions straight to your inbox, please SUBSCRIBE. We respect your privacy and take protecting it seriously.

If you liked this post, please hit the share buttons on your screen.

Thank you very much for your time!!

Share on Facebook15Share on LinkedIn0Tweet about this on TwitterShare on Google+0
Please Share!!

About the Author

Biswadeep Roy
Biswadeep Roy
Qualification: B.Tech, M.Tech from IIT Kharagpur, India. SAP ABAP Experience since 2006. Find more about him on LinkedIn.

5 Comments on "Using IDoc / Output Type special processing options"

  1. Krishnapriya | July 18, 2016 at 12:56 pm |

    If we use IDOC_OUTPUT_ORDERS to get the IDOC structure, will it not trigger the sending of IDOC also.

    My requirement is i only need the structure. dont want that FM to send the IDOC. I will later send it after manipulations.

    • Hello Krishnapriya,

      Function Module IDOC_OUTPUT_ORDERS will never send the IDoc. It will only populate the IDoc Structure. If you only need the IDoc metadata (i.e. list of structures and fields), you can also use function module IDOCTYPE_READ_COMPLETE

      Regards
      Biswa

  2. Got it..!!

    You mean to say.. the data will automatically be populated by the wa_nast..
    Nice one..!! thank you!

  3. Good document..!!
    But I could not understand, why we need IDOC_OUTPUT_ORDERS (IDOC_OUTPUT_) when we need to distribute outbound IDoc from our custom program.
    Can’t we simply/only use MASTER_IDOC_DISTRIBUTE (with control and data records populated).

    Maybe I’m wrong or missing something here…!!

  4. Biswa: This morning one of our lead copied code from this blog of yours and pasted it in my sametime.. 🙂

    We were configuring special function output type for MIRO.

    Thanks for your post.

Comments are closed.