Skip to main content
Previous section   Next section

Setup Tasks

Before you can use the SAP components in a production, you must perform several setup activities. This chapter discusses them:

To access SAP, it is necessary to provide a username and password. This means that you must also create Ensemble credentials that contain an SAP username and password. For information on creating credentials, see Configuring Ensemble Productions.

Setting Up the Java Gateway

For information on setting up the Java Gateway, see “Prerequisites” in Using the Java Gateway.

Installing the SAP JCo Jar File

Obtain, from SAP, the SAP Java Connector 3.x, as appropriate for your operating system. Generally, this is provided as a compressed file. Uncompress it and place the contents in a convenient location. The directory should contain the following items:

  • examples subdirectory

  • javadoc subdirectory

  • Readme.txt file

  • sapjco3.dll file

  • sapjco3.jar file

  • sapjcomanifest.mf file

Generating Proxy Classes for SAP JCo

To communicate with SAP JCo, your Ensemble namespace must contain proxy classes that represent SAP JCo. To generate these classes, do the following:

  1. Start the Java Gateway.

    The easiest way to do this is as follows:

    1. Create a simple production that contains only one business host: EnsLib.JavaGateway.Service. (For an example, see Demo.SAP.Production.Bootstrap in ENSDEMO.)

      Configure the settings for this business host so that it can find the Java Gateway. For information, see “Using the Java Gateway in a Production” in Using the Java Gateway.

    2. Start the production, which starts the Java Gateway.

    For other ways to start the Java Gateway, see Using the Java Gateway.

  2. In the Terminal, change to your Ensemble namespace and use the ImportSAP() method of EnsLib.SAP.BootStrap, as follows:

    do ##class(EnsLib.SAP.BootStrap).ImportSAP(pFullPathToSAPJarFile,pPort,pAddress)
    Copy code to clipboard

    Where:

    • pFullPathToSAPJarFile is the full path to the SAP Jar file.

    • pPort is the port used by the Java Gateway.

    • pAddress is the IP address used by the Java Gateway.

Testing the SAP Connection

To test the SAP connection, do the following in the Terminal (or in code):

  1. Create an instance of EnsLib.SAP.Utils.

  2. Set the following properties of that instance. These are string properties unless otherwise noted.

    • SAPClient — SAP Client e.g 000.

    • SAPUser — Username that has access to the SAP server.

    • SAPPassword — Password for the user.

    • SAPLanguage

    • SAPHost— Host name or IP address of the SAP server.

    • SAPSystemNumber — SAP SystemNumber e.g 00.

    • JavaGatewayAddress — IP address or name of the machine where the JVM to be used by the Java Gateway server is located.

    • JavaGatewayPort — Port used by the Java Gateway.

    • SAPTransactionAutoCommit — Specifies whether to execute the BAPI "BAPI_TRANSACTION_COMMIT" after a successful BAPI/RFC-call. This property is %Boolean.

  3. Call the PingSAP() method of your instance. This method connects to SAP and performs a dynamic invocation of the STFC_CONNECTION function. It returns a %Status.

Generating Message Classes

Ensemble provides sample CSP pages to enable you to generate message classes that carry requests for SAP functions. These are available in the ENSDEMO namespace. To use these pages:

  1. Use the page /csp/ensdemo/sap/Index.csp to search for all the BAPIs and RFCs on the SAP system to which you are currently connected.

    You can also search by complete or partial name.

  2. Click a BAPI or RFC.

    The page now provides a link.

  3. Click this link.

    This displays a new page with details on that BAPI or RFC.

    This page provides a link you can use to generate messages for that BAPI or RFC.

  4. Click the link to generate messages.