Q

Failing an IDoc in a user-exit

Our expert supplies code to fail an IDoc in a user-exit.

I have a requirement wherein a user exit must fail the IDoc for a given condition. The condition is clear but my question is how to fail the IDoc. I dont know if the control records are being passed to the exit or not. Do we need to change the control record status to say 51 etc..? This is an outbound IDoc.

Any help will be appreciated. Thanks.

The IDoc processing function module has a required parameter "IDOC_STATUS". Here you can enter as many status items as required. They all will appear in the WE05 listing, when an IDoc is displayed. The last entry in the table will become the final status of the IDoc. So if you add a status entry with STATUS-"51" (general error) or "52"= (Application error) you can set the IDoc to failure.

See this nice little function below, that fills the IDOC_STATUS table appropriately from values that are compatible with the SY-MSGV1 …..

function Z_LOGOS_IDOC_STATUS_FILL.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(DOCNUM) TYPE  EDIDC-DOCNUM OPTIONAL
*"     VALUE(STATUS) OPTIONAL
*"     VALUE(STATUS_ERROR) OPTIONAL
*"     VALUE(MSGID) OPTIONAL
*"     VALUE(MSGTY) OPTIONAL
*"     VALUE(MSGNO) OPTIONAL
*"     VALUE(MSGV1) OPTIONAL
*"     VALUE(MSGV2) OPTIONAL
*"     VALUE(MSGV3) OPTIONAL
*"     VALUE(MSGV4) OPTIONAL
*"     VALUE(APPL_LOG) TYPE  BALOGNR OPTIONAL
*"  TABLES
*"      IDOC_STATUS STRUCTURE  BDIDOCSTAT OPTIONAL
*"----------------------------------------------------------------------
*
  clear IDOC_STATUS.
  IDOC_STATUS-DOCNUM = DOCNUM.
  IDOC_STATUS-STATUS = STATUS.
  IDOC_STATUS-MSGTY = MSGTY.

  if MSGTY ca 'EAX' and not STATUS_ERROR is initial.
    IDOC_STATUS-STATUS = STATUS_ERROR.
  endif.

  IDOC_STATUS-MSGID = MSGID.
  IDOC_STATUS-MSGNO = MSGNO.
  IDOC_STATUS-MSGV1 = MSGV1.
  IDOC_STATUS-MSGV2 = MSGV2.
  IDOC_STATUS-MSGV3 = MSGV3.
  IDOC_STATUS-MSGV4 = MSGV4.
  IDOC_STATUS-APPL_LOG = APPL_LOG.
  append IDOC_STATUS.
*
endfunction.
This was first published in July 2006

Dig deeper on SAP security administration

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close