Before running a Business Application Programming Interface (BAPI) in your programs, you should test it. See how to test your BAPI and how to get a report that shows you its details.
Key Concept
A Business Application Programming Interface (BAPI) is a standard interface that facilitates the integration of R/3 or mySAP ERP Central Component (ECC) with the processes and data of other business application systems. BAPIs are the standard SAP interfaces, playing an important role in the technical integration and exchange of business data between SAP and non-SAP components. They are an important part of developing integration scenarios where you connect multiple components to each other, either on a local network or on the Internet. You can implement and store BAPIs in R/3 or ECC as Remote Function Call modules.
Customers and third parties use Business Application Programming Interfaces (BAPIs) as the standard SAP business objects for integrating their software components with the SAP system. Once you implement a BAPI, its interface definition and parameters remain stable in the long term, which in turn stabilizes your application programs. The performance of BAPIs is also higher compared to the batch data creation (BDC) process many companies implement.
Let me discuss two ways that functional consultants commonly use BAPIs and give an example of how they identify and test them. Testing BAPIs aids in the technical development process. Normally technical consultants with ABAP expertise use BAPIs, but functional consultants should know how to test BAPIs to retrieve the output before the technical consultants use them in a program.
Take the example of transaction MIRO, posting for vendor invoice verification. In many cases, you have to change the standard invoice verification process, such as changing the price of the material if the price of the material that the finance department processed differs from the price that the PO originally listed. This is not available in standard SAP — you have to create a custom program to post the invoice. In this case, you can use the BAPI CREATE_VENDOR_INVOICE to post the MIRO transaction. BAPIs can drastically cut the time it takes to post an invoice because of the numerous line items you have to use with BDC.
Another example of how to use a BAPI is for reporting. Using a BAPI, you can make changes to the output of the report. The BAPI displays the output in its own format, which you can change based on your requirements, unlike the standard report. In my example, the GetGLAccountPeriodBalances BAPI requires four simple input parameters and outputs the data in a way that no current standard FI report does.
I once had a customer ask my company to create a report that would generate period-wise accounting balances for the G/L. I could have used SAP standard reports, but the customer wanted to view the output in a different way, showing the G/L balances standard by period in a single screen. I used a BAPI called GetGLAccountPeriodBalance. I’ll use this BAPI to illustrate my example. To show you the advantages of BAPIs in action, I’ll first talk about the standard G/L balance display report (transaction FS10N).
Standard G/L Balance Display Report
Figure 1 shows the FS10N report. You normally would use an FS10N report to check the balance of a particular G/L account. The report breaks down the balances by fiscal period, debit, credit, and total balance.
Figure 1
FS10N report
Enter the G/L account, company code, and fiscal year. Click the execute icon, which brings up
Figure 2.
Figure 2
FS10N – Period-wise balance display screen
You can see the G/L account period-wise balance. Double-click any row to view all the line items and documents. Then you can see the final output FS10N report (
Figure 3).
Figure 3
Final output FS10N report
The problem with FS10N is that you can use only one G/L account at a time to get the G/L balance for the period. If you use the above mentioned BAPI, however, then you can see all the G/L balances period-wise for more than one account. Now I’ll show you how you to get the output using the BAPI.
Test and Use BAPIs
To find a G/L BAPI, follow menu path Financial Accounting > General Ledger Accounting > General Ledger > GetGLAccountPeriodBalance (
Figure 4). On the right section of the screen are four tabs:
- Detail: This displays the BAPI’s technical details. In this tab, use the function module in the ABAP program BAPI_GL_GETGLACCPERIODBALANCES to display the G/L period-wise balances (Figure 4).
- Documentation: This shows the BAPI’s use and functionality. Before selecting any BAPI, read the documentation carefully: It gives you the entire details of the BAPI, its parameters, and how to use it.
- Tools: This displays the tools you need to use to create the BAPI.
- Project: This explains how to implement the new project using the standard BAPI and custom BAPIs. If you want to change SAP’s standard BAPI, then you do not need to go to the Project tab. If you are making any change in the BAPI, then you have to create a project where you can customize the BAPI. Those with ABAP experience primarily use this tab.
Figure 4
Expand the BAPI to the object level
To get a feel for the layout that the BAPI provides, you should test any BAPI before using it in a program. Select the Tools tab and click on Business Object Builder (
Figure 5).
Figure 5
Select the Business Object Builder
Click the Display button to bring up the screen in
Figure 6. Expand the Methods node to view all the methods. Different methods in BAPIs contain standard SAP programs. You can reuse the methods anywhere in the program — there’s no need to write an ABAP program for them. This helps to reduce the programming work and increases the reusability.
Figure 6
Expand the Methods node
For this BAPI, green squares circled in
Figure 6 highlight four methods. Depending on your requirements, select the appropriate method. In this example, I selected GeneralLedger.GetGLAccountPeriodBalances because I am looking for the G/L account period-wise balance. To execute any of the methods, select the method by placing your cursor on it. Click on the test/execute icon (F8) to bring up the screen that appears in
Figure 7.
Figure 7
Test the BAPI (method)
You can choose from three methods depending on your requirements: GETGLACCOUNTBALANCE, GETGLACCOUNTCURRENTBALANCE, and GETGLACCOUNTPERIODBALANCES. In this case, the methods differ from one another by displaying G/L account balances in different formats. One method gives only the G/L account balance, while the others give the current balance or balances by period. Choose the method based on your requirements. Execute any of these methods by clicking on the execute icon. In my example, I chose GETGLACCOUNTPERIODBALANCES, and the screen in
Figure 8 appeared. You can enter the details to get the output of the BAPI method you selected. The parameters are different for each method, so if you are using a different method, the screen may vary.
Figure 8
Data input for testing the BAPI
Note
From BAPI Explorer, go through the Financial Accounting node to see the different BAPIs. Read the documentation and test it in the manner I showed you above so that you can use it in any of your programs.
In my example, I input the company code as
0001
, G/L account as
113105
, fiscal year as 2006, and currency type as
10
, which stands for a local currency as defined for company code
0001
.
Click on the execute icon to execute the BAPI and bring up the screen in
Figure 9. At the bottom of the screen, you can see that the BAPI has returned 16 entries. You should expect this because this particular company code has 16 fiscal periods and this particular G/L account has only been posted to one time. Click on the icon next to 16 Entries to see the period-wise posting details to the G/L account.
Figure 9
The details of period-wise posting to the G/L account 113105
The report in
Figure 10 shows G/L account periodic balances in the report. You can verify this information with FS10N, and contrast it against the format in
Figure 3.
Figure 10
Period G/L account balance
Once you have completed testing the BAPI, a technical consultant can fit it into the program. As mentioned in my example, you have to create a customized program in which you can use the BAPI and get the required output the user requested.
Kiran Bapat
Kiran Bapat is an SAP FI/CO, EC-CS, and SEM-BCS expert. She has seven years of industry experience and has worked on SAP FI, EC-CS, and SEM BCS for three years.
If you have comments about this article or publication, or would like to submit an article idea, please contact the
editor.