Kishore Thutaram
SAP Solution Architect | 16+ Years' Experience in SAP | Sharing Practical SAP Knowledge | Engineering Graduate with Expertise in SAP Architecture
https://fiowelt.comIn real-world SAP integrations, sending standard invoice data is often not enough. Outbound IDOCs for external systems often require businesses to include additional custom fields.
In this guide, we’ll walk through how to send a customer invoice with custom fields using an IDOC extension, using real-time techniques followed in SAP projects.
A company needs to send invoice data to an external system, but standard IDOC segments do not include the following:
Because of this:
This requires extending the IDOC structure with custom segments and fields.
We solve this using:
What this solution does:
Configure outbound parameters for the invoice message type.
This ensures IDOC is triggered correctly.
ZZINVITM)If you’re new to IDOC structure and segments, understanding the data flow is important — refer to your guide on handling integrations, such as receiving sales orders via IDOC, which clearly explains the segment hierarchy.
Use:
EXIT_SAPLVEDF_002EXIT_SAPLV56K_002ZXEDFU02This is where custom logic is written.
If you’re unsure how to debug exits and enhancement logic, it’s worth checking your guide on debugging ABAP programs effectively to trace IDOC processing step-by-step.
SELECT matnr, zz_mchl1, zz_mchl2, zz_mchl3
FROM mara
INTO TABLE @DATA(lt_zzinvitm)
FOR ALL ENTRIES IN @lt_xtvbdpr
WHERE matnr = @lt_xtvbdpr-matnr.
LOOP AT int_edidd ASSIGNING <fs_edidd> WHERE segnam = 'E1EDP01'.
lv_index = sy-tabix + 1.
DATA(ls_custom_seg) = VALUE #( int_edidd[ lv_index ] OPTIONAL ).
IF is_int_edidd-segnam = 'E1EDP19' AND ls_custom_seg-segnam <> 'ZZINVITM'.
ls_e1edp19 = is_int_edidd-sdata.
DATA(ls_xtvbdpr1) = VALUE #( xtvbdpr[ matnr = ls_e1edp19-idtnr ] OPTIONAL ).
IF ls_xtvbdpr1 IS NOT INITIAL.
DATA(ls_zzinvitm) = VALUE #( lt_zzinvitm[ matnr = ls_e1edp19-idtnr ] OPTIONAL ).
IF ls_zzinvitm IS NOT INITIAL.
ls_edidd-segnam = 'ZZINVITM'.
ls_edidd-psgnum = 'E1EDP01'.
ls_edidd-sdata = VALUE zzinvitm(
zzmchl1 = ls_zzinvitm-zz_mchl1
zzmchl2 = ls_zzinvitm-zz_mchl2
zzmchl3 = ls_zzinvitm-zz_mchl3
).
INSERT ls_edidd INTO int_edidd INDEX lv_index.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
If performance issues occur while processing large IDOCs, follow best practices from your ABAP performance tuning techniques guide to optimize data handling.
ZXEDFU02Can we extend standard IDOCs?
Yes, using IDOC extensions (WE30/WE31).
Where do we write custom logic?
Inside user exits like EXIT_SAPLVEDF_002.
How to debug IDOC processing?
Use WE02 + breakpoints in exit include.
Can we add multiple custom segments?
Yes, based on business requirement.
Extending IDOCs to include custom invoice fields is a common real-world requirement in SAP integrations.
By using:
You can build scalable and reliable outbound integrations.

SAP Solution Architect | 16+ Years’ Experience in SAP | Sharing Practical SAP Knowledge | Engineering Graduate with Expertise in SAP Architecture
SAP Solution Architect | 16+ Years' Experience in SAP | Sharing Practical SAP Knowledge | Engineering Graduate with Expertise in SAP Architecture
https://fiowelt.com