IDoc Extension and Custom Segments
Learn how custom IDoc extensions and Z segments are designed and used.
Explanation
IDoc extensions are used when standard IDoc segments do not contain required custom fields. A custom segment is created and added to an extension at the correct position in the segment hierarchy. The sending system must populate the segment and the receiving system must understand it. Custom segment design should be minimal and stable because IDoc structures are shared with external partners and middleware.
Code example
* Purpose:* Conceptual example of adding custom segment data during outbound IDoc creation.* Actual enhancement location depends on message type and process. DATA ls_edidd TYPE edidd.DATA ls_zseg TYPE z1tax_info. * Fill custom segment structure with business datals_zseg-tax_code = lv_tax_code.ls_zseg-tax_text = lv_tax_text. * Set custom segment namels_edidd-segnam = 'Z1TAX_INFO'. * Move segment structure into SDATA payloadls_edidd-sdata = ls_zseg. * Append custom segment to IDoc data table at correct hierarchy positionAPPEND ls_edidd TO ct_idoc_data. * Important:* Segment must be added under correct parent.* Receiver or middleware must know the extension structure.Real project scenario
An INVOIC02 outbound IDoc needed custom tax classification data. A Z segment was added under the relevant invoice item segment and populated during outbound enhancement.
Common mistakes
- Adding custom segment at wrong hierarchy level. - Not updating partner or middleware mapping. - Creating too many custom segments. - Not documenting custom segment purpose.
Best practices
- Use standard segments where possible. - Keep custom segments minimal. - Place segment correctly in hierarchy. - Coordinate with middleware or receiver team.
Interview angle
Senior candidates should explain custom segment creation, extension assignment, population and receiver mapping.