Referencing BOR objects in ABAP OO classes
How do I know I’m ready for this?
This is number 7 in a series of blogs on ABAP OO for workflow, so you it would be a really good idea to make sure you have worked through the first 6 blogs. The examples we’ll use here continue on from those we used in the earlier blogs. Here’s the list of the earlier blogs:
- Getting started with ABAP OO for Workflow … using the IF_WORKFLOW interface
- [Using ABAP OO with Workflow Tasks | Using ABAP OO methods in Workflow Tasks]
- [Raising ABAP OO events for Workflow | Raising ABAP OO events for workflow]
- [Using ABAP OO attributes in Workflows and Tasks | Using ABAP OO attributes in workflows and tasks]
- [Using functional methods in Workflows and Tasks | Using functional methods in workflows and tasks]
Which is better ABAP OO or BOR?
Clearly ABAP OO is far superior to BOR – much quicker for development, much more flexible, much less specialized – but if you are still asking this question now might be good time to go back and read the first blog “Why Use ABAP OO with Workflow?” h4. Why would you need to use BOR and ABAP OO together? The main reason for using BOR and ABAP OO together is to access provided SAP business objects for the content. Although newer workflows are now being written using ABAP OO for Workflow – such as Leave Request/Cancellation, and HR Admin Services forms – much of the existing content was originally written using BOR and has not yet been converted to ABAP OO. Whether BOR content is ever converted to ABAP OO depends on the priorities of the specific development area so you should *NOT* wait for old content to be converted. A secondary reason is because even though you are mainly working in ABAP OO you still want to raise events using a technique that does not yet support ABAP OO for Workflow. E.g. Status management events do not provide an ABAP OO option as yet (SAP NetWeaver 7.00 – July 2007).
How do you access a BOR object from an ABAP OO class?
The best approach is to access the BOR object as an attribute of your ABAP OO class. For our ZCL_PLANT example we have been using in the previous blogs, there is an older equivalent BOR object BUS0008. To link the BOR object to our ZCL_PLANT class we need to:
- Create a constant with a prefilled type for the BOR object
- Create an attribute for our BOR object
- Fill the attribute value at runtime with the key of the BOR instance
- Reference the BOR object in our workflows/tasks A constant is just an attribute of a class with the level “Constant” (instead of “Instance” or “Static”).
The prefilled type can be created in a number of ways – you could use a type-pool or just use a direct entry type. A type-pool has the advantage of allowing you to collect all such prefilled types into one place, however for our example a direct entry type is adequate.
I've been using OO Classes for quite a while in workflows and could not agree more that it's the way to go.
I would like to say a public thanks for all your valuable input into all things Workflow and especially these blogs which have been an inpiration.
Cheers,
Mike
Great article especially the BOR object as attribute of your OO class.
How would you handle hard coded BOR events (by SAP), which should trigger your OO WF?
Best regards,
Henk.
I just went through the 7 blogs once again just to refresh my memory of OO/Workflow.
It is a marvellous effort on your part to so lucidly and easily explain the unknowns, in fact I think you have gone a step ahead and actually given a beginner a neat little intro into the hitherto mystical world of SAP Workflow.
This was the last one that I somehow missed when I moved from one client to another but, as they say, better late than never. I tried the BO as attribute of the class and may say it is absolutely fantastic!
Keep up the great work!
P.S.: Can we expect some more gems from you?
This is really great job and helping us a lot.Thanks a lot:)
In my curreny project even I am trying to do same.
There is a object type BUS7051 and I want to use this object in my own class. My workflow triggers with event 'Created' of BO BUS7051. I have defined class attribute and constant as you mentioned.
But now I am confused, how to retrieve notification data from workflow and use the BO attributes and methods in my class.....
Please help....
Thanks in advance...
Rashmi Jain
Ok.. well this is a question perhaps better listed on the BPM forum, however here's a quick summary.
1. Your workflow is triggered on event BUS7051.CREATED
2. The first step in your workflow should be to create an ABAP OO instance of your notification using the notification id from BUS7051. If you want to have different ABAP OO classes for different types of notifications, then usually the notification type and scenario can be used to determine which class you instantiate and also which workflow you start (e.g. by adding a logical expression as a start condition of the workflow).
3. You can then continue on with the rest of the workflow using your ABAP OO instance.
As BUS7051 can represent many different types of notifications - including ISR, PCR and Adobe forms - it's helpful here to have a parent ABAP OO class representing all attributes and methods that apply to any notification, and have specific child ABAP OO classes for each type of notification (which of course inherit all the generic attributes/methods from the parent class).
Hope that's enough to get you started.
If you aren't familiar with some of the terms above I suggest you raise your questions in the SDN BPM forum.
Regards,
Jocelyn
This really helped me.... Now I can think ahead. 🙂
Thanks again for your quick help......
Regards,
Rashmi Jain
I'm new in Workflow and can you please help me in how to add a BOR in my ABAP class for trigger the event. I need to trigger my abap class from BUS2034 created event. Can you give me a step by step to create the constant and the instance?
Thanks for your atention,
Elvis
Great blog!
But I have one problem. I can't press the "Direct Type Entry" button if my constant is Public. Therefore I can't set initial value for BO_BUS0008.
Whether there is an solution for this situation?
Unfortunately ABAP OO for workflow is only available from 6.20 onwards - e.g. ECC 5.0, ECC 6.0, etc. - as I mentioned in the introductory blog. In 4.70 you still only have the option of using BOR objects. Although it doesn't hurt to practice! In later releases I haven't had a problem creating public constants so I suspect that must be a 4.70 issue.
Regards,
Jocelyn
Create own TYPE-POOL in SE11, where create constant:
constants: BEGIN OF ztttt_c_bo_scase,
instid TYPE sibfboriid VALUE IS INITIAL,
typeid TYPE sibftypeid VALUE 'SCASE',
catid TYPE sibfcatid VALUE 'BO',
END OF ztttt_c_bo_scase.
Next just insert this type-pool in type defenition of the class. And then insert ztttt_c_bo_scase as initial value for BOR attribute.