NextTables Knowledge Base

How to start a process chain with NextTables

Written by Sebastian | Mar 1, 2021 9:23:49 AM

NextTables is a very flexible tool and offers many customization options. For example, you can start process chains from NextTables and also check the status. In this article you will learn how to do it.

Create buttons

You can create your own buttons in NextTables and also group them. The customer-specific buttons are defined in the BAdI SET_META_EXIT.

You can find a detailed explanation of how to create buttons in the Knowledge Base article “How to create Custom Buttons in NextTables”. In the article “How to implement a BAdI for NextTables” you will learn how to create a BAdI.

Below you will find the code for our example. With the first button a process chain for geocoding is executed. With the second button you can check the status of the last executed process chain.

Code Snippet

METHOD /nly/if_editor~set_meta_exit.

ch_s_table_info-buttons = VALUE #( BASE ch_s_table_info-buttons
"TOP MENU ENTRIES
( name = 'NO_ACTION_T' descr = 'Process Chain' action = /nly/cl_table_rest_v3=>co_action_no_action location = /nly/cl_table_rest_v3=>co_location_top )

"TOP MENU CHILD ENTRIES
( name = 'BUTTON_URL_T_1' descr = 'Start geo encoding for entries with empty status' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_top sort_order = '0' parent = 'NO_ACTION_T' )
( name = 'BUTTON_URL_T_2' descr = 'Check status of last process chain run' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_top sort_order = '1' parent = 'NO_ACTION_T' )
).

ENDMETHOD.

Start process chain and check status

In the Update Exit, you can use the buttons to start the process chain and also check the status of the last process chain.

Below you will find the sample coding. The first button is used to check the status of the process chain. If the process chain is still running, a message is displayed stating that the process chain cannot be started.

Otherwise, the process chain is started. A corresponding message is also displayed in this case.

The second button is used to read out the status of the last runtime and to output it via message.

Code Snippet


METHOD /nly/if_editor~set_update_exit.

DATA: lt_logs TYPE TABLE OF rspc_s_log_f4,
l_active TYPE c,
l_logid TYPE rspc_logid,
l_msg TYPE string,
l_dd07v TYPE dd07v.

CASE i_button.
WHEN 'BUTTON_URL_T_1' .

CALL FUNCTION 'RSPC_API_CHAIN_GET_RUNS'
EXPORTING
i_chain = 'GEODATA' " Name of the process chain
i_date = sy-datum " Current date of the application server
TABLES
e_t_logs = lt_logs " F4-Structure for protocol
EXCEPTIONS
failed = 1 " internal error
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.


LOOP AT lt_logs ASSIGNING FIELD-SYMBOL(<ls_logs>). " First record will have status of latest Process chain.

IF <ls_logs>-analyzed_status = 'A'
OR ( <ls_logs>-analyzed_status = '' AND sy-tabix = 1 ). " If the last request is in unknown state, then it probably just started.
l_active = 'X'.
ENDIF.
ENDLOOP.

IF l_active = 'X'.
ct_messages = VALUE #( BASE ct_messages
( type = /nly/cl_table_rest_v3=>co_msg_type_warning
visu_type = /nly/cl_table_rest_v3=>co_visu_type_toast
hdr = 'Process chain still running'
msg = |The process chain is still running and cannot be started. | )
).
e_skip = 'X'.
RETURN.
ENDIF.



CALL FUNCTION 'RSPC_API_CHAIN_START'
EXPORTING
i_chain = 'GEODATA'
IMPORTING
e_logid = l_logid.

IF sy-subrc = 0.

ct_messages = VALUE #( BASE ct_messages
( type = /nly/cl_table_rest_v3=>co_msg_type_info
visu_type = /nly/cl_table_rest_v3=>co_visu_type_toast
hdr = 'Process chain'
msg = |Process chain succesfully started. LogID = { l_logid } | )
).
ENDIF.
e_skip = 'X'.
RETURN.

WHEN 'BUTTON_URL_T_2' .

CALL FUNCTION 'RSPC_API_CHAIN_GET_RUNS'
EXPORTING
i_chain = 'GEODATA' " Name of the process chain
i_date = sy-datum " Current date of the application server
TABLES
e_t_logs = lt_logs " F4-Structure for protocol
EXCEPTIONS
failed = 1 " internal error
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

READ TABLE lt_logs ASSIGNING FIELD-SYMBOL(<ls_log>) INDEX 1. " First record will have status of latest Process chain.
If sy-subrc = 0.
IF <ls_log>-analyzed_status IS INITIAL. " If Status in log comes back empty, the process chain is actually running.
<ls_log>-analyzed_status = 'A'.
ENDIF.

CALL FUNCTION 'DD_DOMVALUE_TEXT_GET'
EXPORTING
domname = 'RSPC_STATE' " Domain name
value = CONV char10( <ls_log>-analyzed_status ) " Constant (DOMVALUE_L)
langu = sy-langu " Text language; if SPACE: SY_LANGU,
* bypass_buffer = space " if 'X', with BYPASSING BUFFER
IMPORTING
dd07v_wa = l_dd07v
* rc =
.

l_msg = |Process chain { <ls_log>-txtlg } started at { <ls_log>-zeit TIME = USER } has status { l_dd07v-ddtext }. LogID = { <ls_log>-log_id } |.
else. " Process chain did not run today
l_msg = |Process chain did not yet run today.|.
endif.
ct_messages = VALUE #( BASE ct_messages
( type = /nly/cl_table_rest_v3=>co_msg_type_info
visu_type = /nly/cl_table_rest_v3=>co_visu_type_toast
hdr = 'Process chain'
msg = l_msg )
).

e_skip = 'X'.
RETURN.
ENDCASE.


ENDMETHOD.

Summary

As you can see, NextTables can be easily customized to start process chains. I hope this article helps you with your own implementations.

Available in: Professional | Enterprise

Which License is needed for this feature Professional | Enterprise