Demonstrates the sap-srfc-server component running in a Fuse camel runtime.

Author: William Collins - Fuse Team
Level: Intermediate
Technologies: Fuse, SAP, Camel, Blueprint
Summary: This quickstart demonstrates how to configure and use the sap-srfc-server component in a Fuse environment to handle a remote function call from SAP. This component handles a remote function call from SAP using the Synchronous RFC (sRFC) protocol.
Target Product: Fuse
Source: http://github.com/punkhorn/sap-quickstarts/
This quick start shows how to integrate Apache Camel with SAP using the JBoss Fuse SAP Synchronous Remote Function Call Server Camel component. This component and its endpoints should be used in cases where a Camel route is required to synchronously handle requests from and responses to an SAP system.
This quick start handles requests from SAP for the GetList method of the FlightCustomer BAPI to query for Customer records in the Flight Data Application. The route of this quick start simply mocks the behavior of this method by returning a fixed response of Customer records. The sap-srfc-server endpoint at the beginning of the route consumes a request from SAP and its contents is placed into the message body of the exchange's message. The request is then logged to the console. A processor bean then builds a response message for the BAPI method which contains a fixed set of customer records. It then replaces the message body of the exchange's message with this response. The response is then logged to the console. The sap-srfc-server endpoint then sends the response message back to the caller in SAP.
NOTE The sRFC protocol used by this component delivers requests and responses from and to an SAP system BEST-EFFORT. When an SAP system experiences a communication error when sending a request to or receiving a response from this component, it will be in doubt whether the processing of a remote function call in Camel was successful. For the guaranteed delivery and processing of requests in Camel please see the JBoss Fuse SAP Transactional Remote Function Call Server Camel component.
In studying this quick start you will learn:
- How to configure the Fuse runtime environment in order to deploy the JBoss Fuse SAP Synchronous Remote Function Call Server Camel component.
- How to define a Camel route containing the JBoss Fuse SAP Synchronous Remote Function Call Server Camel component using the Blueprint XML syntax.
- How to use the JBoss Fuse SAP Synchronous Remote Function Call Server Camel component to handle requests from SAP.
- How to configure connections used by the component.
For more information see:
- https://access.redhat.com/documentation/en-us/red_hat_fuse/7.0/html-single/apache_camel_component_reference/#SAP for more information about the JBoss Fuse SAP Camel components
- https://access.redhat.com/products/red-hat-fuse for more information about using JBoss Fuse
Before building and running this quick start you will need:
- Maven 3.1.1 or higher
- JDK 1.8
- A JBoss Fuse 7.0.0 container
- SAP JCo3 and IDoc3 libraries (sapjco3.jar, sapidoc3.jar and JCo native library for your OS platform)
- SAP instance with Flight Data Application setup.
To configure the quick start for your environment:
- Deploy the JCo3 library jar and native library (for your platform) and IDoc3 library jar to the
libfolder of your JBoss Fuse installation. - In your JBoss Fuse installation, copy the
org.osgi.framework.system.packages.extraproperty from the config properties file (etc/config.properties) to the custom properties file (etc/custom.properties) and append the following packages to the copied property:
org.osgi.framework.system.packages.extra = \
... \
com.sap.conn.idoc, \
com.sap.conn.idoc.jco, \
com.sap.conn.jco, \
com.sap.conn.jco.ext, \
com.sap.conn.jco.monitor, \
com.sap.conn.jco.rt, \
com.sap.conn.jco.server
-
Ensure that the SAP Instance Configuration Configuration Parameters in the parent pom.xml file (
../../.pom.xml) of quick starts project has been set to match the connection configuration for your SAP instance. -
Ensure the destination
QUICKSTARThas been defined in your SAP instance:
a. Using the SAP GUI, run transactionSM59(RFC Destinations).
b. Create a new destination (Edit > Create):
1. RFC Destination :QUICKSTART.
2. Connection Type :T.
3. Technical Settings :
i. Activation Type :Registered Server Program.
ii.Program ID :QUICKSTART.
4. Unicode:
i. Communication Type with Target System :Unicode -
Ensure the following
ZBAPI_FLCUST_GETLISTABAP program is installed and activated in your SAP client:*&---------------------------------------------------------------------* *& Report ZBAPI_FLCUST_GETLIST *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ZBAPI_FLCUST_GETLIST. DATA: RFCDEST LIKE RFCDES-RFCDEST VALUE 'NONE'. DATA: RFC_MESS(128). DATA: CUSTOMER_DATA LIKE BAPISCUDAT, IT_CUSTOMER_LIST TYPE STANDARD TABLE OF BAPISCUDAT. DATA: IT_RETURN TYPE STANDARD TABLE OF BAPIRET2, RETURN TYPE BAPIRET2. RFCDEST = 'QUICKSTART'. CALL FUNCTION 'BAPI_FLCUST_GETLIST' DESTINATION RFCDEST TABLES CUSTOMER_LIST = IT_CUSTOMER_LIST RETURN = IT_RETURN. IF SY-SUBRC NE 0. WRITE: / 'Call ZBAPI_FLCUST_GETLIST SY-SUBRC = ', SY-SUBRC. WRITE: / RFC_MESS. ELSE. WRITE: / 'CUSTOMER_LIST:'. ULINE. WRITE: /5 'CUSTOMERID', 16 'FORM', 30 'CUSTNAME', 55 'STREET', 85 'POSTCODE', 95 'CITY', 120 'COUNTR', 127 'PHONE', 157 'EMAIL'. LOOP AT IT_CUSTOMER_LIST INTO CUSTOMER_DATA. WRITE: /5 CUSTOMER_DATA-CUSTOMERID, 16 CUSTOMER_DATA-FORM, 30 CUSTOMER_DATA-CUSTNAME, 55 CUSTOMER_DATA-STREET, 85 CUSTOMER_DATA-POSTCODE, 95 CUSTOMER_DATA-CITY, 120 CUSTOMER_DATA-COUNTR, 127 CUSTOMER_DATA-PHONE, 157 CUSTOMER_DATA-EMAIL. ENDLOOP. WRITE: / 'RETURN:'. ULINE. WRITE: /5 'TYPE', 20 'ID', 40 'MESSAGE'. LOOP AT IT_RETURN INTO RETURN. WRITE: /5 RETURN-TYPE, 20 RETURN-ID, 40 RETURN-MESSAGE. ENDLOOP. ENDIF.
To build and run the quick start:
- Change your working directory to the
sap-srfc-server-fusedirectory.
- Run
mvn clean installto build the quick start. - In your JBoss Fuse installation directory run,
./bin/fuseto start the JBoss Fuse runtime. - In the JBoss Fuse console, run
install -s mvn:org.fusesource/camel-sapto install the JBoss Fuse SAP Synchronous Remote Function Call Server Camel component. Note the bundle number for the component bundle returned by this command. - In the JBoss Fuse console, run
install -s mvn:org.jboss.quickstarts.fuse/sap-srfc-server-fuseto install the quick start. Note the bundle number for the quick start returned by this command. - In the JBoss Fuse console, run
log:tailto monitor the JBoss Fuse log. - Invoke the camel route from SAP by running the
ZBAPI_FLCUST_GETLISTprogram. - In the console observe the request and response received and returned by the endpoint.
- Compare this response with the received data displayed by the ABAP program.
To uninstall the quick start and stop the JBoss Fuse run-time perform the following in the JBoss Fuse console:
- Enter Ctrl-c to stop monitoring the JBoss Fuse log.
- Run
uninstall <quickstart-bundle-number>providing the bundle number for the quick start bundle. - Run
uninstall <camel-sap-bundle-number>providing the bundle number for the component bundle. - Run
shutdown -fto shutdown the JBoss Fuse runtime.