Create your own function module. Suggestion:
master_idoc_create_<message type>. In the interface, you substitute the example parameters appl_head and appl_item with the application data you are using to create the IDoc.
Variable definition:
The first data statement can be copied. The second data statement must be adapted to the individual IDoc.
You can use (or even enhance) the block in which the distribution model is read. In this example, we used module ale_model_determine_if_to_send.
For all IDoc segment types with currency amounts, you can use form routine e1xitem_currency_sap_to_idoc as a template for writing your own conversion routine. We suggest the name:
<Segment type>_currency_sap_to_idoc.
For all IDoc segment types with fields for which ISO codes exist, you can use form routine e1xitem_codes_sap_to_iso as a template for writing your own conversion routine. We suggest the name:
<Segment type>_codes_sap_to_iso.
For all IDoc segment types with fields to be left-justified, you can use form routine e1xhead_condense as a template for writing your own routine. We suggest the name:
<Segment type>_condense.
You should set left-justification after conversion.
You must adapt the program parts in which the IDoc is created from the application data to reflect your own application structures and IDoc segments.
If the update program is executed for the application, master_idoc_distribute may also have to be called in update task.
Do not forget COMMIT WORK if one is not performed at a higher level. The database commit at the end of the transaction is not sufficient.