Please also have a look in our OnlineHelp for further information.
A so-called BAPI is a Business Object method. There are hundreds of Business Objects in a SAP system, one of these is Material. Material represents a single material. You can execute several methods on it, e.g. Availability. The method Availability provides the so-called ATP (stock quantity Available To Promise). You can use the Object Repository (transaction BAPI) to search or execute BAPIs and Business Objects. Please have a look at ifr.sap.com, the web-based SAP Interface Repository. The example below shows how to execute the BAPI Material.Availability in a Windows Forms application. We start by placing an ERPConnect.R3Connection control in the form (you can use drag and drop from the toolbox). The figure below shows the form during design time. The connection properties (on the right hand side) can be also set in design time, so we don’t need to worry about these things in code.
Before executing the BAPI, there are at least three import parameters to be defined: the Plant (PLANT), the material number (MATERIAL) and the unit (UNIT). As you can see in the code below, the BAPI object is created by the CreateFunction method of the R3Connection object. The imports will be set the same way as we did when calling ‘normal’ function modules. After executing this BAPI we can evaluate the return parameters. In case of an error, we have to analyze the Return structure. If no error has occurred, the AV_QTY_PLT parameter contains the stock quantity in the given unit.
The figures below show the example program in action. On the first try, the user types a non-existing material number so an error message is given by the BAPI. The right hand figure shows a correct quantity indication.