Skip to Content
author's profile photo
Former Member

JSP to ABAP

Hi,

Can anybody give me an idea as to how can i store data from .jsp page into sap table using ABAP. e.g. If i have a web page designed in .jsp and i want the data entered in the page to be stored in the tables i create, i want to have some idea as to where to start in ABAP.

thankyou

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Oct 05, 2005 at 06:16 PM

    You can either write an RFC or BAPI function in SAP and call this function from .jsp application using JCo connector or if you are on WebAS 640 I think you can use webservices.

    Attached please find more details on the process.

    ABAP <-> Java Communication

    SAP Java Connector (JCo)

    The SAP Java Connector is a toolkit that allows a Java application to communicate with any SAP system. It combines an easy to use API with unprecedented flexibility and performance. The package supports both Java to ABAP System as well as SAP System to Java calls.

    The SAP Java Connector is the best choice for building SAP-enabled Java applications because of the following features:

    High-performance JNI-based Remote Function Call (RFC) middleware

    Supports SAP R/3 system 3.1H and higher (and other mySAP components that have Business Application Provider Interfaces (BAPIs) or RFMs).

    Supports inbound (Java client calls BAPI or RFM) and outbound (ABAP calls Java server) calls.

    Supports synchronous, transactional and queued RFC.

    Supports client pooling (good for web servers).

    Multi-platform

    Complete and correct code-page handling (incl. multi-byte languages)

    Easy to install and deploy.

    JCO is essential for the communication between SAP J2EE Engine and SAP Web Application Server. It is acting as Java-Wrapper for the RFC-Library.

    Note: You can download JCo at http://service.sap.com/connectors. For SAP J2EE Engine 6.20 you need the 2.0 version. Follow the installation instructions to enable the SAP J2EE Engine to connect to SAP systems.

    Remote Function Call (RFC)

    RFC is an SAP interface protocol, which simplifies the programming of communication processes between systems. RFCs enable you to call and execute predefined functions in a remote system – or in the same system. RFCs manage the communication process, parameter transfer and error handling.

    In SAP J2EE Engine 6.20 RFC is used for processing ABAP to Java requests. A function is provided for receiving calls from the SAP systems. This is done by registering SAP J2EE Engine as an RFC destination.

    The J2EE Engine RFC Engine Service processes calls from the SAP systems. It dispatches the calls to a stateless Session Bean, which is registered in the JNDI. By the naming convention the JNDI name used is identical to the name of the SAP function module. Technically, the service is based on the JCO (SAP Java Connector).

    The EJB must implement the public void processFunction(JCO.Function function) method.

    The JCO.Function contains both the input and output parameters.

    To parse correctly the function calls from the SAP system, the JCO needs a repository. This is a remote connection to a repository of an SAP system.

    Scenario

    1. On startup the RFC Engine service connects to the repository of an SAP system.

    2. The RFC Engine service registers itself at the Gateway with a defined name. It is possible to register it under different names and at different Gateways.

    3. An SAP system calls a function for the registered RFC destination.

    Note: Make sure that the function is defined in the repository!

    4. The Gateway forwards the call to the RFC Engine.

    5. The RFC Engine looks in the JNDI for the EJB, which is registered under the function name.

    6. The RFC Engine calls the processFunction(JCO.Function) method of the EJB found.

    7. The results of that call (the modified JCO.Function ) are passed to the Gateway.

    8. The Gateway passes the results back to the SAP system.

    RFC Library

    The RFC Library offers an interface to an SAP system. The RFC library is the most commonly used and installed component of existing SAP software. This interface provides the opportunity to call any RFC function in an SAP system from an external application. Moreover, the RFC Library offers the possibility to write an RFC server program, which is accessible from any SAP R/3 system or an external application. Most SAP R/3 connectors use the RFC library as communication platform to SAP systems.

    The most important design features of the RFC Library are:

    Working with the native RFC protocol.

    Maximum functionality, that is almost all features of RFC in SAP R/3 systems have to be supported by the RFC Library, too.

    Maximum performance.

    Maximum flexibility.

    Full compatibility to other RFC releases.

    The RFC library is available for all OS platforms:

    Windows – librfc32.dll

    Unix/Linux – librfccm.so , librfccm.sl , and so on.

    On errors it writes trace-files into the current working-directory:

    rfc<GUID>.trc : One file per call with detailed trace-info.

    dev_rfc.trc : Combined file for all errors.

    Call Java Functions from SAP R/3

    The Java class JCO.Server can be used to create an RFC server. It registers under a program ID at an SAP Gateway.

    In the SAP System (Transaction SM59 ) the same information (program ID and SAP Gateway) will be maintained to define a TCP/IP-destination.

    ABAP programs can now call functions on this external destination

    On the Java side those function calls will be received in a callback method:

    handleRequest(JCO.Function function)

    The function contains both the input and output-parameters

    Why a Repository?

    The RFC-protocol sends only the values of the function call as a byte array, but does not send the function definition. Therefore the receiver needs a Repository to parse those values.

    Example:

    Receive byte-array: Hello199

    Parse into 3 parameters: „Hello“, 1, 99

    Although this Repository and the function-definitions could be created manually, typically an existing SAP Repository is used. The advantage is, that then the Repositories on both sides (Java and ABAP) are always the same.

    Note: When using an SAP Repository, the RFC Server is at the same time an RFC Client! This is important for understanding how the RFC Server must be configured.

    Configuration and Testing

    1. Install the SAP J2EE Engine 6.20.

    2. Run SAP J2EE Engine and start the Visual Administration Tool. Configure the RFC Engine Service in a way described below:

    a. Define the RFC destination:

    i. Program ID – the name of this RFC-destination;

    ii. Gateway host and Gateway service – Gateway, where to register;

    iii. Number of processes – maximum number of parallel threads;

    b. Define the repository – all other parameters (User, Password, Host, Client, System number, and so on) are used to connect to the repository of an SAP System.

    Note: For more information about the RFC Engine and its properties, see Administration Manual->Services Administration Reference->RFC Engine Service

    3. Deploy an EJB for testing. The EJB must support the processFunction(JCO.Function) method and must be bound in the JNDI with the name of the SAP function. Before deploying you have to specify the reference from the application to the JCO library. You can do this from SAP J2EE Engine Deploy Tool. Choose the “Deployer” Tab, then choose Deploy->Libraries from the toolbar menus. In the Libraries section choose the “References” Tab and add the “jco“ library.

    The above procedure is valid if you deploy the application from the SAP J2EE Engine Deploy Tool. In case you deploy it from the shell console, you can use the changeref shell command.

    Example:

    changeref –m <application_name> jco

    where <application_name> must be replaced with the name of the application which you are deploying.

    4. Configure the RFC-destination in the SAP System:

    a. Transaction SM59 – use this transaction to create a new TCP/IP connection. Enter the Program ID and the Gateway, which you specified in step 2.a.

    b. Save and press the “Test Connection” button to check the connection.

    5. Call a Function in SAP J2EE Engine from the SAP System:

    a. Transaction SE37 – use this transaction to enter the name of the function and press “Single Test”.

    b. Enter the RFC target system (which you configured in 4.a.) and all necessary values for the function.

    c. Press the execute-button to call the EJB in SAP J2EE Engine.

    Fast RFC

    Fast RFC Library is an extension to the RFC Library, which allows switching the communication to shared memory (instead TCP/IP). This means, that Fast RFC is only available, if the RFC client and the RFC server are on the same machine. It is available as native library for all OS platforms:

    Windows – frfclib.dll

    Unix/Linux – rfclib.so, frfclib.sl, ...

    Because shared memory communication is quite version specific, the libraries frfclib.dll and librfc32.dll must be exactly the same version as the SAP R/3-Kernel. If a TCP/IP-communication is used, this is not necessary.

    Architecture

    Connectivity between SAP J2EE Engine and SAP Web AS is available via several networking mechanisms (JCo via RFC, SOAP, …), which is applicable for loosely coupled applications following the currently popular web service approach. For tightly coupled applications, this is a less favorable solution. A tighter integration approach is required for the applications that are Java-ABAP mixtures.

    Fast RFC provides an additional fast local communication channel for JAVA-ABAP components via shared memory and an efficient representation response mapping of the data types of both systems. This gives the opportunity to use the other communication model (RFC/JCo) for gross granularity communication and to switch to fine granularity communication for tighter coupled applications.

    Using the ClusterInfo Tool

    Overview

    The ClusterInfo tool is a web-based application that you can deploy on the SAP J2EE Engine and use to obtain the following information:

    Current status of the cluster

    Details about the running dispatcher and server cluster elements

    JCo and RFC information for each server node

    The application also provides functions for testing standard and fast RFC connection to the R/3 system.

    Prerequisites

    To use this application, you need to install JCo. For more information, see the SAP Java Connector (JCo) section.

    Deploying the Application

    You can find the ClusterInfo application archive (ClusterInfo.ear) in <SAPj2eeEngine_install_dir>/tools/ClusterInfo directory. To deploy it, use the following procedure:

    1. Start the Deploy Tool and create a new project.

    2. Go to the Deployer tab and choose Deploy &#8594; EAR &#8594; Load EAR in the menu bar. Browse to ClusterInfo.ear.

    3. Choose Deploy &#8594; Libraries. In the Additional Libraries screen, go to the References tab. Choose Add and enter jco as a name for the new reference. Go to the Additional References tab. In the From Loader field, choose application from the drop-down menu, and enter ClusterInfo in the text box. In the To Loader field, choose service from the drop-down menu, and enter admin in the text box. To save the reference entry, choose Add. To confirm all changes, choose OK.

    4. Choose Deploy &#8594; Connect to connect to the SAP J2EE Engine. Enter the relevent logon information. If the Deploy Tool connects successfully, it displays a message “Connected.” in the status bar.

    5. Choose Deploy &#8594; Deployment &#8594; Deploy EAR. If the deployment has been successful, the Deploy Tool displays a message “Deployed successfully!!!” in the status bar.

    Using the Application

    After you have deployed the ClusterInfo application, you can run it by typing the following in the Address field of your browser: http://<yourhost>:<httpPort>/ClusterInfoWEB/servlet/Main.

    You can choose between the following options:

    Cluster Info

    STFC Tests

    Cluster Info

    If you choose this option, the application prompts you to log on to the SAP J2EE Engine. Then it displays a summary of the current system status. For each running cluster element you can obtain the following information:

    Cluster element name

    Cluster ID

    IP address

    Cluster Manager join port

    If it is server or dispatcher element

    In addition, you can view detailed status for each server element in the cluster, by choosing Details for the relevent server. The details include information about:

    System properties – platform, Java Virtual Machine, and so on

    SAP J2EE Engine – cluster version, build date, and so on

    JCo and RFC – paths to libraries, JCo classes, and so on.

    The last two fields of the table display the results from the FastRFC tests:

    FastRFC Connection – diplays OK if a fast RFC connection can be established; otherwise, displays an error message.

    Get SystemInfo through Fast RFC – diplays OK if a fast RFC connection works properly; otherwise, displays an error message.

    STFC Tests

    Using this option, you can call one of the following ABAP functions:

    STFC_CONNECTION – tests the connection to the R/3 system

    STFC_STRUCTURE – the import and export parameters are structures

    STFC_PERFORMANCE – the import and export parameters are tables; if you choose this function, you have to enter the required additional parameters as well.

    To run the tests, you must connect to the relevent R/3 system using either FastRFC or standard RFC connection. For the standard RFC connection you have to specify R/3 host and instance number.

    To log in to the R/3 system, use the same parameters that you specify when using the SAP Logon. The required fields are:

    Client

    User ID

    Password

    To run the test, choose Submit. The result of the test is displayed at the top of the page.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 05, 2005 at 06:18 PM

    I am assuming that you jsp page is storing the values in a bean while session is live. You would then need to use jCo to call an RFC enabled function module on the ABAP side to accept these values and store them in a custom table. You first need to examine what data you want to send to r/3 system. You can then develop the interface of your rfc enabled function module.

    transaction SE37

    Regards,

    Rich Heilman

    Add comment
    10|10000 characters needed characters exceeded