Saturday, 11 January 2014

Referencing BOR objects as Class attributes in SAP Workflow.

I was wondering how I can use the BOR (Business Object Repository) attributes as my class attributes so that I can use that in my workflow and thanks to Jocelyn Dart I found a way. You can refer her excellent series of blogs on ABAP OO for workflow in SCN. http://scn.sap.com/community/bpm/business-workflow/blog/2007/07/16/referencing-bor-objects-in-abap-oo-classes  

You can also refer the standard class CL_SWF_FORMABSENC provided by SAP.

Now let’s get started with step by step procedure to refer BOR objects as class attributes. For demo purpose I have used Purchase Order BOR – BUS2012.

1. Execute T-code SE24 and create a new class say ZCL_BOR_ATTRIB.

2. In the interface section of the class, add the interface IF_WORKFLOW. In order to use class methods in the workflow tasks we must have this interface in our class. Once we add this interface BI_OBJECT and BI_PERSISTENT interface automatically appear in the interface section.

3. In the Methods section of the class, below highlighted methods of IF_WORKFLOW interface gets added.

4. Come to Attributes section of the class and create the following attributes.

5. Now we have to create a pre-filled type for the constant attribute and to do so click on the arrow mark against the constant attribute and write the below code marked in the Box.

6. Create a CONSTRUCTOR method by pressing the constructor button in the top right area of the screen and add the parameter EBELN.

7.  In the CONSTRUCTOR method add the below code.

8. In BI_PERSISTENT~FIND_BY_LPOR method write the below code. This method is responsible for passing the values from workflow to class. We are passing the EBELN (Purchase document number) retrieved from workflow to CONSTRUCTOR method here.

9.  In  BI_PERSISTENT~LPOR method pass the attribute M_LPOR to the returning parameter RESULT. This method is responsible for passing the computed values from class back to the workflow.

10. Now you can test the class by providing the instance key 4500000088.

11. To check whether the attribute BO_BUS2012 is having the right values or not just click on detail button.

12. Since we can’t use CONSTRUCTOR method in the workflow tasks. We must create a method, which will explicitly instantiates our class ZCL_BOR_ATTRIB. So let’s create a method say CREATE_INSTANCE and the below two parameters.

13. In the CREATE_INSTANCE write the below code.

14. Now go to PFTC T-code create a workflow standard task and include this class method. Don’t forget to mark/enable Synchronous object method and Background processing.

15. To test that workflow task execute the T-code SWUS and input the task number and EBELN value and execute.

16. As soon as you execute the task you will get a status message “Task Started under work item id ******** (current status Ready)". After that, click on Workflow Log.

17. Click on the menu Extras – Container.

18. In the Task Container you will find all the attributes of the BOR-BUS2012.

19. To cross verify the attributes retrieved go to SWO1 (Es Doublew Oh One… J )and execute the BOR-BUS2012 by providing the purchase order number 4500000088.

20. Below are the  BOR BUS2012 attributes and their corresponding values.

7 comments:

  1. Looking for training on SAP Workflow, Check this site for training on best IT courses . Go here if you’re looking for training on Sap Workflow.

    ReplyDelete
  2. Thanks for providing information. We are providing online training classes
    sapworkflowonlinetraining

    ReplyDelete
  3. It was really a nice article and I was really impressed!!http://goo.gl/FZhyT0

    ReplyDelete
  4. It was really a nice article and I was really impressed!!http://goo.gl/FZhyT0

    ReplyDelete
  5. Just found your post by searching on the Google, I am Impressed and Learned Lot of new thing from your post.
    Business Objects training in bangalore
    Business Objects institutes in bangalore

    ReplyDelete
  6. Really informative. Could you explain, how we can link the workflow to the standard tcode(GOS) say invoice creation.

    ReplyDelete