Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
Sometimes if the inbounding IDOC can't meet a specific validation check then need to terminate the IDOC Inbound processing and mark errors accordingly at IDOC status records.

Take standard process code ORDE as an example, it processes inbound IDOC using the function module 'IDOC_INPUT_ORDERS' to create sales orders.

1. Where to add customized validation logic

All user exits are available here starting with 'CALL CUSTOMER-FUNCTION', we can check the inputs/outputs of those function modules to decide which one should be used. One article explains how to find an SAP Enhancement when we know the Exit function module.

For this case, the user exit '009' at routine 'CHECK_IDOC_ORDERS' will be a good one that contains all the details of the sales order and also the IDOC control table&data table. We can add customize code inside to manipulate no matter values for SO creation or Idoc status.

2. How to populate customized validation results to IDOC

Two options here: append an error message to the internal table ERRTAB or update the entry at the IDOC control table idoc_contrl.
DATA: ls_e1edk01 TYPE e1edk01,
ls_edidd TYPE edidd.
IF dedidc-mestyp = 'ZORDR_IDOC1'. "IDOC msg type
CLEAR ls_edidd.
READ TABLE dedidd INTO ls_edidd
WITH KEY segnam = 'E1EDK01'. "Idoc data
IF sy-subrc EQ 0.
MOVE ls_edidd-sdata TO ls_e1edk01. "segment data
IF ls_e1edk01-action = 'XXX'. "customized valdation
"<option #1>: add to internal table derrtab
MOVE '00' TO derrtab+20(20).
MOVE 'E' TO derrtab+40(1).
MOVE '001' TO derrtab+41(3).
MOVE 'EDI Support team review needed cause XXX' TO derrtab+167(50).
APPEND derrtab.
CLEAR derrtab.
"<option #2>: add to status table idoc_status
* ls_EDIDC-docnum = docnum.
* ls_EDIDC-status = beleg_nicht_gebucht.
* ls_EDIDC-msgty = 'E'.
* ls_EDIDC-msgid = '00'.
* ls_EDIDC-msgno = '001'.
* ls_EDIDC-msgv1 = 'EDI Support team review needed cause XXX'.
** idoc_status-msgv2 = lieferant.
* APPEND ls_EDIDC to idoc_status.

3. A few points to note

  1. Internal table ERRTAB will be refreshed if the only error message is VG219 (Suitable schedule agreement &1 &2 with the reason for rejection has been found).

  2. Internal table ERRTAB will be appended to IDOC_STATUS only when input_method is initial (ex. debug at front-end using WE19 will be skipped totally!)


PS: If SAP Blog provides a private flag, maybe I’ll set it for many of my posts because the same topic has been discussed many times and I couldn’t write a better one compared with the existing one. Still, sometimes it’s difficult to figure the issue out with help of GOOGLE and the community, or it may take hours to validate various solutions. So in most cases, I summarize related details and record my finding as a reminder. I’m glad if it helps others by chance, if it doesn’t, please forgive me keep posting such content without any buzzword.

Labels in this area