The inspiration for this blog is awhich made me to think that is it possible to do some thing like, if a mail is sent to outlook along with a hyperlink, and as soon as the end user clicks on the hyperlink a workflow has to be started in the SAP system, irrespective what the workflow handles.
To make things clear, the scenario what I considered is, a mail will be sent to a set of employees in an organization, to know the opinion of the employee, based on this a workflow will be triggered, which will update a Z table by using Program Exit class.
The SAP itself has given us a way to handle this kind of cases by using START FORM, in the basic data of the workflow. The way in which, we define a start event, and when ever the event is raised and the workflow acts as the receiver, in the same way even the start form concept works. In order to use start form,
- Z-table where the user name and his opinion is stored,
- A Z-structure with same fields as Z-table contains.
- A workflow container element is to be created with type same as Z-Structure with property Importing.
- A workflow template, with the respective logic and the steps.
- Enable ITS in the SAP system.
Creating & Defining the header data of workflow
- A Simple workflow template consisting one decision step enabled with Advance with Dialog, and used a program exit class to update the Z table after the work item is executed. Agent defined as Workflow Initiator (_Wf_Initiator).
- Create a workflow container element by specifying type as Z-structure and properties as Importing. (Invitation).
- Go to Basic Data of the workflow template, and in the Version Independent tab click on the tab Start Form.
- Click on the Create, from here wizard will help to create the form, at the second step of the wizard, specify the name of the form, select the respective container element (INVITATION) and enable the check box Enable Web Transaction. After the execution of the wizard , the Start Form(s) section will appear as below,
- In other session goto Object Navigator (SE80), and click on Edit Objects, select WebObjects tab , in that select the option ITS Service and specify a Z service name and finally click on create Icon.
- The system will prompt to enter a transaction code copy the transaction code which is shown in the above screen shot and click SAVE.
- Right click on the theme 99, create a template by including the Program name and screen number which are saved in the basic data of the workflow.
- Publish the internet service by right clicking on the name of the internet service and choosing Complete Service. A successful message will be prompted if the internet service is published completely.
- Execute SICF transaction and follow the path /sap/bc/gui/sap/its, right click on the ITS node and select New Sub element, specify the service name same as specified for internet service, in interactive options section for GUI link select Yes and click on the button GUI configuration. Mention the parameters as below.
- Click on the tab Logon Data and specify a user name and password which has authorization to start workflow, this is because, when user clicks on the hyperlink it will prompt for user id and password to check authorization, this is optional.
- Select handler list tab and specify the class name as CL_HTTP_EXT_ITS.
- Finally new service has to be activated, by simply right clicking on the service and select Activate Service.
- Newly created service can be tested by selecting Test Service.
- If every thing is done correctly, then in a browser all the fields declared in the structure will be displayed along with Start and Cancel buttons.
- Enter the respective data and click on the Start button to start workflow.
- Since both initiator and approver both are same, if workflow gets triggered then browser will be refreshed as below screen shot. Since the Decision step is enabled with Advance with dialog immediately.
Code to generate dynamic hyper link:
Always after development, the objects are ported to new system, so as per the new system settings the hyperlink will also change with respect to host, port, so to dynamically get these settings use the below code snippet.