Objective:Send workitem to the user’s Business Workplace on Material Change.
Purpose:Whenever a Material will change in MM02, a workitem will be sent to the creator of the material and the user who will change the material with the description ‘Material Property is changed from ‘’ to ‘’ ‘to their Business Workplace.
Business Scenario:Whenever a Material ‘Unit (MEINS)’ will change from MM02 a workitem will be sent to the creator of the material and the user who will change the material with the description ‘Material Property is changed from ‘’ to ‘’ ‘to their Business Workplace.
Process: This demo will involve the following steps:
- Copy the Standard BUS BUS1001 (Material) into custom ZBUS1001.
- Create an Event ‘CHANGED’ for Change Material to trigger the Workflow.
- Make an entry in SWEC for ‘Events for Change Document’ and put the Change doc. Object: ‘MATERIAL’ Object Type: ‘ZBUS1001’ and Event ‘CHANGED’. Select the radio button Trigger event ‘On Change’.
- Go to SWDD and build a Workflow.
- Create a Method to get changed Material data using a Function Module.
- Create a Multiline Container Element to hold multiple Agents in lines.
- Create a Method to get Agent from multiline container element.
- Use Fork to send mail to users parallely.
- Use that Multiline Container Element in Send Mail step to send work item to different users.
Prerequisites: It is assumed that the reader of the document has the knowledge of Change Document and Workflow builder.
(Many business objects are changed frequently, and these changes are logged into change documents to make the changes traceable. Change documents can be created for changes already made as well as for planned changes. Tables: CDHDR and CDPOS)
Step by step Approach:
1. Go to SWO1 and copy the Standard BO: BUS1001 to custom ZBUS1001.
Create an Event ‘CHANGED’.
1. Change Release status by navigate Edit ->Change Release Status -> Object Type Component -> To Implemented.
Then go to Edit ->Change Release Status -> Object Type Component -> To Released.
Go to Txn. SWEC to connect the Event with Change Doc. Object to trigger the workflow on change.
Go to SWDD and create a Workflow. Go to Basic Data and put Abbreviation and name for your workflow. Then Save it.
Go to Basic data -> Start Event. Put The Event CHANGED and Activate and Click on automatic binding to start Workflow.
1. To get the Changed Data of Material we need to create a custom Method. Here we will create a Function Module to return the value of changed data.
Go to SE37 and provide the Function Module name.
Select the radio button Remote-Enabled to create a RFC enabled function module.
Put Import and Export parameters and select Pass By Value button for RFC-Enabled FM.
Write this piece of code to fetch data from Change Document tables: CDHDR and CDPOS. Source Code:
Save and Activate.
1. Now Go to SWO1 and create a Method.
Create with Function module as template ‘Yes’.
Complete the full process and select Yes.
Now press the red button to generate the method successfully and follow the step 3 to release the component type method.
Now Create a Task from PFTC->Standard Task. Give a name to the task and put the method over here. Select Background Processing.
Click on Binding button and press Automatic Binding. Save the Task.
1. Now go to SWDD and create an Activity step and put the Task over here.
Click on Binding and press Automatic Binding.
Make all workflow container element as import export parameter.
Now create another method to get agents. Here workitem would send to the two different user, one who created the Material and one who changed the material.
To achieve this functionality 1stcreate a multiline container element to hold Agents. Give SOXNA-FULLNAMEas ABAP dict. type.
Click on import, export and multiline and click on continue on Properties tab.
Click on Program and write down this piece of code.
Save and generate this method successfully. Next follow the step 3 to release the component.
Create another Task and give the method name over here. Click on Background Processing. Do Automatic Binding.
Go to SWDD and create another activity. Click Automatic Binding.
Now send workitem to the users parallel. To achieve this functionality use Fork. Parallel Branch ‘02’. Necessary branch ‘01’.
Create Send Mailstep to each branch. Pass the multiline container element IT_AGENT to the Recipients.
Click on Control tab and do necessary bindings. Click Transfer Graphic.
Now Your Workflow will look like this.
Finally go to Basic Data-> Start Event tab and do binding with Event container element Material’ with workflow container element ‘MATNR’ to start the workflow on ‘MATERIAL’ change. Activate the workflow.
Go to MM02Txn and make necessary changes. Workitem will be sent to two different users to their Business Workplace.