Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

IDOC_Error_raising

Former Member
0 Likes
603

Hi..

I want two scenarios while processing the IDOCS:--

1) I want to Raise IDOC_ERROR if the conditions are not met.

2) I want to write those error messages in teh IDOC status record.

I have made a Single Perform to raise error and will call that PERFORM for the required segment.

Please tell me how to proceed.

Thanks.

Hi..

I want two scenarios while processing the IDOCS:--

1) I want to Raise IDOC_ERROR if the conditions are not met.

2) I want to write those error messages in teh IDOC status record.

I have made a Single Perform to raise error and will call that PERFORM for the required segment.

Please tell me how to proceed.

Thanks.

3 REPLIES 3
Read only

Former Member
0 Likes
572

Hi Subhash,

You can code something like this.

1) I want to Raise IDOC_ERROR if the conditions are not met.

* Check if right IDOC type
  loop at idoc_contrl.
    if idoc_contrl-idoctp <> 'SOPGEN01'.
      raise wrong_function_called.
    endif.
  endloop.

2) I want to write those error messages in teh IDOC status record.

* Fill status records of IDOC with status after posting
  loop at idoc_contrl.
    clear idoc_status.
    idoc_status-docnum = idoc_contrl-docnum.
    if sy-subrc = 0.
      idoc_status-status = '53'. "OK!
    else.
      idoc_status-msgid = sy-msgid.
      idoc_status-msgty = sy-msgty.
      idoc_status-msgno = sy-msgno.
      idoc_status-msgv1 = sy-msgv1.
      idoc_status-msgv2 = sy-msgv2.
      idoc_status-msgv3 = sy-msgv3.
      idoc_status-msgv4 = sy-msgv4.
      idoc_status-status = '51'.         "ERROR!
*     Fill Return variables
      clear return_variables.
      return_variables-doc_number = idoc_contrl-docnum.
*     return_variables-wf_param = c_wf_par_processed_idocs.
      return_variables-wf_param = 'Error_IDOCs'.
      append return_variables.
    endif.
    append idoc_status.
  endloop.

* Fill result of whole processing
  workflow_result = 0.
  in_update_task = true.

Hope this will help.

Regards,

Ferry Lianto

Please reward points if helpful.

Read only

Former Member
0 Likes
572

Hi,

if the data is wrong. then create an entry in the status table.


  IF L_E1EDK03-IDDAT = C_016 AND L_DATUM > SY-DATUM.
      CALL METHOD APPEND_STATUS_TABLE
        EXPORTING
          DOCNUM = IDOC_NUM
          MSGID  = 'VV'
          MSGTY  = 'E'
          MSGNO  = '027'
          MSGV1  = TEXT-003
          MSGV2  = TEXT-004
          MSGV3  = ' '
          MSGV4  = ' '.
    ENDIF.

METHOD APPEND_STATUS_TABLE.

  DATA:L_STATUS LIKE LINE OF  IT_STATUS.

  L_STATUS-STATUS = '51'.
  L_STATUS-DOCNUM = V_IDOC.
  L_STATUS-MSGTY  = MSGTY.
  L_STATUS-MSGID  = MSGID.
  L_STATUS-MSGNO  = MSGNO.
  L_STATUS-MSGV1  = MSGV1.
  L_STATUS-MSGV2  = MSGV2.
  L_STATUS-MSGV3  = MSGV3.
  L_STATUS-MSGV4  = MSGV4.
  L_STATUS-REPID  = 'SAPLZSD_SCS'.
  APPEND L_STATUS TO IT_STATUS.
  CLEAR  L_STATUS.

ENDMETHOD.     "Append_status_table

Regards

vijay

Read only

Former Member
0 Likes
572

Like Ferry has mentioned, update the status record that automatically give a RED flag to the IDOC status.

You don't have raise a exception separately.

Regards,

Ravi