Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
partha_sarkar6
Discoverer


This example illustrates how you can use tracing and user-defined trace statements, to trace the execution of the custom logic in the BAdI "Determination of Workflow Agents for Purchasing Documents".


Example Use Case


You have defined a workflow for purchase orders with "Total Amount > 100 EUR", using the Manage Workflows for Purchase Orders app. The workflow contains a step whose recipient is "Agent Determination by BAdI", i.e the agents are determined using the custom logic provided in the Determination of Workflow Agents for Purchasing Documents BAdI.



1. The custom logic can be implemented in the BAdI Determination of Workflow Agents for Purchasing Documents using the Custom Fields and Logic app. To enable tracing, you can insert the following user defined trace statements in the BAdI.







Method




Color/ Severity Level




Result






cl_ble_trace_writer=>write_info_message( 'This is an info message' )




White/ Information




This method writes a trace entry with the severity level "information" in the Trace Hierarchy table.


The string that is passed as the parameter is displayed in the Step Info column of the Trace Hierarchy table.


In this example the string is - This is an info message.






cl_ble_trace_writer=>write_warning_message( 'This is a warning message' )




Orange/ Warning




This method writes a trace entry with the severity level "warning" in the Trace Hierarchy table.


The string that is passed as the parameter is displayed in the Step Info column of the Trace Hierarchy table.


In this example the string is - This is a warning message.






cl_ble_trace_writer=>write_error_message( 'This is an error message' )




Red/ Error




This method writes a trace entry with the severity level "error" in the Trace Hierarchy overview.


The string that is passed as the parameter is displayed in the Step Info column of the Trace Hierarchy table.


In this example the string is - This is an error message.







In this BAdI, we have added few information trace messages. Please note that you can only pass string value to the parameter of the trace methods.





1. In order to start tracing the custom logic, you can use the Custom Logic Tracing app.


Choose the Start Trace option, and fill the required fields. For tracing the steps in the Determination of Workflow Agents for Purchasing Documents BAdI, enter the trace user as SAP Workflow Runtime.





1. Choose Start to begin tracing. A new active trace will be created. It remains active for the lifetime you have defined. The countdown indicates the remaining minutes.


Navigate to the UI of the business object that you want to trace and execute the actions. In this case, go to the Manage Purchase Orders app. Create a Purchase Order with Total Value greater than 100 Euros and order it. As the Total Amount in the purchase order is greater than 100 EUR, the above workflow gets picked up. This in turn causes the custom logic in the Determination of Workflow Agents for Purchasing Documents to be executed.





The recipient as determined in the BAdI receives the purchase order in their Inbox.


Return to Custom Logic Tracing and choose "Finish Trace" to terminate it. This adds the trace to the Finished Traces list.




From there, you can navigate to the details of the trace hierarchy. As you can see, the trace is marked in white color indicating that there are only info messages. This status color always refers to highest priority found during the trace. For example, if a trace contained both a warning and an error, the overall accumulated status color would be red for error.



For more details, please refer to https://help.sap.com/viewer/0f69f8fb28ac4bf48d2b57b9637e81fa/latest/en-US/4161479993824dde8f088419d8...

2 Comments