Skip to Content
Technical Articles
Author's profile photo Jigang Zhang 张吉刚

Add customized message during Idoc outbound processing for output type

It’ll be very helpful to left logs at the Processing log when IDoc outbound been triggered for a specific output type. The standard program already takes care of normal process steps even with generated Idoc number.

What if we want to terminate Idoc output processing due to some failed validations? Take sales order’s EDI user-exit ‘EXIT_SAPLVEDC_004’ as an example, we can throw an exception with ‘DATA_NOT_RELEVANT_FOR_SENDING’.

But it’ll only display ‘No data was selected’ at the processing log which still hard to understand the reason why.

Here we can use the function ‘‘NAST_PROTOCOL_UPDATE’‘ to add logs with screen inactive check to prevent message added at display or preview.

  check xscreen = space.
  call function 'NAST_PROTOCOL_UPDATE'
    exporting
      msg_arbgb = syst-msgid
      msg_nr    = syst-msgno
      msg_ty    = syst-msgty
      msg_v1    = syst-msgv1
      msg_v2    = syst-msgv2
      msg_v3    = syst-msgv3
      msg_v4    = syst-msgv4
    exceptions
      others    = 1.

One place need to pay attention to is: the message ID must be a system message ID instead of customized ID, otherwise will get below C!002 error message.

Just go to table T100 (Messages table) and search by text equal to like ‘&1 &2 &3 &4’, and choose one system message ID from field ARGBG and its message number will do.

  CHECK screen = space.

  CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
    EXPORTING
      msg_arbgb = '0D'   "syst-msgid
      msg_nr    = '161'  "syst-msgno
      msg_ty    = 'E'    "syst-msgty
      msg_v1    = 'Contact Person'"syst-msgv1
      msg_v2    = 'missing'       "syst-msgv2
      msg_v3    = 'feild1'        "syst-msgv3
      msg_v4    = 'or field2.'    "syst-msgv4
    EXCEPTIONS
      OTHERS    = 1.

Finally, get this clear processing log as below:

 

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thanks for sharing!

      Not sure I understand the note about "system message ID instead of customized ID". I've used the FM you've mentioned many times before with either standard or custom message class. Yes, the message needs to be maintained in SE91 but, if I recall, it can be any message.

      Could it be that there was simply no message with such number in ZMSG class? I'm not sure where you got that error though, the wording about "work area" is confusing. Hm...

      I would caution against reusing random standard messages. We had experience before when a standard message was changed to completely different text. That was quite a surprise to the users after an upgrade. 🙂

      Author's profile photo Jigang Zhang 张吉刚
      Jigang Zhang 张吉刚
      Blog Post Author
      Hi  Jelena Perfiljeva, Thanks for the comments.
      You're right, that FM is wildly used for NAST output processing which can support system standard message class or customized message class. The scenario I encountered is EDI user exits like ‘EXIT_SAPLVEDC_004’ can't support customized message classes even with correct input parameters and SE91 maintenance.
      I agree that you mentioned potential issue after the standard message been upgrade. No better idea I can get now and hope it's a rare event 😀