Upload
-
View
570
Download
40
Embed Size (px)
DESCRIPTION
bapi
Citation preview
BAPI & RFC
What is BAPI ?
BAPI stands for ‘Business Application Programming Interface’ it is precisely defined interface providing access to processes and data in business application systems such as R/3.
BAPIs are the standard interfaces and they play important role in the exchange of business data between SAP components, and between SAP and non-SAP components.
BAPIs are defined as API methods of SAP Objects. These objects and their BAPIs are described and stored in the Business Object Repository (BOR).
Naming Convention of BAPI
BAPIs are identified by the name of the business object type followed by the name of the BAPI. (BAPI names describe what the BAPI does to the business object). A period separates the two parts of the name.
For example, the full name of the BAPI CheckAvailability() of the business object Material is: Material.CheckAvailability().
Uses of BAPIBAPIs can be called within the R/3 System from external application systems and other programs. A BAPI call can either be made as an object oriented method call or as a remote function call (RFC).
The Business Framework - the open, component-based architecture, which allows software components from SAP and third parties to interact and integrate with each other, is becoming more and more important.
SAP business objects are accessed through BAPIs (Business Application Programming Interfaces), which are stable, standardized methods. SAP business objects and their BAPIs provide an object-oriented view of R/3 business functions.
RFC (Remote Function Call)
A remote function call is a call to a function module running in a system different from the caller's. The remote function can also be called from within the same system (as a remote call), but usually caller and callee will be in different systems.
In the SAP System, the ability to call remote functions is provided by the Remote Function Call interface system (RFC). RFC allows for remote calls between two SAP Systems (R/3 or R/2), or between an SAP System and a non-SAP System.
BAPI & RFC (Comparison) Difference between RFC and BAPI are business objects. We create business objects and those are then registered in our BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case we only specify the business object and its method from external system in BAPI there is no direct system call.
While RFC are direct system call, Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types.
BAPI & RFC (Comparison) Cont..Remote Function Calls (RFCs):RFC is the protocol used by SAP for remote communication, that is, for communications between remote (independent) systems.
RFC is used for communications between two independent SAP systems, or for communications between an SAP system and a non-SAP system, such as an external application. It can also be used for communications between modules on the same system.
Using the RFC interfaces you can extend the functionality of R/3 applications from an external program.
Compared to using the GUI interfaces, using RFC interfaces requires more knowledge of the business logic of the R/3 applications with which you are integrating the external application.
External programs using RFCs can either make or receive remote function calls to or from an SAP system. Therefore, using RFCs an external program can act as either the client or the server to an SAP system. Conversely, the SAP system can take the role of either the client or the server to the external application.
Using RFCs requires knowledge of ABAP programming, because calling a remote function in R/3 is calling an ABAP function.
BAPI:R/3 systems contain a set of business objects, which are an object-oriented representation of real-world business objects. Examples of business objects are a purchase requisition, or an employee.
The advantage of using BAPIs over using RFCs is that using BAPIs requires no ABAP programming knowledge. You use BAPIs from standard programming languages such as C++ and Java.
Using BAPIs also offers the most stability to your application, because BAPIs stay consistent over different R/3 releases.
BAPI & RFC (Comparison) Cont..
Synchronous/Asynchronous
BAPI:Updation: Synchronous
Process: Asynchronous
RFC:Synchronous: This type of RFC executes the function call based on synchronous communication, meaning that the systems involved must both be available at the time the call is made. Synchronous communication can be implemented in function calls that require the immediate return of data to the sender system.
Asynchronous: the receiving system does not necessarily have to be available at the time a function call is dispatched from the sender system. The receiving system can receive and process the call at a later time.
Steps for creating a BAPI:
T code to create a BAPI is: BAPI.
Step 1: Define Structure For The BAPI
Step 2: Write Function Module
Step 3: Create the API Method
Step 4: Final Steps
Creating a BAPI
Creating a BAPI Cont…Step1: Define a structure for BAPIIn this step structures for the parameters and tables of the function module used for the BAPI are defined.
Go to T code ‘SE11’
Datatype -> Structure
Enter the Structure name
Click on create button
Creating a BAPI Cont…
Select Structure
Click continue
Creating a BAPI Cont…
Save it and Activate it
Step2: Write Function Module
Each BAPI must have its own function group.
Under the attributes tab remember to select Processing Type Remote Enabled module, otherwise the function module cannot be invoked via RFC and used as a BAPI.
Import/Export parameters can only be BY VALUE for an RFC enabled function module.
Creating a BAPI Cont…
Creating Function Group:
SE37 is the T Code for creating Function Module.
SE37 -> Goto -> Function Groups -> Create Group.
Creating a BAPI Cont…
Creating a BAPI Cont…
Type Function Group name
Save
Creating a BAPI Cont…
Type FM name and click on create
Give Function Group name and save it
Creating a BAPI Cont…
Make the function Remote Enabled
Creating a BAPI Cont…Import Parameters:
Check ‘Pass Value’Tables:
Press Enter
Creating a BAPI Cont…
Source Code:
Save it and Activate it
Creating a BAPI Cont…
Step 3: Create the API Method Using The BAPI WIZARD
BAPI wizard is used to expose the remote function module as a BAPI and it will generate some additional code, so the function module is a valid method of the BOR. This allows the BAPI to be called as a workflow method in addition to be called by an outside program.
Each function module corresponds to a method in the BOR
Creating a BAPI Cont…T Code to create the Business Object Builder: SWO1.
We can either create the new Object type as a subtype of an existing business object or create a new business object from scratch.
Creating a new BAPI Object:
T Code SWO1
Supertype not required because we are creating a new Object.
* For cross Applications
Creating a BAPI Cont…
When we create the business object a standard interface, an attribute ObjectType and the methods ExistenceCheck and Display are automatically generated. These cannot be changed.
Creating a BAPI Cont…
Adding API Method:
Select Here
Utilities
-> API Methods
-> Add Method
Creating a BAPI Cont…
Give the name of Function Module:
Click Here
Creating a BAPI Cont…
Click Here
Creating a BAPI Cont…
API Method Added
Now, Select the BAPI Object
Creating a BAPI Cont…
Change release status To Implemented
Edit -> Change Release Status -> Object Type -> To Implemented
Creating a BAPI Cont…
Change release status To releasedEdit -> Change Release Status -> Object Type -> To Released
Creating a BAPI Cont…
Implementing API Method:
Select API Method
Creating a BAPI Cont…
Change release status To implemented
Edit -> Change Release Status -> Object Type Component -> To Implemented
Creating a BAPI Cont…
Change release status To releasedEdit -> Change Release Status -> Object Type Component -> To Released
Creating a BAPI Cont…
Generating API Method
Click on Generate Button
Creating a BAPI Cont…
Now we can write codes for interface in VB, Java, C++ etc.
BAPI for SAP to SAP System
After giving the Transaction BAPI, we’ll get following screen:
Step 1: Give the Transaction BAPI
Now based on our requirement we have to search for BAPI, Here we are going to search for BAPI related to Purchase Order. Purchase order is in MM so we select that from the list.
We have to get purchase order detail, So Double click on the ‘GetDetail’. The
right frame will show the BAPI name. Materials Management -> Purchasing -> Purchase Order -> GetDetail
We need Purchase Order Header detail, double Click Header, we will get Right Frame with the Dictionary Reference. The Dictionary Reference is BAPIEKKO.We can see the fields by Double clicking that BAPIEKKO.
Now Expand The GetList by pressing > , you will get the screen as below
1
2
Note down the Fields name from the Components Column those are required in the report.
Frequently used BAPI:
Sales and Distribution:Customer Material Info: BAPI_CUSTMATINFO_GETDETAILM
Sales Order: BAPI_SALESORDER_GETLIST
Sales Order: BAPI_SALESORDER_GETSTATUS
Material Management:
Purchase Req Item: BAPI_REQUIREMENT_GET_LIST
Purchasing info: BAPI_INFORECORD_GETLIST
Purchase order: BAPI_PO_GETDETAIL
Production and Planning:
Planned order: BAPI_PLANNEDORDER_GET_DETAIL
Planned Indep Reqmt: BAPI_REQUIREMENTS_GETDETAIL
Finance:
AP Account: BAPI_AP_ACC_GETOPENITEMS
Debtor Credit: Account BAPI_CR_ACC_GETDETAIL
AR Account: BAPI_AR_ACC_GETOPENITEMS
ABAP Report using BAPI (in SE38) REPORT ZBAPI1.DATA : BEGIN OF I_POITEM OCCURS 0.INCLUDE STRUCTURE BAPIEKPO.DATA : END OF I_POITEM.PARAMETERS P_EBELN LIKE EKKO-EBELN default '4500012164'.CALL FUNCTION 'BAPI_PO_GETDETAIL'EXPORTINGPURCHASEORDER = P_EBELN* ITEMS = 'X'* ACCOUNT_ASSIGNMENT = ' '* SCHEDULES = ' '* HISTORY = ' '* ITEM_TEXTS = ' '* HEADER_TEXTS = ' '* SERVICES = ' '* CONFIRMATIONS = ' '* SERVICE_TEXTS = ' '* EXTENSIONS = ' '* IMPORTING* PO_HEADER =* PO_ADDRESS =TABLES* PO_HEADER_TEXTS =
PO_ITEMS = I_POITEM. " Assign the Internal Table* PO_ITEM_ACCOUNT_ASSIGNMENT =* PO_ITEM_SCHEDULES =* PO_ITEM_CONFIRMATIONS =* PO_ITEM_TEXTS = .* PO_ITEM_HISTORY =* PO_ITEM_HISTORY_TOTALS =* PO_ITEM_LIMITS =* PO_ITEM_CONTRACT_LIMITS =* PO_ITEM_SERVICES =* PO_ITEM_SRV_ACCASS_VALUES =* RETURN =* PO_SERVICES_TEXTS =* EXTENSIONOUT =
ABAP Report using BAPI (in SE38) Cont…
LOOP AT I_POITEM.WRITE :/ 'PO NUMBER = ' , I_POITEM-PO_NUMBER COLOR COL_HEADING,/ 'ITEM = ' , I_POITEM-PO_ITEM,/ 'MATERIAL NAME = ' , I_POITEM-MATERIAL,/ 'MATERIAL = ' , I_POITEM-PUR_MAT,/ 'CHANGED ON = ', I_POITEM-CHANGED_ON,/ 'SHORT TEXT = ' , I_POITEM-SHORT_TEXT,/ 'COMPANY CODE = ' , I_POITEM-CO_CODE,/ 'PLANT = ' , I_POITEM-PLANT,/ 'MATERIAL GROUP = ' , I_POITEM-MAT_GRP,/ 'QUANTITY = ' , I_POITEM-QUANTITY LEFT-JUSTIFIED,/ 'UNIT = ' , I_POITEM-UNIT,/ 'NET PRICE = ' , I_POITEM-NET_PRICE LEFT-JUSTIFIED.ULINE.ENDLOOP.
Note: We can write any number of fields from the Dictionary BAPIEKPO in the output, just Note the field and give that in the Write statement within
LOOP …ENDLOOP.
Output of the Report
Testing the Report: Give transaction ME23 and give the Purchase order number, We can see the details of the report there.
Click Here
Testing the Report Cont…
Thank You