Skip to Content

PI 7.31 introduces a Java only version of PI. This obviously is much more efficient for message processing. However, many existing XI/PI customers have built processing logic on ABAP stack.  In this blog, we’ll look at the steps that can be carried out to create similar functionality on Java stack. I hope the information will be useful and I welcome any suggestions/comments.

     I’ll take a sample use case – dynamic receiver determination based on custom table entries. ( i.e. based on file name, route the      message to different receivers ). For our discussion, the table will be very simple – it has three columns : id, filename and receiver. Id      is primary key and filename is the field that is compared to pattern match with the message’s filename to determine the receiver      business system. The table is too simplistic and data won’t be normalized but let’s ignore that for now .

Of course, it can be easily implemented using XPath expressions in PI 7.31 but I’m using this as it covers a functionality that was often implemented by clients on ABAP stack and it’s a good use case as we can use it to show usage of  persistence.  On ABAP stack, this functionality can be implemented using the following approach.

  • – Create an ABAP class (with interface IF_MAPPING ) for processing logic where lookup on custom table is performed. This ABAP class is used in the operation / interface mapping.
  • – SM30 can be used for table maintenance
  • – SE16 can be used to display table entries.


As shown in the below diagram, a message may arrive / leave at Java stack but the scenario used ABAP development infrastructure. Of course, it was not mandatory but given ABAP skill set being more widespread in SAP landscapes we had the below situation in many cases.

  image1.PNG

So in a file to file transfer, the FTP adapters (on Java stack ) will receiver / send files and an ABAP map is used to perform lookup to find the receiver.

Option from PI7.31 onwards:

  image2.PNG

The following approach could be taken to create similar functionality on Java stack:


  • Create tables in Java dictionary.
  • Since SAPUI5 is supported by SAP AS Java and is the recommended UI by SAP, it can be used to build display and maintenance screens.
  • – For server side processing ,we can use servlets to handle requests from SAPUI5 client. We’ll need two servlets – one to display data entries already in database and a second one to create new entries.
  • – Receiver determination class is on Java stack where we can use Lookup API in a java mapping program. This is a normal Java map and can be built using DatabBase Accessor. I won’t cover in this blog but the github link for this project has the code which can be referred.

To keep the model simple, we can perform database operation in the servlet itself via JPA and not really go via EJBs. EJBs can be used for more complicated scenarios.

Additional Libraries Required:

  • As it’s much more easier to use JSON with any Javascript library including SAPUI5, we’ll use Google GSON libraries to convert server side response to a JSON message.

     Hence, our development objects will look somewhat like this.

image3.PNG

We’ll use SAP Java Development Components ( DCs ) to leverage benefits of NetWeaver Development infrastructure for lifecycle management.

Some customers may still want to maintain the database on ABAP stack ( e.g. in their ECC system / SOLMAN etc .)  and have it replicated to Java stack. In these cases, the messages can be sent to Java AS over HTTP via a RFC destination by tying it in with changes over ABAP tables. In case servlet expects/ returns JSON messages, we can use the standard ABAP class /SDF/CL_E2E_XI_ALERT_JSON_DOC / use SCN’s code exchange to get the JSON tool in case your ABAP system doesn’t have this standard JSON processing class.

In this case, the scenario will look like as below.

image4.PNG

Implementation Steps ( our original scenario using SAPUI5):

  1. Google GSON libraries: Create a DC of type external library with Google GSON jar to package the required libraries. This is required as the servlet response will be in JSON format which can be easily interpreted by the client side SAPUI5 JavaScript code.
  • – Create a DC for external library and add the jar file to libraries folder.

/wp-content/uploads/2013/09/image7_285798.png

Change the access to allow access for both COMPILATION as well as ASSEMBLY.

/wp-content/uploads/2013/09/image8_285803.png

  • – Ensure that both public parts have jars.

/wp-content/uploads/2013/09/image9_285804.png

     2. Create a dictionary DC. It’ll have an ID column and FILENAME and RECEIVER columns. Based on FILENAME, we’ll determine the      RECEIVER.

/wp-content/uploads/2013/09/imag10_285805.png

Create dictionary and deploy it to SAP Java Server.

/wp-content/uploads/2013/09/image11_285812.png

  • – Create an additional TABLE for generating keys. We’ll use this later for primary key generation.

/wp-content/uploads/2013/09/image12_285813.png

  • – Verify that the table exists on database. You may switch to database development perspective. Create a connection using your dB connection details.

/wp-content/uploads/2013/09/image13_285814.png

3. Create an EE application of type “Web Module” and perform the following steps:

  • Add JPA support by modifying project facet.
  • /wp-content/uploads/2013/09/image14_285815.png


  • – Generate entities from tables. This will generate a class for the database table.
  • /wp-content/uploads/2013/09/image15_285816.png

It should already have the below annotation.

/wp-content/uploads/2013/09/image16_285817.png

As we’ll use key generation from a different table (TMP_KEYGEN) , the below annotations are required.

/wp-content/uploads/2013/09/image17_285818.png

Update persistence.xml to change the transaction type as Local as we’ll be managing transactions in servlet code while persisting data.

/wp-content/uploads/2013/09/image18_285819.png

  • In summary:
  • Add SAPUI5 SCAs and put dependency for both the DC as well as the SC.
  • Add SAPUI5 Javascript libraries.
  • Add SAPUI5 Java libraries.
  • Update web.xml to add components required for SAPUI5
  • – We’ll create two servlets: RetrieveData will display existing table entries and UpdateData is used to create entries. Both servlets will need to have the JPA information injected at runtime and hence we need the following annotation / declaration.

/wp-content/uploads/2013/09/image19_285820.png

RetrieveData servlet will return all values in the database.

/wp-content/uploads/2013/09/image20_285833.png

  • – UpdateData inserts values to the database table:

/wp-content/uploads/2013/09/image21_285834.png

write( response, map ) is a helper method has been written to write the JSON response – it’s the last 3 lines of the previous servlet.

Nothing too fancy in html file – it calls the main view.

/wp-content/uploads/2013/09/image22_285835.png


I won’t go throught the entire JS code. Essentially it builds the views shown later below. The Javascript code invokes GET method on RetrieveData servlet. Here, we invoke a GET method on RetrieveData servlet and push the result into an array which can later be bound to a table that will be displayed.

/wp-content/uploads/2013/09/image23_285839.png

And code to trigger POST. We just display an alert message .

/wp-content/uploads/2013/09/image28_285867.png

Java files structure for the web module:

/wp-content/uploads/2013/09/imag31_285921.png

and files for UI in the web module:

/wp-content/uploads/2013/09/imag32_285922.png

This is how the project DCs look.


/wp-content/uploads/2013/09/image25_285841.png

Dictionary DC was created and deployed separately as it doesn’t have to be part of this EAR.

jsonlib: Has Google GSON libraries for Java processing.

detcvr: It’s the webmodule – It has servlet , views as well as JPA generated entity file.

dtrcvear: It is our EAR to deploy the application to SAP AS Java.



This is how the screen turns out to be. We can maintain values :

/wp-content/uploads/2013/09/image26_285845.png

And entries are dsiplayed using the “Display Routing Values” tab.

/wp-content/uploads/2013/09/image27_285846.png

To test in PO, create an iFLow with two receivers, one default and the second one will be determined based on Java map which will perform a lookup on the table to get the receiver business system based on filename. Configure Routing with Dynamic Message Router

/wp-content/uploads/2013/09/image41_286726.png

and process two files: First with an arbitrary name and second one has name starting with IN which was updated in our dB by SAPUI5 application. Based on the table entry, the message is routed to BS_DUMMY_IN business system.

/wp-content/uploads/2013/09/image43_286761.png

The code for this project can be referred at https://github.com/viksingh/PIDYNAMICRCVDCs .


To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply