Skip to content

Instantly share code, notes, and snippets.

@softy12
Last active November 29, 2020 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save softy12/7f85e27c5b18f77f3c4dbdac8df006c2 to your computer and use it in GitHub Desktop.
Save softy12/7f85e27c5b18f77f3c4dbdac8df006c2 to your computer and use it in GitHub Desktop.
SAP BW: program to check whether Process Chain ran successfully, see notes on http://blog.maruskin.eu/2017/09/how-to-get-notification-whether-process.html
REPORT zmm_check_if_pc_ran.
PARAMETERS: p_chain TYPE rspc_chain OBLIGATORY,
p_days TYPE i OBLIGATORY DEFAULT 30.
DATA: l_v_date TYPE sydatum,
l_t_logs TYPE TABLE OF rspc_s_log_f4,
l_v_logid TYPE rspc_logid,
l_v_status TYPE rspc_state,
l_t_clog TYPE rspc_t_msg,
l_s_clog TYPE rspc_s_msg.
FIELD-SYMBOLS: <fs_log_entry> TYPE rspc_s_log_f4.
l_v_date = sy-datum.
DO p_days TIMES.
CALL FUNCTION 'RSPC_API_CHAIN_GET_RUNS'
EXPORTING
i_chain = p_chain
i_date = l_v_date
TABLES
e_t_logs = l_t_logs
EXCEPTIONS
failed = 1
OTHERS = 2.
SORT l_t_logs BY datum zeit DESCENDING.
READ TABLE l_t_logs INDEX 1 ASSIGNING <fs_log_entry>.
IF sy-subrc EQ 0.
l_v_logid = <fs_log_entry>-log_id.
EXIT.
ENDIF.
l_v_date = l_v_date - 1.
ENDDO.
CALL FUNCTION 'RSPC_API_CHAIN_GET_STATUS'
EXPORTING
i_chain = p_chain
i_logid = l_v_logid
IMPORTING
e_status = l_v_status.
*- get PC's proceses details info
CALL FUNCTION 'RSPC_API_CHAIN_GET_LOG'
EXPORTING
i_chain = p_chain
i_logid = l_v_logid
TABLES
e_t_log = l_t_clog
EXCEPTIONS
error_message = 1.
CASE l_v_status.
WHEN 'G'.
WRITE: / 'PC', p_chain, 'ran succesfully on', <fs_log_entry>-datum, 'at', <fs_log_entry>-zeit.
WHEN 'R'.
WRITE: / 'PC', p_chain, 'failed on', <fs_log_entry>-datum, 'at', <fs_log_entry>-zeit.
WHEN OTHERS.
ENDCASE.
WRITE: / 'Following are detials abotu particular proesses within the PC:'.
LOOP AT l_t_clog INTO l_s_clog.
WRITE: / l_s_clog-msgid, l_s_clog-msgno, l_s_clog-msgty, l_s_clog-msgv1, l_s_clog-msgv2, l_s_clog-msgv3, l_s_clog-msgv4.
ENDLOOP.
*- collect info from <fs_log_entry> and l_t_clog and send it over email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment