Kishore Thutaram
SAP Solution Architect | 16+ Years' Experience in SAP | Sharing Practical SAP Knowledge | Engineering Graduate with Expertise in SAP Architecture
https://fiowelt.comIn many SAP integration scenarios, it’s important to notify external systems when a sales order item is rejected. Standard IDOCs do not always filter or send only rejected items, which can lead to unnecessary data transfer and confusion in downstream systems.
This article explains how to send only rejected sales order items using IDOC by implementing output control and enhancements in SAP.
A business needs to send only rejected sales order items to an external system in real time for accurate order processing and exception handling.
To achieve this requirement, we:
This ensures IDOC communication is properly configured.
To send IDOC only when rejection happens:
Sample Logic for Rejection Check
FORM KOBEV_903.
FIELD-SYMBOLS : <lft_yvbap> TYPE tab_xyvbap,
<lft_xvbap> TYPE tab_xyvbap.
DATA: lv_subrc TYPE sy-subrc.
lv_subrc = 4.
ASSIGN ('(SAPMV45A)YVBAP[]') TO <lft_yvbap>.
ASSIGN ('(SAPMV45A)XVBAP[]') TO <lft_xvbap>.
LOOP AT <lft_xvbap> ASSIGNING FIELD-SYMBOL(<lfs_xvbap>)
WHERE abgru IS NOT INITIAL.
IF <lft_yvbap> IS ASSIGNED AND <lft_yvbap> IS NOT INITIAL.
DATA(ls_yvbap) = VALUE #( <lft_yvbap>[ posnr = <lfs_xvbap>-posnr ] OPTIONAL ).
IF ls_yvbap-abgru NE <lfs_xvbap>-abgru.
lv_subrc = 0.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
sy-subrc = lv_subrc.
ENDFORM.
To ensure only rejected items are sent, implement logic in IDOC enhancement.
Enhancement Details:
EXIT_SAPLVEDC_001ZXVEDU01This logic ensures only latest rejected items are sent:
DATA: lv_time TYPE sy-uzeit.
IF edidd[] IS NOT INITIAL.
RETURN.
ENDIF.
IF dxvbap IS NOT INITIAL.
lv_time = sy-uzeit - 10.
SELECT tabname tabkey
FROM cdhdr
INNER JOIN cdpos
ON cdhdr~objectclas = cdpos~objectclas
AND cdhdr~objectid = cdpos~objectid
AND cdhdr~changenr = cdpos~changenr
INTO TABLE @DATA(lt_cdpos)
WHERE tabname = 'VBAP'
AND fname = 'ABGRU'
AND udate = @sy-datum
AND utime GT @lv_time.
LOOP AT dxvbap INTO DATA(ls_dxvbap).
DATA(lv_tabkey) = sy-mandt && ls_dxvbap-vbeln && ls_dxvbap-posnr.
READ TABLE lt_cdpos WITH KEY tabkey = lv_tabkey TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
DELETE ct_dxvbap WHERE vbeln = ls_dxvbap-vbeln
AND posnr = ls_dxvbap-posnr.
ENDIF.
ENDLOOP.
ENDIF.
Verify that:
After triggering the IDOC, verify the following:
❌ Not assigning the output determination routine in configuration
❌ Incorrect logic while comparing XVBAP and YVBAP tables
❌ Forgetting to filter non-rejected items in IDOC enhancement
❌ Not using change pointers, leading to duplicate or unnecessary data
❌ Missing partner profile configuration in WE20
1. How do we trigger IDOC only for rejected items?
By implementing a custom output control routine in VOFM.
2. Which field indicates rejection in sales order?
Field ABGRU (Reason for Rejection).
3. Why use change pointers in this scenario?
To capture only recent changes and avoid sending duplicate data.
4. Can this be extended for other conditions?
Yes, similar logic can be applied for delivery blocks, pricing changes, etc.
Sending only rejected sales order items via IDOC is a smart way to optimize integrations and reduce unnecessary data exchange. By combining output control, enhancement logic, and change pointer techniques, you can ensure that only relevant data is sent to external systems.
Once implemented correctly, this approach improves performance, accuracy, and overall integration efficiency in SAP landscapes.

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