
You use this procedure to enable users to access context-related information of the processes in your system.
1. Implement the BAdI
Log on to the SAP Business Suite Process Observer system.
Implement the BAdI POC_PROCESS_CONTEXT.
Implement the BAdIi methods, IF_POC_PROCESS_CONTEXT~PROCESS_DEFINITION_CONTEXT_GET (for metadata information) and IF_POC_PROCESS_CONTEXT~PROCESS_INSTANCE_CONTEXT_GET (for runtime information).
You can only use the following XSD types in the IF_POC_PROCESS_CONTEXT~PROCESS_DEFINITION_CONTEXT_GET method:
boolean |
byte |
date |
dateTime |
decimal |
double |
float |
int |
integer |
long |
short |
string |
time |
- |
- |
- |
Sample Code Snippet for IF_POC_PROCESS_CONTEXT~PROCESS_DEFINITION_CONTEXT_GET Method
...
DATA:
ls_name_type_pair TYPE poc_s_process_context_par_def,
ls_pdef TYPE poc_s_process_definition,
ls_context_def LIKE LINE OF et_process_definition_context.
CLEAR: et_process_definition_context.
LOOP AT it_process_definition INTO ls_pdef.
CASE ls_pdef-proc_def_id.
WHEN ‘order_to_cash’.
CLEAR: ls_context_def.
ls_context_def-proc_def_id = ‘order_to_cash’.
ls_context_def-proc_version = ‘001’.
"===============Sales order ID========================"
CLEAR:ls_name_type_pair.
ls_name_type_pair-context_par_name = ‘sales_order_id’.
ls_name_type_pair-context_par_type = ‘string’.
APPEND ls_name_type_pair TO ls_context_def-context_parameter_def.
"===============Amount====================================="
CLEAR:ls_name_type_pair.
ls_name_type_pair-context_par_name = ‘amount’.
ls_name_type_pair-context_par_type = ‘double’.
APPEND ls_name_type_pair TO ls_context_def-context_parameter_def.
APPEND ls_context_def TO et_process_definition_context.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
...
Sample Code Snippet for IF_POC_PROCESS_CONTEXT~PROCESS_INSTANCE_CONTEXT_GET Method
...
DATA:
ls_process LIKE LINE OF it_process_instance,
ls_context LIKE LINE OF et_process_instance_context,
ls_name_value_pair TYPE poc_s_process_context_par_val.
CLEAR: et_process_instance_context[].
LOOP AT it_process_instance INTO ls_process.
IF ls_process-proc_def_id EQ ‘order_to_cash’.
ls_context-proc_id = ls_process-proc_id.
ls_context-proc_def_id = ‘order_to_cash’.
ls_context-proc_version = ‘001’.
"==context data can be retrieved by using standard sap bapis or rfcs
"=====================order id===============================
ls_name_value_pair-context_par_name = ‘sales_order_id’.
ls_name_value_pair-context_par_value = ‘001’.
APPEND ls_name_value_pair TO ls_context-context_parameter_value.
"=============Amount======================================
ls_name_value_pair-context_par_name = ‘amount’.
ls_name_value_pair-context_par_value = 10.
APPEND ls_name_value_pair TO ls_context-context_parameter_value.
APPEND ls_context TO et_process_instance_context.
ENDIF.
ENDLOOP.
... You must use the POC_FAC_QUERY_SCOPE_OBJ_INS API to get business object instance ID related to your process. For example, if you want to provide the context–related details for a sales order, you need to know the sales order ID. You can get the sales order ID using the related business object instance ID, which exists as part of the POC_FAC_QUERY_SCOPE_OBJ_INS API result.
Save and activate the changes.
2. Register the Context Service
To register the context service for a process, use one of the following:
Business Process Content Powered by SAP Gateway is deployed as an addon for SAP Gateway |
Registering Process Context Service for Deployment Scenario 1 |
Business Process Content Powered by SAP Gateway and SAP Gateway are deployed on separate systems |
Registering Process Context Service for Deployment Scenario 2 |
3. Activate the Context Service
To activate the context service for a process, see Activating the Process Context Service.