Showing posts with label iDocs. Show all posts
Showing posts with label iDocs. Show all posts

Monday, March 12, 2012

Receiving Multiple IDocs Using Single Channel/Program ID In SAP Adapter

This is a very common problem with Oracle SAP Adapter. For receiving iDocs from SAP, we need to create a channel on the Application adapter tool and each channel is associated with a corresponding program id in SAP system. When we have multiple Integrations with SAP system, it becomes a maintenance overhead for SAP BASIS administrators to create multiple program ids for each of these integrations/idoc_types.

To overcome this situation and make sure we can receive multiple iDocs via same channel/program id, an elegant solution has been explained in the attached link.
https://blogs.oracle.com/ateamsoab2b/entry/soa_11g_sap_single_channel

Thursday, September 29, 2011

SAP IDoc Data With Japanese Kanji or Chinese Characters Overflows

Recently came across an issue while integrating SAP R3 (4.2) version with SOA 11g (11.1.1.4). When idocs are received by SAP Adapter from the SAP system containing Japanese Kanji/Chinese special characters, it was found that the data overflows on to next segments/xml tags and is distorted. This causes mapping issues as incorrect data is being mapped to. The root cause behind this behaviour is that SAP R/3(4.2) is a non-unicode system while SOA 11.1.1.4 is Unicode.

The issue is covered in below Oracle documentation as well
http://download.oracle.com/docs/cd/E14571_01/relnotes.1111/e10132/adapters_iway.htm#CIHBCICF

Here is the explanations provided by Oracle

"This issue only occurs on non-Unicode SAP MDMP environments, where one character can be two or more bytes. As an example of this issue, when using Japanese, the SAP field length is four characters. The English word "ball" fits correctly into the field because one character equals one byte. The Japanese word for ball in Shift-Jis encoding is three characters, but two bytes per character, so the last character is truncated and the last character appears in the next field. Since IDocs are positional delimited, this can cause errors in processing. This occurs because SAP uses character length, not byte length for all non-Unicode field lengths. There is no work around on this issue other than using Unicode or using shorter text in IDocs in DBCS."

None of the workaround suggested above were feasible options. So tried the below approach to fix this...

From SAP before sending the idoc, convert all Japanese strings to hexadecimal characters. Once SOA suite receives the idoc, the BPEL uses a java embed/custom XSLT function (java code) to convert the hexadecimal back to Japanese characters.There is lot of sample code available for doing these kind of hex to string conversion. Just make sure you are using the correct charset (like shift-jis for japanese kanji) while doing the conversion.
Now you should be able to see the idocs properly and use the converted japanese,chinese special characters correctly in your mappings.

Friday, July 16, 2010

Receiving SAP iDocs in Oracle BPEL process

This post is an extension to my earlier post on invoking-sap-bapis-from-oracle-bpel . Here I will be covering detailed steps involved in receiving SAP iDocs into Oracle BPEL process. Unlike Service adapters in case of BAPI we will be dealing with Event adapters incase of SAP iDocs. We can use events generated in SAP system due to some DB activity/application process to trigger a BPEL process. For doing this we need to create a SAP channel in Application explorer and select this channel to create a JCA Inbound WSDL(Event Notification – BPEL receive). Few things to be noted about SAP Channel:
  • It only applies to J2CA configuration
  • You must create channels for every different event object. Also each channel must be associated with a unique SAP R/3 program id.
  • After creating/modifying channels weblogic server must be restarted for the changes to take effect at runtime.
                

In above screenshot showing Channel creation steps, note the value of Program Id of server (BPEL01). This will be registered in the SAPGUI as a RFC destination. This helps SAP to direct the events to the target system. For detailed steps on how to register Program Id on SAPGUI please check the Appendix section Configuring SAP R/3 Outbound Processing from SAP R/3 User's Guide for Weblogic server


Once the SAP Channel has been created under Events section goto the Adapters section and generate the Inbound WSDL for your iDoc (you will have to use the SAP channel while creating inbound WSDL). This process generates 3 files: *.wsdl, *.jca and *.xsd under the $SOA_HOME/soa/thirdparty/ApplicationAdapters/wsdls directory.


Next copy these files to your local machine and in your Jdeveloper create a BPEL process with a third party adapter service which uses the *.wsdl and *.jca files for configuration. Complete the BPEL process to receive the idoc from the third party adapter service and do further processing.


Restart your Weblogic server and now when a transaction/action is performed on SAP server like generating a sales order that should trigger the BPEL process.