Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calling methods from the Business Object BUS2032

Former Member
0 Likes
3,299

Hi all,

Is it possible to call methods from the Business Object BUS2032.

If so, how can it be done??

Regards,

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,157

Hello Marvin

"Methods" of business objects are no class methods in technical terms. They are just semantic definitions.

If you call transaction SWO1 and display your business "object" (which is no object in the OO-sense) BUS2032 then you see "method" <b>SalesOrder.ChangeFromData</b>.

Double-click on the method name and switch to the tabstrip <b>ABAP</b>. There you see that this "method" is implemented by the BAPI<b> BAPI_SALESORDER_CHANGE</b>.

Regards

Uwe

Hi all,

Is it possible to call methods from the Business Object BUS2032.

If so, how can it be done??

Regards,

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,158

Hello Marvin

"Methods" of business objects are no class methods in technical terms. They are just semantic definitions.

If you call transaction SWO1 and display your business "object" (which is no object in the OO-sense) BUS2032 then you see "method" <b>SalesOrder.ChangeFromData</b>.

Double-click on the method name and switch to the tabstrip <b>ABAP</b>. There you see that this "method" is implemented by the BAPI<b> BAPI_SALESORDER_CHANGE</b>.

Regards

Uwe

Read only

uwe_schieferstein
Active Contributor
0 Likes
2,157

Hello Marvin

If you look at <b>BUS2012 </b>(<i>Purchase order</i>) its methods are implemented by BAPI_PO_... BAPIs.

The corresponding classes (available >= 6.20) are <b>CL_PO_HEADER_HANDLE_MM</b> (Header) and <b>CL_PO_ITEM_HANDLE_MM</b> (Item).

Regards

Uwe

Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
2,157

Hi Marv,

you sure can. Here is an extract from the SAP Help. I found it at http://help.sap.com/saphelp_46c/helpdata/en/c5/e4ad71453d11d189430000e829fbbd/frameset.htm

<b>Programmed Method Call</b>

Call (fictitious) method Print of object type VBAK (sales document). The method receives the parameters Paperformat and Printertype as input.

* Call method Print of object type VBAK
***************************************************

* Data declarations
***************************************************
DATA: VBAK_REF TYPE SWC_OBJECT.
SWC_CONTAINER CONTAINER.
* Create object reference to sales document
*************************************************
SWC_CREATE_OBJECT VBAK_REF 'VBAK' <KeySalesDoc>
* Fill input parameters
***************************************************
SWC_CREATE_CONTAINER CONTAINER.
SWC_SET_ELEMENT CONTAINER 'Paperformat' 'A4'.
SWC_SET_ELEMENT CONTAINER 'Printertype' 'Lineprinter'.

* Call Print method
***************************************************
SWC_CALL_METHOD VBAK_REF 'Print' CONTAINER.
* Error handling
IF SY-SUBRC NE 0.
   ..... 
ENDIF.

Cheers

Graham

Read only

0 Likes
2,157

Hi there --this is of course technically correct -- however I would where possible try and avoid the use of BO's. If you can find (or create) a genuine class then you can then use "proper" OO.

The concept of a BO was to allow for some limited type of "pseudo object" coding before ABAP supported a relatively powerful and full OO set.

Cheers

Jimbo