To invoke a BAPI through RFC (Remote Function Call), the first thing we must do is import it into the GeneXus KB from GeneXus ERP Connector.
We select the BAPI or BAPIs we want to import and press the Import button.
This will generate an External Object in the KB with the BAPI’s name and all its methods.
Then, from any GeneXus object, we may invoke with <EO>.<method>(parms) or <EODataTypeVariable>.<method>(parms)
Upon generating this object, GeneXus will create an RFC call to invoke the BAPI. At runtime, the RFC call uses SAP Connector (SAP .Net Connector or SAP Java Connector depending on the GeneXus generator used), so it is a prerequisite to have it installed and distribute the corresponding DLL with the application.
SAP .Net connector and SAP Java connector are free of charge for SAP Customers and SAP Partners.
ERP Connector - Generating the application with GeneXus .NET Generator
ERP Connector - Generating the application with GeneXus Java generator
NOTE: RFC calls to the BAPI are only supported in .NET and Java generators. Android and iOS Devices cannot invoke the BAPI directly, they need to call server side components (generated in .NET or Java) that interact with the BAPI
Before invoking a BAPI via RFC from a GeneXus object, the application must be connected to the SAP server where the BAPI will be invoked.
To do so see:
Using the External Object GXEnterpriseSessionManager
Each BAPI has two types of methods, an instance method, and a class method. You will notice the class method in the GX ERP connector marked with a red circle in its icon.
When you use a class method in a GeneXus Object, you directly use the External Object in the code writing <EOName>.<ClassMethodName>(<parms>).
Material.GETLIST(&BAPIMATRAW, &BAPIMATRADC, &BAPIMATRASO, &BAPIMATRAL, &BAPIMATRAM, &BAPIMATRAS, &BAPIMATMFRPN, &BAPIF4A,
But when you use an instance method, you must define a variable of the External Object data type. In the GeneXus Object, you must select a value for the SAP Object Key (this means instantiate the object) and invoke the method from the variable <EODataTypeVariable>.<InstanceMethod>(<parms>)
&Material.Material = '000000000000000001' // Material number instantiation for GetDetail
&Material.GETDETAIL(&Plant, &ValuationArea, &ValuationType, &BAPIMGVMATNR, &BAPIMATDOBEW, &BAPIMATDOC, &BAPIMATDOA,
In addition to standar BAPI, there are other RFC functions standard or developed by the user (these last known as Zfunctions).
All that functions can be ussed with GeneXus ERP Connector, but to be seen by GeneXus ERP Connector, these functions must be published in the BOR (Business Object Repository). This is done in SAP ERP using the following steps (in particular from Stage 3).