Ask the Expert

Failing 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.

    Requires Free Membership to View

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: