Adding multiple business objects in a task with class based workflow
When we want to add business objects in a task , we have seen that most of the discussions are based on the BOR Object “System” method -“GenericInstantiate” . If we want to add more number of business objects or different types of business objects in a task , then we have to repeat the steps with standard task based on BOR Object “System” .Creating the business objects in a class based workflow with BOR object, we may end up seeing binding errors like below:
There are many blogs explaining how to develop a workflow based on custom class , here I concentrated mostly to achieve our goal without complete class development. My approach is to show that we can add multiple business objects without creating a custom task using BOR Object “System” or using a standard task with BOR Object “System” and also to have an error free task .
For example , a service engineer has to take approval from the manager to replace certain products .System sends a workflow task to the manager based on the products mentioned in the service order . When manager wants to check certain things in the service order products before approving the task , then associated business objects ( in SAP CRM Web UI ) or objects and attachments ( in business workplace inbox ) are helpful in the task. These objects will give comprehensive view of the service order without having to navigate any further to know the details.
Service order products :
For the above requirement scenario , the final workflow will look like below :
This workflow is a class based workflow . I created a class “Z_WF_ADHOC_OBJECTS” with required interfaces and implemented the interface methods .
Global attributes of the class are like below , for our goal, I created a variable “GT_BO_OBJ” of table type SIBFLPORBT to hold required business objects.
Created a method “CREATE_ADHOC_OBJECTS” in the class for getting the multiple business objects ( here products ) based on the service order , the method parameters are like below :
IV_SERVICE_ORD_NO | Importing | Type | CRMT_OBJECT_ID_DB |
ET_BO_OBJS | Exporting | Type | SIBFLPORBT |
Import parameter takes service order number , reads service order data , prepares data with corresponding BOR object type ( here it is product “BUS1178 ” ) and exports data in a table type parameter .
I created an activity ,”Create Adhoc Objects” ,and attached task with class method “CREATE_ADHOC_OBJECTS” like :
Task container elements are like :
Task and activity bindings are as follows :
Created a user decision step and added captured business objects ( class global variable &WF_CLASS.GT_BO_OBJS& ) to ‘&_ADHOC_OBJECTS&” system parameter , then the binding will be like :
Finally , activated the workflow and executed with sample service order, the generated task in CRM Web UI worklist or in user inbox will be like :
Now from task, user can easily navigate the objects to check the details ( here objects are products ) . By clicking on the corresponding product , product displays as follows :
I believe , if a requirement needs more details in a task , then my approach is simple and very helpful.
Great blog, excellent use of the SIBFLPOR(B) structures, I do this a lot, particularly as it also adds a performance benefit because the object is not instantiated - only the key is generated.
It might be worth pointing out that this technique is low-level and does NOT do any validation because nothing gets instantiated. So, depending on your exact implementation, you may only find out several steps later that your key is invalid and order HELLO doesn't exist...
Thanks Mike.
As there is no automatic system validation on the keys, the developer should be extra careful about the keys and also should be aware of the object’s life cycle.
Irrespective of the workflow tasks execution, the objects should be available and valid in the system, then my approach will support the scenario.
Hello,
what is done in the method CREATE_ADHOC_OBJECTS ?
Could you post the code, please ?
Thanks.
It guess above the code that can be seen, only a function module called, probably CRM_ORDER_READ to get the service order items.