Call SAP Business Object Methods in your report Program using Macros
This blog is to explain how better we can reuse already coded business object methods. We navigate to Business Object explorer (Transaction Code SWO1) to explore all available business objects both standard and custom , Module wise , we see there are a lot of potential methods and attributes encapsulated based on business cases that can be reused.
Let us execute a business object method through SWO1 and later write a program to call the method.
Execute a Business Object
Step-1 Go to transaction SWO1 and search a business Object
Step-2 Let us instantiate the BO (BUS0019) by passing key fields
Click on OK the BO will get instantiated with its attributes value getting populated according to the key fields.
Step-3 Execute the edit method , for the edit dialog to be open and allowing user to update values.
Program to call the method with Business Object Instantiation
*&———————————————————————*
*& Report ZSAMPLE_BO_INSTANTAITION
*& Demo Use of BUS0019
*&———————————————————————*
REPORT ZSAMPLE_BO_INSTANTAITION.
include <cntn01>.
“Data Declaration-key
data:begin of objkey,
id type t500p-persa,
personnelsubarea type t001p-btrtl,
end of objkey.
“Data declaration of object
data:zbus0019 type swc_object.
SWC_CONTAINER CONTAINER.
“Now fill the value of key
objkey-id = ‘AR01’.
objkey-personnelsubarea = ‘0001’.
swc_create_object zbus0019 ‘BUS0019’ objkey. “Instantiate Business Object
SWC_CALL_METHOD zbus0019 ‘Edit’ CONTAINER.
After Execution of this program it opens the edit dialog for Personnel area and subarea.