‎2007 Nov 26 11:39 AM
Hello Gurus!
Is there a way to call BAPIs via classes/methods in abap objects or is it still common to use them as function modules?
I already searched in online help and found only this <a href="http://help.sap.com/saphelp_nw04/helpdata/de/dd/5009660aa411d2ad1b080009b0fb56/content.htm">old example</a> (unchanged since 4.6), is it still up to date?
regards,
alfons
‎2007 Nov 28 7:35 PM
Hi Alf,
I just call them as function modules.
You can also use this technique for calling the method of a business object described at http://help.sap.com/saphelp_nw70/helpdata/en/c5/e4acef453d11d189430000e829fbbd/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 Robbo