Saturday, May 3, 2014

Containers in Workflow

It’s the location/variables to store/hold the data. It can be simple variables, structure, even objects of any class. Elements required in the workflow are declared in the workflow container.

Workflow Containers types

  • Workflow container
  • Task container
  • Method container
  • Rule container

Binding

Exchange of data can be done through binding between two different containers. Data can be flowed from event container to workflow container, from workflow container to method container and so on.
Project: Here we will first learn how to create container elements and then one example to demonstrate how to store data into database or how to interact with back-end from Workflow.

Workflow Container and its elements

  • Double click on the Create button present in the left panel of transaction code SWDD.
  • Provide name of the container element to be created and type of that container element. It can be simple data type or structure or it can refer to any Business object or class.
  • In the properties tab select the import and export parameters which means we can import this variable from other container or we can export this variable to other container. It is recommended to check both the check box.
  • In the initial tab provide the initial value which means we can assign any default value to the container elements.
  • Now the variable /container element has got created and placed in left panel of Workflow container.
  • Right click on the undefined step and select create button. We are going to create one step called User decision step.
  • Choose the User decision step from list of steps. This step is basically a dialog step which requires user interaction to take the action. The action will be specified at design time. Once this step is executed at run time one dialog work-item gets generated and gets placed in user inbox.
  • In title section provide the title which will be nothing but the subject line of the mail. We can dynamic value set in subject by having & symbol placed in the title section. Once &1 is placed , provide the binding of the container element in parameter section which will be holding the dynamic value at run time .
  • Provide the agent who will be receiving the work-item in his/her inbox. Here workflow initiator is being chosen so that the person who initiates the workflow will receive the work item. Also provide the action which you want the user to take.
  • Click on save button hence it will ask to provide abbreviation. It is to identify the worklfow from list of workflows.
  • Once saved workflow gets created with one user decision step and two branches (Approve and Reject).

Method Container and its elements

  • Go to Class transaction code SE24 and create one class.
  • Add the interface IF_WORKFLOW in the interface section. This interface is added in the class which has to be used in the workflow. Then only workflow will recognize the class. Once this interface is added by default 6 methods get added in method section.
  • Create one STATIC method called SAVE_DATA in the method tab.
  • Create one parameter in the importing parameter.
  • Now go to transaction SE11 and create one table which will store the sales order once gets approved.
  • Now move back to SE24 method where you need to write the following code to save the sales order into database table
    METHOD save_data.
      data ls_vbak type vbak.
    
      ls_vbak-sales_order = im_vbeln.
      MODIFY ztest_vbak FROM ls_vbak.
      Commit work.
    ENDMETHOD.
    

Task Container and its elements

  • Now create the ACTIVITY step in Approve branch that will be responsible to save the sales order into database.
  • Create the task by clicking on display button beside Task.
  • Provide the abbreviation and object category as ABAP Class and object type as class Name and provide the method to save the sales order.

  • Select check boxes for Background Processing and Synchronous object method as shown below.

  • Now check the binding -> The flow of data should be from Task container to Method container. i.e. the sales order which is approved should flow from Task container to method container so that the method can take that data and save the same into database. Drag and drop the elements to perform the binding.
  • Now flow the data from Workflow container to Task container. Thus the flow would be done w.r.t Binding. ( worklfow container -> Task container -> Method container).
  • Click on transfer button 
  • Now the activity step has got added in the approve branch.
  • Activate Workflow. You might know what to click to activate.

Testing Workflow

  • Now test the Workflow by clicking on Test button present beside the Activate button.Provide the salesorder value.
  • Now go to transaction code SBWP, where the workitem will be present. Now execute the workitem.
  • Now look into the database, the record would have got stored into database.

Checking Workflow log in Graphical View

  • Go to transaction code SWIA to see the graphical log.
  • Now we understood how to flow the container element through binding and how the workflow interacts with Database table.

1 comment:

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.