Professional Documents
Culture Documents
RFC allows for remote calls between two SAP Systems (R/3 or R/2), or between an SAP System and a non-SAP System. The called function can run in a different system on a different machine in the network. The remote function can also be called from within the same system (as a remote call). RFC consists of two interfaces: A calling interface for ABAP Programs and a calling interface for Non-SAP programs. Any ABAP program can call a remote function using the CALL FUNCTION...DESTINATION statement. The DESTINATION parameter tells the SAP System that the called function runs in a system other than the caller's. You can use the CALL FUNCTION statement to call remote functions by including an additional DESTINATION clause. CALL FUNCTION remote function DESTINATION dest EXPORTING f1 = IMPORTING f2 = TABLES t1 = EXCEPTIONS The field dest can be either a literal or a variable. Logical destinations are defined in the RFCDES table via transaction SM59 or via the menu path: Tools ->Administration, Administration->Network->RFC destinations.
Types of RFCs
Synchronous RFC(Default type) o The calling program continues the execution only after the called function is complete. o Eg: CALL FUNCTION remote function destination XXXX Asynchronous RFC o The calling program continues the execution without waiting for return from the called function. o Eg: CALL FUNCTION remotefunction STARTING NEW TASK taskname. Transactional RFC o The called function module is executed exactly once in the RFC server system. Each function call is seen as a transaction in the target system. Transactional RFCs use the suffix IN BACKGROUND TASK. o Eg : CALL FUNCTION remotefunction IN BACKGROUND TASK
Exceptions:
o o o o The system raises COMMUNICATION_FAILURE and SYSTEM_FAILURE internally. You can raise exceptions in a remote function just as you would in a locally called function. SYSTEM_FAILURE: This exception reports all failures and system problems on the remote machine. COMMUNICATION_FAILURE: This exception is raised when a connection or communications failure occurs. It does not report system problems (for example, abnormal termination) that occur on the remote machine.
BAPI can be accessed by two types of applications. o Dialog application Calls a BAPI and waits for results as the BAPI is processed. o Distributed application Uses ALE to exchange and replicate data between distributed systems.
BAPI Programming
The process of defining and implementing a BAPI consists of the following steps: o Firstly, we describe the scenario the BAPI is to be used in. o The BAPI concept and scenario is reviewed. o The BAPI and its interface is defined. o The individual programming objects for BAPI are created. o The BAPI is tested. o The BAP is released and frozen for further use. Some BAPIs and methods provide basic functions and can be used for most SAP Business Objects. These are called STANDARDIZED BAPIs.
Standardized BAPIs
BAPIs for Reading Data
o o o o GetList() , GetDetail() , GetStatus() , ExistenceCheck() Create() or CreateFromData(),
o o o
Creating a BAPI
Go to transaction swo1. Select the business object (Generally of type BUS nnnn), according to the functional requirement for which the BAPI is being created. Open the business object in change mode. Then Select Utilities ->API Methods ->Add method. Then enter the name of the function module and select Continue. In the next dialog box, following information needs to be specified : Method: Suggest an appropriate name for the method, Texts: Enter description for the BAPI, Radio buttons: Dialog, Synchronous, Instance-independent. BAPI s are usually implemented synchronously. Now, select Next step. To create the method select Yes in the next dialog box. After the program has been generated and executed, check the program in the method just created Thus, a BAPI is created.
In the pop-up that comes up, select the radio button structure.
In the components tab of the structure, give the different fields and their corresponding field types and press enter to check the compatibility.
Go to the Attributes tab and select the radio button reading remote -enabled module. Come back to the imports tab and provide the import parameters as shown or as per your requirement.
Now in the Export tab, provide the export parameters as shown or as per your requirement.
In the tables tab, provide the information as shown or as per your requirement.
The next screen you visit is the source code. It would look like this.
go
to
the
attributes
tab.
Go
to
Function
Now click on the methods to drop down and see what methods are provided by default. There would be two methods, showing in red color which comes by default while creating the BAPI.
In the ultimate pop-up, click the next step icon. We observe that the information is predefined in the fields This is the next screen where you would just click on the next icon.
Click on Yes. You can see an information message reading ZBAPIFMWBS inserted.
Now save after you add the method. Select & Double click on the API method.
The message shows, the object type status set to modeled. (or already modeled) Go to: EditChange Release StatusObject type Component To Implemented.
You can see a message reading Object type status set to implemented
Now go to BAPI T-code (BAPI) we can find the BAPI (our BAPI) The BAPI browser would look like the screen below.
You can click on the Alphabetical tab so that you can browse the BAPIs in an alphabetical order. Find your BAPI as shown below.