Skip to Content

In the first part How to create and trigger class based workflow – part 1, we have seen creating a class using IF_WORKFLOW interface. Now we will see, how to create workflow.

Creating Workflow

Step 1: Creating Workflow.

Go to SWDD Transaction and click on Create button to create new Workflow.

/wp-content/uploads/2012/03/15_83708.jpg

Step 1.1: Creating Attributes.

Under Navigation Area Work flow container will be selected, If not select Work Flow container as shown below.

/wp-content/uploads/2012/03/16_83709.jpg

Under Workflow Container double click to create as shown below.

/wp-content/uploads/2012/03/17_83710.jpg

Enter Element Name, Description and select the created class.

/wp-content/uploads/2012/03/18_83711.jpg

Under Properties Tab select import, export and click on Ok.

/wp-content/uploads/2012/03/19_83712.jpg

Now Double click again to create emp_id Element which stores the Employee ID.

Enter attribute name, description and enter type as shown below.  You can enter the data type directly by selecting ABAP dict. Data type.

/wp-content/uploads/2012/03/20_83713.jpg

Under Properties tab check import, export and click on Ok.

/wp-content/uploads/2012/03/21_83714.jpg

Similarly create one more attribute emp_name to store Employee Name.

/wp-content/uploads/2012/03/23_83715.jpg

Under Properties tab check import, export and click on Ok.

Click on Save and Save the Work flow.

Step 2: Registering Start Events for Workflow.

Click on basic data (hat symbol) as shown below.

/wp-content/uploads/2012/03/24_83716.jpg

Go to Start events Tab and select Category as CL (ABAP Class), Enter Class Name and Enter Event Name (you can select event from F4 help) as shown below.

/wp-content/uploads/2012/03/25_83717.jpg

Step 2.1: Binding Business Object Attributes to Workflow Attributes.

Click on binding as shown below

/wp-content/uploads/2012/03/26_83719.jpg

Here binding generated automatically with the matching types, if you don’t see this binding, bind manually by drag and drop from Class container to Workflow container.

/wp-content/uploads/2012/03/27_83718.jpg

Now you can see empid of Business Object is mapped with emp_id of Workflow Container. Click on OK.

Step 2.2: Activating Start Event for Workflow

  Click on Activate as shown below.

/wp-content/uploads/2012/03/28_83723.jpg

Once activated it turns to green.

/wp-content/uploads/2012/03/29_83725.jpg

This means once the REGISTERED event of Class ZCL_WF_DEMO is triggered, the Workflow will Start.

Click on Save and go back to main screen.

Step 3: Creating Task 

Double Click on the Undefined Step as shown below.

/wp-content/uploads/2012/03/30_83726.jpg

Select Activity Step and click on Ok.

/wp-content/uploads/2012/03/31_83727.jpg

Click on Create Task as shown below.

/wp-content/uploads/2012/03/32_83728.jpg

Enter abbreviation, Name. Under Object method, select Object category as ABAP Class. Enter Class Name and Method Name (You can select method from F4 help) as shown below.

Select the check box ‘Synchronous object method’. ( If you don’ t select the ‘Synchronous’ , for Asynchronous method you need to maintain the Terminating Events, In terminating events select the element _WI_OBJECT_ID and select the event name using F4 )

Under Execution Select Background Processing, since no user interaction is required for our scenario.

33 - Copy.jpg

Click on Save and Click on Back Button.

It will prompt to Transfer missing elements. Click on Yes. (You can also click on No and create elements manually).

/wp-content/uploads/2012/03/34_83732.jpg

Now Click on Ok.

Continuing in next part How to create and trigger class based workflow – part 3 ( as the maximum no.of images reached )..

To report this post you need to login first.

16 Comments

You must be Logged on to comment or reply to a post.

  1. Abdullah Azzouni

    Again; nice work my friend. I just have a comment on the transaction used to create workflow templates. While SWDD will work just fine as you described, PFTC provides a more logical approcah as you start by defining the header and main container elements before going into the workflow builder to define the different steps.

    (0) 
    1. Ravin Joshi

      One query: After binding task to get employee Name, while clicking on Transfer button, Is it mandatory to provide Agent assignment for that task (i.e. Here Activity Task 000004) – which can be shown under Task Properties with yellow or red button of Agent assignment?

      (0) 
  2. Ravin Joshi

    One query: After binding task to get employee Name, while clicking on Transfer button, Is it mandatory to provide Agent assignment for that task (i.e. Here Activity Task 000004) – which can be shown under Task Properties with yellow or red button of Agent assignment?

    (0) 
    1. Kiran Kumar Valluru Post author

      Hi,

      Have you selected background processing checkbox? . For background processing no need of agent assignment. If you dont select background processing( Foreground ) agent assignment is required. In this scenario as no user interaction is required, select background processing. Normally for agent assignment, click on yellow button under task properties and assign the agent.

      Best Regards,

      Kiran

      (0) 
      1. Ravin Joshi

        Yes, Background processing checkbox also selected in my case, Moreover for agent assignment under task properties corresponding button displayed as red colour and not allowing to click on transfer button as asking for Agent.

        Is somewhere settings need to be changed? Or any other ?

        (0) 
        1. Kiran Kumar Valluru Post author

          Hi,

          It seems like configuration problem. check swu3 configuration. Als check wf-batch user exists or not. check whether job SWWDHEX was  scheduled with report RSWWDHE.

          Best Regards,

          Kiran.

          (0) 
          1. Ravin Joshi

            Thanks Kiran. Do you mean it while executing SWU3 config, all the contents of left-hand panel should be in Green colour status? What can be done if not in Green colour?

            How can I check if WF-BATCH user is having all the authorizations? What can be done if job SWWDHEX taking much time for execution or getting cancelled?

            (0) 
            1. Kiran Kumar Valluru Post author

              Hi,

              Please check with your basis team. WF-BATCH user will be created automatically, once we execute the automatic customization, at that time the authorization of user who executed it will be transferred to the wf-batch. Ask your basis team to create wf-batch with SAP_ALL authorization. please check this help docu for reference : http://help.sap.com/SAPHELP_NW04s/helpdata/EN/a0/28e937a5caba6ee10000009b38f842/content.htm

              <<How can I check if WF-BATCH user is having all the authorizations?>>

              goto SU01 enter WF-BATCH and click on display. goto profiles tab, there you can see SAP_ALL authorization.

              Best Regards,

              Kiran

              (0) 
              1. Mahesh kumar

                Hi kiran,

                i followed above example but i got a problem in workflow the event is not triggering but wf  template triggering but another problem at task also every work item say’s in process only

                what is the problem can u help me.

                Regards

                Mahesh

                (0) 
  3. Guru Shanthi Potluri

    Hi Kiran,

    I created custom class and tagged the class to the task. But I see some issue in Binding. In the class I have notification I’d as key attribute. Based on this key attribute, I am fetching multiple approvers and adding recipients using CL_BCS to send email.

    While executing workflow.. I get error at the email step. In the error log details I see notification I’d is not set.

    I guess there is issue in Binding. I’m new to workflow. Can you help?

    Thanks

    Shanthi

    (0) 
  4. Nishant Bansal

    Hi,

    In our case we have more than 32 character key fields, How we can proceed this.

    For all PA info types we have 34 character key fields so Please let me know how i can proceed this.

    Thanks and Regards,

    Nishant

    (0) 

Leave a Reply