Skip to Content
Technical Articles
Author's profile photo Maciej Jarecki

Configure EDI Message Control base on Purchase Order case

The main purpose of this webblog is to show how to configure message control to send customer created Idoc to external system. This example bases on purchase order case.

Business scenario

Usually sap system is configured that after purchase order has been created or changed, system bases on predefined message control process sends SAP standard Idoc with message type ORDERS. In most cases this solution is sufficient and company dose not have to change anything. But on the other hand it has limitation like Idoc is sent just only for some purchase order type with is set in message control or in distribution model for orders filter and valid to transfer only data for selected plants or storage locations.


I will create custom Idoc that will contain relevant data from our point of view. After purchase order has been created or changed system will send this Idoc to external system base on our condition with will be Vendor coming from PO.


I will split this blog into two parts. First one is to configure Message Control and second one is to create and configure Idoc.


To the first part includes following tasks:

  • Create condition table
  • Create Access Sequence
  • Create Output type.
  • Assign Output type to active procedure
  • Append new records to condition table
  • Set new output type to be taken into account when PO is created or changed


Condition table is normal table with contain structure and value to with our purchase order will be compared after change or create new one. In our case this table will contain only one column Vendor. To create it, use tcode VOK3

Next enter table number which should be higher than 900. Number below 900 are reserved for sap standard application. Fill it in with 907 and go next. On this screen on right side we see available fields to which affected purchase order can be compared with. We can append some new fields but this is beyond the scope of this blog. Let’s double click on vendor and then “Generate” button.

Log will appear.


Now we have table where we will insert Vendors for with changed or created new one PO should be compared based on PO-Vendor filed. You can display content of this table like any other using SE16N with name B and table number. In this case it will be B907.


Access sequences is some kind of linkage between message control and Condition table. One access sequences can have multiple access so it means number of condition tables assigned to it.


From VOK3 -> Purchasing Document -> Purchase Order ->Access Sequences.

Now choose new entry and insert “Z2AS” and description as you wish, I propose “Custom solution from PO” and hit save. Now on access sequences level we see our new line. Select it and click “Accesses” from left menu. Then “New Entries” and insert “10” and 907 in Tab column. In “Requirement” you can enter routing number with point to some abap code that additional can limit execution of Access sequence. This can be maintained via tcode V/27. Last column indicate if purchase order comply this requirement system should stop checking others access sequences. We leave this field unchecked.



Now double click on Field from left menu and we should see something like that


Fill access field with value 10 and we should see something like that.



Now it’s time to create output type. This part of message control solution is responsible to indicate which access sequence will be used and how output will be handled.

Go to tcode Nace


Select Application “EF” and then “Output types”.

Then you see all output types for selected application and not only to EDI processing.

Hit “New Entries”


Important is to select proper access sequences that we created before and tick access to conditions. Then switch to “Default values” tab and fill it like that.


Now in output types select created one Z2MM and click on Mail title and texts. Enter EN description.



Now click “Processing routines” and fill like below.


Program RSNASTED and form routine EDI_PROCESSING.



I last node of output types we enter how our Purchase Order will be processed. We would like to send Idoc so it will be EDI and function Logical system (LS).


The next step is to assign output type to current procedure. We can have many procedures defined for application but only one can be active. Procedure finally describes process of selecting appropriate output types. Let’s us add our own solution at the end of the list.


Value of step column depends on how many steps are before our solution. Column requirement like before point to Abap include that have to be execute to check does our PO is valid to be selected. We leave this field blank. Manual entry describe that message can be send only manually by user. In our case do not check it.

After we have created condition table it’s time to enter value to which our PO will be compared to. In “Nace” transaction select application “EF” and double click on condition records. Then click on our new output type and you will see following screen.


Our condition table contain Vendors to with PO vendor will be checked against. Press execute and  now enter new Vendor number. In Funct column LS for logical system and partner witch will receive our idoc. In message transition medium chose 6 “EDI” and dispatch time it is 4 “save immediately (when saving the application)”. Language is EN for English.


The last step to configure our message control processing in part one is to define what kind of output type will be generated in me21n and me22n. To achieve it go to VOK3then


PurchaseOrder -> Messages – >Fin-Tuned Control.



We need to enter that our output type is available for new PO and for changed one.


So add two record, first for new one like screen below

And second one for change

The only one difference is in first column witch indicate is it record for new
purchase order or to change one.

Now the first part of our new solution is ready. Now we have to create and configure new idoc.

In second I have to achieve following tasks

  • Create      new idoc
  • Create      function module
  • Assign      function module to created idoc
  • Configure      partner profile

To create new idoc first we need to develop new segment that will organize idoc’s structure. We use WE31tcode to create new segment,

Let’s fill all required fields like below.

It’s very simply idoc that will be performed our audit reason.

  • APPL describe how kind of message control is send in our case it is “EF”
  • OBIEKT in this case it is PO number that has been changed or created
  • MTYP describe output type
  • KTO means, user that created or changed PO
  • BORTYP means what kind of BOR it is


Save it and don’t forget to release it from Edit-> set release.

Now go to tcode WE30  where you generate finale structure of idoc. Fill all necessary fields and create new structure like on below screen shot


Save it and don’t forget to release it from Edit-> set release.

Because one Idoc can be use in many business cases like order which is used to send purchase order and to receive sales order from Customer, it has number of message types.

Go to WE81 and append new message type. I have created message like that

Now it’s time to assign message type to idoc. To do this we need to use WE82 tcode

Append New Line with fallowing settings.

In first column we have Message Type created in WE81 and in second column we have Idoc basic type created in WE30. Ok after we have structure of our new idoc it’s time to write function module that will fill this structure. To do this go to tcode SE37and create new function module wit code like below.

*”*”Global Interface:




control_record_out-direct = ‘1’.
control_record_out-serial = sy-datum.
control_record_out-serial+8 = sy-uzeit.
control_record_out-mestyp = C_message.
control_record_out-idoctp = C_idoc.
*control_record_out-rcvprt = ‘LS’.
*control_record_out-rcvprn = ‘A000000006’.







Please remember that function module that is able to send idoc from message control has standard parameters for this kind of output. In code we declare what kind of idoc and with segments this message will contain and also what data will be in it.


Now when we have function module we have to point that our idoc will be processed by this function module. To do this use tcode WE41. Hit New entries and fill it with following values.

The most important is function module that should point to FM created in previous task.

Now from left menu chose logical message and add our Idoc message type like below.


The last step is to configure partner profile. Go to tcode WE20. From left menu select Partner type LS and chose same partner type that you append in condition table. You will see inbound and outbound messages form selected partner. To Outbound parmtrs add new record. In Output Option fill Message Type with “Z2_PO_MC_MJ”, select transfer Idoc immed and for Basic Type write Z2_MC_OUTPUT_MJ.



Next go to Message Control tab. Add two new entries for our Idoc. First for Idoc that will be sent when Purchase order will be created and second one when someone change some relevant information in PO. The last column indicate is it new or change. Application for PO is EF, Message Type is our new created message type and Process code is Z2_PO_MJ.

Hit Save and when you return to WE20 tcode you should see new record in outbound table.


OK everything is done .Now it’s time to test it. Go to ME21Nto create new purchase order for vendor you entered in condition table assigned to our output type.


And in messages associated with this PO we should se our Output Z2MM.


Now we can go to tcode ME22Nand change something to PO.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Abdul Hakim
      Abdul Hakim
      Your blog is very nice.
      Keep up the good work.

      Warm Regards,
      Abdul Hakim

      Author's profile photo Raja Thangamani
      Raja Thangamani
      Nice blog...