Adapters, Sap JDBC
Adapters, Sap JDBC
Adapters, Sap JDBC
Topics:
1. JDBC Adapter
2. SAP Adapter
3. WmDB
1. JDBC Adapter
JDBC Adapter provides a way to exchange data with relational databases through the use of a JDBC driver
and we perform this adapter task with the help of web Methods Integration Server.
The adapter provides real-time communication with the database without changes to your existing application
infrastructure.
Using JDBC Adapter client can perform database transaction like insert, update, delete etc.
The JDBC Adapter supports the databases like Oracle, Sybase, Teradata and Microsoft SQL Server.
JDBC Adapter provides a set of user interfaces, services, and templates that enable you to create integrations
with databases using a JDBC driver.
The isolation level settings can be specified in the Other Properties field of the Connection Configuration screen.
Connection Pools: Connection pools improve performance by enabling adapter services to reuse open connections
instead of opening new connections.
Connection Properties
Transaction Type: LOCAL_TRANSACTION or XA_TRANSACTION or NO_TRANSACTION
DataSource Class: oracle.jdbc.pool.OracleDataSource
serverName: localhost
user: adapter
password: adapter
Retype password: adapter
databaseName: xe
portNumber: 1521
networkProtocol: tcp
Other Properties: driverType=thin
Web Methods JDBC minimum pool size? (Only look this article)
Performance-wise a min connection > 0 will be "better" for the first set of transactions that is processed in IS using
those connections. That is because the connections to the DB will already be established--the time cost of connecting
and logging in was incurred during start-up rather than when a JDBC service was invoked.
With a min size of 0, the first JDBC service that is invoked will be delayed a bit while the connection is made and log-
in accomplished. After that, there is no overhead (for that connection--each connection up to max pool size will
connect and log-in when multiple connections are needed).
An idle pool will drop the connections back to 0 at some point, and then the next JDBC services will incur the
connect/log-in overhead again.
For busy pools, the actual connections will not go back to 0. They will be maintained and connection/log-in overhead
avoided.
The biggest problem with a min connection > 0 is the potential for stale sessions. This can cause a JDBC service
failure if a session is kept and is idle long enough for the DB to close the session or if the DB is restarted.
As usual, it is a trade-off. You want to strike a balance between keeping too many idle connections (wasteful and risks
stale connections) and establishing connections too often (time delay and impact on the DB server). It is likely rare
that a value other than 0 should/must be used.
The Integration Server requires access to the Java classes for each JDBC driver that it will use. Typically,
where must such Java classes be placed?
Ans: webMethods6\IntegrationServer\lib\jars
How do I sort using the JDBC select adapter service?
Ans: Although there is no tab to specify "order by" the same functionality is able to be specified in the "SELECT" tab.
One of the columns in the is labelled "Sort Order" which will allow you to specify the column(s) you wish to sort by. To
alter the order: simply alter the order of the columns selected
What is meant by "Block time out" and "Expire time out " in jdbc adapter configuration ?
Ans: Block timeout: refers to how much time the IS should wait to get connection from connection pool before
throwing exception. Expire Timeout:refers to how much time the free connection stay as it is before it expires.
What is the internal process for JDBC Adapter notification? what is the use of buffer table , sequence and
trigger objects for Adapter notification?
Ans: Insert and Update Adapter notifications use exactly once notification feature which ensures notification data will
not be duplicated even if a failure occurs during processing since it assigns Unique IDs for each pulishable document.
If there is a processing failure, the IS checks for duplicate records in storage and ignores any of the duplicate IDs
created during failure.
Stored procedure notification do not use publishable document unique IDs so they do not have support for exactly one
notification feature.
Insert, Update and Delete Notifications use a combination of triggers and buffer tables to capture the events happen
on specific tables in a dbase. While configuring the notification you configure the triggers and buffer tables. Adapter
creates trigger and buffer table only when you enable a notification. The trigger monitors the table and inserts the data
in buffer table and buffer tables holds the data. When you disable a notification adapter drops the trigger and
corresponding buffer table.
Notification publishes the publishable document which contains a single row from buffer tables and after publishing the
data/row is removed from buffer table.
How do I change JDBC connections between environments?
Ans: First solution is to use WmDeployer and to set it up to change the parameters of the JDBC connection as part of
the deployment map configuration.
Other solution is to have the JDBC connections in a separate package from the code and to only migrate it when a
connection is added/removed and to configure it for the particular environment. This allows you to migrate the other
packages and leave these other packages alone. The disadvantage is the manual reconfiguration required, but this
can be ok with the appropriate discipline.
How do I do a special join with JDBC Adapter Services?
Solution
As some special join syntax is still fairly database dependent (although there is now provision in the ISO/ANSI SQL
syntax), a custom SQL adapter service appears to be one possible solution to achieving it.
You replace any input variables with questions marks ("?") and then for each question mark you have to add an entry
to the Input JDBC list. These have to match the order and the type expected.
For any output column you need to add a corresponding entry in the output JDBC list. This will tell webMethods what it
should try to extract from your query.
Other Notes
For special joins:
Oracle has the (+) operator for outer joins (and also supports specification in the FROM )
Sybase has *= syntax
MySQL uses syntax in the from block
How do I know what datasource class to use in the connection screen?
Ans: Hit the help link while configuring the connection and you will find a list of the data source classes for different
types of database and different transaction model (e.g. XA vs LOCAL transactions).
What do I do if I get a "Adapter Runtime Error" when enabling a JDBC Adapter Connection?
Error Message
[ART.0114.1007E] Adapter Runtime: Error Logged. See Error log for details. Error: [ART.118.5042] Adapter Runtime
(Connection): Unable to enable connection resource folder:service.
[ART.118.5063] Adapter Runtime (Connection): Unable to start connection folder:service: after 1 attempt(s).
com/ddtek/jdbc/extensions/ExtEmbeddedConnection
"Error Connection
Solution
Ensure you have the sl53_cj33.jar file located in the IS/lib/jars/ directory. Ensure that the extension of the file is .jar
(not .zip).
2. SAP Adapter
Has same log file for all the IDoc sent/received Have individual log file for each IDoc
Stores Idocwith the TID name Here TID is divided into 3 parts as like in SAPThe
folder structure will be WmSap-->1st part of TID--
>2nd part of TID --> 3rd part.xml(contains the
IDoc)3rd part.xtn(log file for the IDoc)
Listners, Listnernotification, routing notification all Everything can be configured via Developer
need to be configured using Admin console
Its not like a JDBC Adapter Almost similar to JDBC Adapter
How to Create a SAP Adapter connection:
Adapters (IS)->click SAP Adapter->configure new connection->fill the following info -> click on Save Connection.
Package: RFCConnections
Folder Name: RFCConnections
Connection Alias: VEL_D7B
User Name: D7B_OIS
Password: QAZQ12@#
Client : 300
Language: EN
Application Server: SAPD7B.SAPNET.HP.COM
System Number: 00
Listener/ProgramID: SAP-OMIH
On the connections screen, click “No” in the enabled column for the connection you want to enable.
How to Create a Listener:
Adapters (IS)->click SAP Adapter->Go to Listeners -> Configure new listener->Click on RFC listener->Fill in the below
form and click on Save Listener.
Package = RFCConnections
Folder Name = RFCConnections.Listeners.Velocity
Listener Name = SAP_OMIH
Retry Limit = 5
Retry Backoff Timeout = 10
Program ID = SAP-OMIH
Gateway Host = SAPD7C.SAPNET.HP.COM
Gateway Service = sapgw00
Number of Threads = 5
Repository Server = VEL_D7C
SNC Enabled = No
SNC Quality of Service = Use global build-in default settings
RFC Trace = Off
Log Transaction status = on
Store Message body = on
Make status column as “Enabled” for the newly created Listener as shown below.
Create a SAP Adapter (RFC to SAP Inbound): which is used to invoke the RFC function module in the SAP
Create or locate folder where you want to create adapter service for example:SAPAdapter
Click on New -> click on Adapter Service -> click on Next -> click on SAP Adapter -> select an Adapter
Connection Alias -> click on Next -> Select RFC Adapter Service -> click on Next ->Give the relative name of
which u want and locate in folder( for example SAPEMP) -> click on Finish
Open created adapter and provide function pattern and group pattern. And click on save.
1. In the previous step, on the Function search tab, in the Function pattern field, type all or part of the name of
function module for which you want to create an adapter service.
2. Use pattern matching characters if you are unsure of the complete name and want SAP Adapter to search for
several RFCs with similar names.
3. Just enter the pattern and press enter.
4. Under function name, a list of RFCs that match your criteria you specified in previous step is displayed.
Steps to create a SAP Adapter Notification which listens for the SAP Call to webMethods (i.e. RFC to SAP
Outbound):
Go to RoutingNotifications package -> then go to RoutingNotifications folder then -> Create a folder structure
SAPD7C -> Right click on the SAPD7C, select New -> All Choices -> Adapter Notification(as shown below) and click
on Next -> Select SAP Adapter and click on Next ->RFC Listener Notification (Synchronous) and next->select the
adapter notification Listner and click next->provide same name and click on next-> click on next-> click on finish.
Open created adapter and provide function search info:
Function Pattern:RFC*
Group Pattern:*
Function name:RFCING
Function Description:
Group name:SYST
1. In the previous step, on the Function search tab, in the Function pattern field, type all or part of the name of
function module for which you want to create an adapter service.
2. Use pattern matching characters if you are unsure of the complete name and want SAP Adapter to search for
several RFCs with similar names.
3. Just enter the pattern and press enter.
4. Under function name, a list of RFCs that match your criteria you specified in previous step is displayed.
5. Once the Adapter notification is created, whenever the SAP function module (which you given in Function
search tab) issue a call, this Adapter notification will trigger the corresponding webMethods service and
respond back to SAP.
Go to RoutingNotifications package -> then go to RoutingNotifications folder then -> Create a folder structure
SAPD7C -> Right click on the SAPD7C, select New -> All Choices -> Adapter Notification(as shown below)
and click on Next -> Select SAP Adapter and click on Next -> Select Routing Notification (Synchronous)
and click on Next -> Select the routingListener and click on Next -> enter Name as “routingRule” and go to
SAPD7C and click on Next -> Select the Invoke Service and Click Next -> Click on finish.
Need to provide below details under Transport Settings Tab as shown in below screen.
Sender: SAPD7C
Receiver: OMIH2
Message: ALEAUD
Transport: IS
Go to Adapter Settings tab and click on browse button for Service Name
Select the Service Invoke and click on OK as shown below. Then SAVE and exit.
Go to WM Console -> Go to Adaptors -> SAP Adaptor -> Listener Notifications Link -> Filter for
“RoutingNotifications.SAPD7C.OMIH2.ALEAUD:routingRule”
Make it Enable status to “Yes”
•Sender –An arbitrary string that indicates who sent the message. If the Sender column has character “*” it indicates
that any SAP system can send the data to that particular SAP Adapter.
•Receiver –An arbitrary string that indicates the message destination. If the Receiver column has character “*” it
indicates that it can receive IDoc from any SAP system.
•Message type –is the message type sent by SAP system.
2 SAP PI Overview
SAP PI is SAP's EAI software. It provides adapters to communicate with external systems (e.g. Web service, JMS,
FTP, ...), can communicate with SAP ERP systems, and provides functionality to implement mapping logic. SAP PI
sits on top of SAP Web Application Server.
SAP PI consists of two components: the SAP PI Integration Server that interacts with the SAP Enterprise Core
Components and the SAP PI Adapter Engine that provides the ability to interact with other systems via adapters. SAP
PI includes a number of adapters to interact for example via HTTP, Web service, JMS, or FTP. Additional adapters
may be purchased from 3rd party vendors.
3 Connectivity Options
3.1 Direct Integration of ERP and IP (SAP <-> webMethods (SAP Adapter))
The webMethods SAP adapter is used together with a dedicated webMethods Integration Server instance to provide
integration between ERP and the IP. The dedicated webMethods Integration Server allows a decoupling between the
Integration Backbone and the SAP integration.
Benefits:
Fewer different components to manage
Proven approach used by numerous customers
DHL operations familiar with the management of webMethods IS
Promises best performance
Asynchronous & synchronous communication possible
Drawbacks:
Requires additional webMethods knowledge in ERP
3.2 Communication via PI using the XI adapter (SAP <-> SAP PI <-> webMethods (SAP PI Adapter))
webMethods provides an adapter to interact with SAP PI directly. This adapter exists since the XI days and remains
unchanged for interaction with SAP PI. A dedicated webMethods IS is only used for connectivity, all mapping &
transformation already done on the Integration Backbone.
Benefits:
Skips the external SAP PI Adapter Engine => better performance than JMS or Web services that used the Adapter
Engine
Asynchronous & synchronous communication possible
Drawbacks:
XI adapter is an older product that has seen limited usage (officially supported on webMethods 8.x)
Requires servers for PI and dedicated webMethods Integration Server => increased management efforts
3.3 Communication via PI using Web services (SAP <-> SAP PI <-> webMethods (webServices))
SAP PI provides a Web services adapter to call and offer Web services. This functionality can be used in conjunction
with the built-in Web service functionality of webMethods to integrate ERP and the IP.
Benefits:
Standards-based communication
Web services to be offered and called directly from the Integration Backbone integration layer
Drawbacks:
Most likely the slowest approach
Possibility of incompatibilities in the respective Web service stacks of SAP PI and webMethods
Asynchronous communication not intuitive
3.4 Communication via PI using JMS (SAP <-> SAP PI <-> webMethods (JMS))
SAP PI provides a JMS adapter to call and offer Web services. This functionality can be used in conjunction with the
built-in JMS functionality of webMethods to integrate ERP and the IP. SAP PI includes its own JMS provider but the
usage of webMethods Broker is recommended.
Benefits:
Standards-based communication
JMS is the standard communication in the Integration Backbone
Drawbacks:
Should be faster than Web services but slower than the other two options
JMS configuration on SAP PI Adapter Engine non-trivial (especially as features like authentication and encryption are
to be used)
Synchronous communication possible but not very intuitive
3.5 Ignored Options
The following options have been discounted and not researched in detail:
File, FTP via PI: not desired for new interfaces
HTTP: less strict than SOAP, might introduce manageability issues
RFC-based communication via PI: no benefits over RFC-based direct communication
XI-based communication with SAP EC component
Recommendation
A direct integration using the webMethods SAP adapter is the preferred approach. It simplifies the overall system
landscape as only one EAI platform is running and also ensures better performance as fewer components are
involved. The only downside is that it requires some webMethods knowledge on the ERP side to offer the necessary
functionality via SAP adapter and webMethods Integration Server.
If the use of SAP PI is mandated, the JMS based integration is the best choice.
Sending an IDOC from a SAP system.
When a IDOC is sent by an SAP system it is received by WM IS and some processing is done on the IDOC or stored
in a secondary storage device .
When a IDOC is received a flow service in IS has to be executed , we have to give the service name , folder name
and package name in the routing role(when a routing rule is defined).
Receive an IDOC service:
-> Sap.idoc.decodesdata (byte array to values object (with key & value)).
-> Sap . idoc . encode
Service out (XML Data -------------- IDOC data) (IDOC in values format to XML string)
-> Sample.IO.test.write to file
Filename : file path ........... XML
IDOC data ---------- file content
For test sending an IDOC to wM IS
1) Open web browser and paste the link
http://localhost:5555/SAP/submit-IDOCXML.html
2) Copy and paste the IDOC in text area (IDOC which is in XML format).
3) Modify the fields
< RCVPRN> Receiving logical system name given by SAP people(Found in routing rule)
sending logical system name given by SAP people (or found in Routing rule)
message type MATMOS(ORDERS) INVOICE/------------ Given by SAP
4) Click on the submit button to send the IDOC to an IS
Sending an IDOC (MATMAS) format to an SAP system and Data in the form of XML file.
Steps:
1) Get an sample MATMAS DOC in XML format.
2) Create a DTD from the MATMAS XML file . This is a document type in (MATMAS FORMAT)
3) Collect the mandatory fields for MATMAS and create a Document with the fields
(IDOC _ MAN).
4) Create a document type with the configurations for sending an IDOC
(IDOC--CONFIG)
DOCUMENT:
-> Table name -- EDI - DC40
-> Direct (2 for sending)
- > IDOC type (MATMAS 01/02/03)
-> Message type (MATMAS)
-> SNDPOR – MIR 57
-> SNDPRN -- MIR 57 LS (logical system name created in SAP server)
-> SNDPRT -- LS (Partner type)
-> RCVPOR -- SAP IDS
-> RCVPRN – IDS47800
-> Receiver port - LS
5) Create an XML Document from the XML file (Data in XML format) (IDOC __ XML)
6) Send IDOC service (For sending an IDOC)
Go to Advantage and log in. You will need an account that has access to software downloads. Please refer to your
licensing agreements with webMethods.
Go to software download for webMethods and look for SAP adaptor 4.6
SAP adaptor 4.6 relies on WmPartner. Download and install this first. (To install view installation instructions)
Download SAP adaptor 4.6 package SAP.zip. Put this in the replication/inbound and install via web admin console.
Shutdown your server.
Copy LIBRFC32.dll and sapjcorfc.dll from packages\SAP\code\libs to your windows SYSTEM32 directory.
Restart windows.
Start up IS.
In the web console the SAP link should show under Adapters.
Realtime Scenerio:
Automated transactions involving publish/subscribe on the broker are failing while sending BAPI's to SAP
with the following error:
This error does not occur when manually running the service that the trigger subscribing to the broker
document invokes.
pub.sap.client:lockSession
(pub.sap.bapi:decode)
(pub.sap.client:createTID)
pub.sap.transport.BAPI:OutboundProcess
pub.sap.bapi:commit
Problem
When running IS as a Windows NT service, SAP trace files are not created in the directory defined by setting
the RFC_TRACE_DIR in server.bat as per described in the adapter's installation guide.
pub.sap.client:releaseSession
Solution:
a) webMethods patch fix
Go to Advantage and log in. You will need an account that has access to software downloads. Please refer to your
licensing agreements with webMethods.
Apply patch IS_6-1_SP2_PubSub_Fix3 as per this support article on advantage:
http://advantage.webmethods.com/article/?id=SR-1-88000881
b) Code change
If applying the above patch does not work, simply disable the following three steps from the code snippet:
pub.sap.client:lockSession
pub.sap.bapi:commit
pub.sap.client:releaseSession
This should allow transactions to be processed but is not recommended as a long term solution.
Problem
We've had several cases where you can create a SAP Alias in webMethods and connect ok, then create a
listener in webMethods and that reports that it can connect ok, but then go into SAP and run SM59 and it
cannot connect back to webMethods.
Solution
The solution was to delete the individual listeners inside the SAP alias and recreate them.
IDOC_INBOUND_ASYNCHRONOUS
Firstly, invoke the following service. This service converts an input string into the equivalent IDoc format that is
understood by the file port of the SAP system.
pub.sap.idoc:decodeString
Secondly, invoke the following service. This service routes the IDoc into the designated SAP system. You will need to
configure an SAP Server in the SAP Adapter before invoking this service.
pub.sap.transport.ALE:OutboundProcess
Problem
When running IS as a Windows NT service, SAP trace files are not created in the directory defined by setting the
RFC_TRACE_DIR in server.bat as per described in the adapter's installation guide.
SET RFC_TRACE_DIR=%IS_DIR%\packages\WmSAP\logs
Solution
Define the RFC_TRACE_DIR as a system variable in Windows. Follow these steps:
Problem
The user that posted this document (SAPUser) could not be associated with a partner to check their identity.
Solution
You need to determine the appropriate group. For example assigning SAPUser to the TNAdministrators group will
resolve the problem. But, do you really want to do this?
Problem
Testing an RFC using Adapters > SAP Adapter > Lookup > RFC-XML Template returns the correct response.
But a different response is returned when running a service that invokes the RFC using
pub.sap.transport.RFC:OutboundProcess.
Solution
Ensure that you drop $tid from the pipeline before invoking pub.sap.transport.RFC:OutboundProcess in order to get
the correct response. Dropping this variable makes synchronous RFC call to SAP.
Alternatively you can also use pub.sap.client:invoke to make a synchronous call to RFC.