SAP AIF & E1IDOCENHANCEMENT: Dynamic IDoc extension without coding
Within the SAP Application Interface Framework (AIF), dynamic enhancements of IDocs can be used, which allows especially powerful & generic additions to standard logic without the need to adjust the IDoc types.
Note 2457381 introduces a generic enhancement to any IDoc type by adding segment E1IDOCENHANCEMENT dynamically.
This allows you to add additional data to an SAP standard IDoc type without a custom extension.
The result compared to the standard way:
- Time saving
- Less custom extension
- No additional ALE settings, like WE30, WE31, WE20
- No need to reupload the IDoc definitions
- Reduction of error sources
- Various types of IDoc extensions
- Additional global informations of the IDoc
- Especially powerful in combination with reusable AIF functions to build generic solutions like:
- Reference Document numbers or Duplicate check
Your system must support the dynamic enhancements. Therefore, two SAP notes must be applied:
The E1IDOCENHANCEMENT is a table, which consists of an 30 char “IDENTIFIER” fieldand the corresponding payload in the field “DATA”. Since it offers 970 chars for the payload in each line there are plenty of use cases.
There are some additions needed in the system to use this in SAP AIF:
- The SAP AIF Raw structure should include the component E1IDOCENHANCEMENT.
- This can be done in advance, by the check box “Add segment E1IDOCENHANCEMENT to the generated structure” in the AIF IDoc Structure Generator.
The resulting AIF structure includes now the table with corresponding SAP standard type:
- Otherwise, the segment will be filtered out before the IDoc is sent
- Best practice: create 2nd Port for all scenarios which are using the enhancement
For the implementation you are as flexible as the enhancement itself and can implement various use cases via the AIF structure mapping.
let’s just assume you want to add the username of the processor to the outbound IDoc to confirm the Flightbooking.
After the structure is enhanced as described above you can simply add this in AIF structure mapping. In this example the root structure is used to insert a new line in the E1IDOCENHANCEMENT.
During the AIF transformation a new segment will be added.
Next step is to define the identifier and the value.
In this case we map the identifier field to the value ‘USERNAME’ and the corresponding data should be mapped with the current user. Therefore we can use the standard functions of SAP AIF fieldmappings.
Now we could use the AIF transformation to test this:
Analogous to this example, we can use all standard AIF functions to enrich the IDoc with data without development. For example, we can use a value mapping to select and add data from tables like SFLIGHT.
The one Hook:
The dynamic enhancement must always be located at the end of the IDoc
The E1IDOCENHANCEMENT in SAP AIF can be used to extend IDocs quickly and easily. Especially when creating the IDoc structures via the AIF structure generator, the checkbox for adding dynamic enhancements should always be ticked in order to be able to use the segment at any time.
Since the segment can be used in every IDoc, especially generic IDoc extensions can be implemented effectively, since each IDoc uses the same structure for this.
Particularly in ALE, this results in a great time saving, as otherwise the extensions would always have to be set in the same way in both systems.
The only disadvantage to note is that the dynamic enhancement must always be the last segment of the IDoc. This means that it is particularly suitable for global extensions or extensions that are detached from the structure. If you want to extend sub-segments, you must find a way to determine the correct structure again via the identifier field. Here classical enhancements are more powerful in most cases.
Is it possible to "assign" the enhanced fields to specific segments (in lower hierarchy level) or is it used only for header level entries?
many thanks for your comment on this.
That's the only catch to the enhancement. It is needed that the E1IDOCENHANCEMENT is always the last segment in the IDoc and therefore always in the first level.
If you want to extend a segment in lower hierarchy position ( I.E. E1EDP19) with data, then you have to identify the corresponding segment via the identifier so that it can be assigned in the target system or use the classic ALE extension.