Lesson Overview
In order to enhance an ALE scenario that includes the transfer of additional fields, you have enhanced an IDoc type. This lesson discusses all the steps required for enhancing outbound processing. It is assumed that the enhancement is based on a table append, and that current data is entered in the append fields. You want to enhance outbound processing so that the contents of the table append fields are copied into the corresponding segment fields, and the segment is inserted into the master IDoc. The field types used mean that conversions are required that exceed the automatic type conversion of theMOVEstatement.
Lesson Objectives
After completing this lesson, you will be able to:
• List the steps required for implementing an enhancement in outbound processing
Business Example
The material master has been enhanced. In addition to the fields allocated by SAP, information on the cheapest competitor product is also entered and saved in the application documents. To achieve this, the database tableMARAhas been enhanced by the addition of a table append from the
APPENDstructureYBIT350. This enhancement should also take effect in the ALE scenario for material master distribution. The customer fields are to be transferred with the IDoc for the message typeMATMAS. For this purpose, an enhancement of the IDoc typeMATMAS03has been created that contains an additional segment as a subsegment ofE1MARAM. In the outbound program that structures the master IDoc for the IDoc typeMATMAS03, you now want to fill the additional customer segment and insert it into the master IDoc. If possible, you want to achieve this using an enhancement.
In many applications, it is already possible to enhance an ALE scenario using customer fields. Immediately after attaching an SAP segment to the master IDoc, an enhancement is provided. You can then use this enhancement to fill a customer segment. Application development can enable this in the following ways:
• The application calls an enhancement that returns a structure of the typeEDIDDto the program. In the enhancement, enter the name of your segment type in the fieldSEGNAM, and enter the data for the
segment in the fieldSDATA. Immediately after the enhancement, the program checks whether the structure contains a permitted customer segment, and attaches the segment to the master IDoc.
• The application calls an enhancement that is contained in the master IDoc as the interface parameterTABLES. In this example, you enter the segment data into a structure of typeEDIDD, and insert it beneath the parent segment in the master IDoc.
You also need to change the control record before the function module
MASTER_IDOC_DISTRIBUTEis called: Enter the enhancement in the fieldCIMTYP. You have the following options for doing this:
• The enhancement of the application contains anEXPORTparameter, which is used to transfer the name of the enhancement to the application program. The application program copies this name into the corresponding field of the control record before calling the function moduleMASTER_IDOC_DISTRIBUTE.
• The enhancement contains aCHANGINGparameter for the control record.
In this case, you can copy the name of the enhancement directly into the fieldCIMTYPof this parameter in the enhancement.
Figure 61: Example: Enhancement in the Program
your enhancement to the IDoc type MATMAS03. The application program copies this name into the control record before it calls the function module
MASTER_IDOC_DISTRIBUTE.
Figure 62: Implementing the Enhancement in Outbound Processing In this example scenario, you want to fill the customer segmentZ1BIT350 with values from the table append for the tableMARA. In the outbound programMASTERIDOC_CREATE_MATMAS, a customer exit is called after the segmentE1MARAMhas been created and the segment has been inserted in the master IDoc (line 251):
APPEND T_IDOC_DATA.
The names of the message type and the current segment type are transferred to the enhancement. The parameterF_MARAis used to transfer the row of the database tableMARA(including the fields of the table append) to the enhancement. Some lines previously, this structure is filled using
SELECT SINGLE * FROM MARA. The fields of the table append are therefore not only contained in the structureMARA, but are also filled with the current field values from the database table of the sending system. It is therefore unnecessary to re-access the database tableMARAwithin the enhancement.
Within the enhancement, you need the following data objects:
• Internal table for the master IDoc
The application program transfers the master IDoc using theTABLES parameterIDOC_DATA.TABLESparameters technically act in the same way asCHANGINGparameters. You can contact the data object directly using the parameter name.
• Structure for the customer segment with row type
EDIDD
Fill this segment with the required data from the control part and the data part, and attach it to the master IDoc. Because the master IDoc is transferred as theTABLESparameterIDOC_DATA, andTABLESparameters are always internal tables with header lines, you can use the header line. We explicitly define a help structure with the nameEDIDD_S.
• Structure with the row type of the segment type
This structure contains all fields of the customer segment with the data types of the external format. This help structure simplifies the conversion from internal to external format.
• Structure with application data, with the row type of the database table MARA
This structure is transferred to the enhancement as theIMPORT parameterF_MARA.
Within the enhancement, you need to carry out the following steps:
• Convert the fields of the table append into external format
• Copy the field contents in external format into the corresponding fields of the structure with the segment type
• Copy the structure with the segment type into the fieldsdataof the structure with row typeedidd
• Copy the name of the segment type into the fieldsegnamof the structure with the row type edidd.
• Attach this structure to the internal tableidoc_data.
• Enter the name of the IDoc type enhancement in the export parameter
idoc_cimtype.