Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.