• April 9, 2026
  • Kishore Thutaram
  • 0

Introduction

In real-time SAP integrations, standard IDOCs often do not fulfill all business requirements. Especially in Purchase Order scenarios, businesses need to send additional custom fields to external systems for better tracking and processing.

This article explains how to extend a Purchase Order IDOC and send custom fields using enhancements in SAP.

SAP Purchase Order IDOC with custom fields extension

Business Scenario

A business needs to send Purchase Order data to an external system, but the standard IDOC does not include:

  • Sales Order reference
  • Custom mapping fields
  • Additional business-specific attributes

Because of this:

  • External systems miss critical data
  • Manual intervention increases
  • Integration becomes inefficient

To solve this, we enhance the IDOC with custom segments and fields.

Solution Overview

We use the following approach:

  • Extend standard IDOC using WE30 / WE31
  • Implement enhancement using a user exit
  • Populate custom data dynamically

Key Benefits:

  • Seamless outbound integration
  • Custom data availability
  • Scalable and reusable solution

Step 1: Configure Partner Profile (WE20)

Maintain outbound parameters for Purchase Order IDOC.

Ensures IDOC is triggered correctly during output processing.

Screenshot 1
Screenshot 2

Step 2: Create IDOC Extension (WE30 / WE31)

  • Create a custom segment (e.g., ZZE1EDP01)
  • Add required fields

Understanding IDOC structure is important here — if you’re new, you can refer to your article on receiving IDOCs to understand segment hierarchy and flow.

Screenshot 3

Step 3: Implement Enhancement Logic

Use:

  • Function Module: IDOC_OUTPUT_ORDERS
  • Exit: EXIT_SAPLEINM_011
  • Include: ZXM06U33

This is where custom logic is written.

If you want to trace how data flows through exits, it’s helpful to understand how to debug ABAP programs to analyse runtime behaviour effectively.

Step 4: Populate Custom Segment Data

CONSTANTS: lc_zze1edp01 TYPE edidd-segnam VALUE 'ZE1EDP01',
lc_e1edp01 TYPE char7 VALUE 'E1EDP01'.

DATA: ls_e1edp01 TYPE e1edp01.

SELECT ebeln, ebelp, vbeln, vbelp
FROM ekkn
INTO TABLE @DATA(lt_ekkn)
WHERE ebeln = @dekko-ebeln.

LOOP AT dint_edidd ASSIGNING FIELD-SYMBOL(<lf_dint_edid_l>)
WHERE segnam = lc_e1edp01.

DATA(lv_index) = sy-tabix.

ls_e1edp01 = CONV e1edp01(<lf_dint_edid_l>-sdata).

DATA(ls_ekkn) = VALUE #( lt_ekkn[ ebelp = ls_e1edp01-posex ] OPTIONAL ).

IF ls_ekkn IS NOT INITIAL.

DATA(ls_zze1edp01) = VALUE zze1edp01(
zkdauf = ls_ekkn-vbeln
zkdpos = ls_ekkn-vbelp
).

DATA(ls_new_edidd) = VALUE edidd(
segnam = lc_zze1edp01
sdata = ls_zze1edp01
).

INSERT ls_new_edidd INTO dint_edidd INDEX lv_index + 1.

ENDIF.

ENDLOOP.

Step 5: Test Output (WE02)

  • Trigger PO output
  • Check IDOC in WE02
  • Verify custom segment values

While processing large volumes, always follow ABAP performance tuning techniques to avoid slow execution.

Common Mistakes Developers Make

  • DOC not triggered → Check WE20 configuration
  • Custom segment missing → Verify exit logic
  • Data not populated → Debug include ZXM06U33
  • Wrong mapping → Validate EKKN data
  • Performance issues → Avoid SELECT inside loops

Frequently Asked Questions

1. Can we extend standard Purchase Order IDOC?
Yes, using WE30/WE31 you can create custom segments and extend IDOCs.

2. Where do we write custom logic?
Inside user exits like EXIT_SAPLEINM_011.

3. How to debug IDOC processing?
Use WE02 and set breakpoints in the exit include.

4. Can we add multiple custom segments?
Yes, based on business requirements.

5. Is this approach suitable for S/4HANA?
Yes, this works in both ECC and S/4HANA systems.

🎉 Final Thoughts

Extending Purchase Order IDOCs is a common requirement in SAP integrations. By using:

  • IDOC extensions
  • User exits
  • Efficient ABAP logic

You can build a robust and scalable outbound integration solution.

Share article

Kishore Thutaram

SAP Solution Architect | 16+ Years' Experience in SAP | Sharing Practical SAP Knowledge | Engineering Graduate with Expertise in SAP Architecture

https://fiowelt.com

Leave a Reply

Your email address will not be published. Required fields are marked *