With this proxy API, you can start SAP Cloud Platform Workflows out of your ABAP Environment.
The overall starting point is the class CL_SWF_CPWF_API_FACTORY. Once you have the API object of interface IF_SWF_CPWF_API, see the ABAP documentation on supported actions.
Sample Code
This coding sample shows how to start an SAP Cloud Platform Workflow.
TYPES: BEGIN OF ty_context,
some_property TYPE string,
END OF ty_context.
DATA(lo_cpwf_api) = cl_swf_cpwf_api_factory=>get_api_instance( <consumer_type> ).
DATA(ls_context) = VALUE ty_context(
some_property = 'someValue'
).
DATA(lv_context_json) = lo_cpwf_api->get_start_context_from_data(
iv_data = ls_context
).
DATA(lv_cpwf_handle) = lo_cpwf_api->start_workflow(
iv_cp_workflow_def_id = 'myprocess'
iv_context = lv_context_json
iv_retention_time = 30
iv_callback_class = 'ZCL_SWF_CPWF_CALLBACK'
).
Sample Code
This coding sample shows a completion callback that includes reading the context.
METHOD if_swf_cpwf_callback~workflow_instance_completed.
TYPES: BEGIN OF ty_context,
some_result TYPE string,
END OF ty_context.
TRY.
DATA(lo_cpwf_api) = cl_swf_cpwf_api_factory=>get_api_instance( <consumer_type> ).
data(lv_context_json) = lo_cpwf_api->get_workflow_context( iv_cpwf_handle = iv_cpwf_handle ).
DATA ls_context TYPE ty_context.
lo_cpwf_api->get_context_data_from_json(
EXPORTING
iv_context = lv_context_json
IMPORTING
ev_data = ls_context
).
CATCH cx_swf_cpwf_api INTO DATA(lx_exc).
RAISE EXCEPTION TYPE zcx_swf_cpwf_callback
EXPORTING
previous = lx_exc.
ENDTRY.
" your business coding
ENDMETHOD.