0% found this document useful (0 votes)
870 views20 pages

How To Create Custom Adapter Module in SAP PI - PO For EJB 3.0 Version - SAP Blogs

The document provides step-by-step instructions for creating a custom adapter module in SAP PI/PO using EJB version 3.0. It details each step of the process including creating projects, adding required libraries, configuring deployment descriptors, and deploying the EAR file. The document is technical in nature and aims to help SAP PI/PO developers with creating their own custom adapter modules.

Uploaded by

mohananudeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
870 views20 pages

How To Create Custom Adapter Module in SAP PI - PO For EJB 3.0 Version - SAP Blogs

The document provides step-by-step instructions for creating a custom adapter module in SAP PI/PO using EJB version 3.0. It details each step of the process including creating projects, adding required libraries, configuring deployment descriptors, and deploying the EAR file. The document is technical in nature and aims to help SAP PI/PO developers with creating their own custom adapter modules.

Uploaded by

mohananudeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.

0 Version | SAP Blogs

Follow RSS feed Like


Community

Ask a Question Write a Blog Post Login

Technical Articles

Bijayashree Banoj Brahma


May 3, 2019 6 minute read

How to create Custom Adapter Module in SAP PI/PO for EJB


3.0 Version
4 Likes 6,298 Views 2 Comments

Introduction:

In this blog, we will see step-by-step  process to create SAP PI/PO Custom Adapter module, EJB version 3.0. 
As, I don’t nd any blog, where each steps are clearly mentioned, with detail con guration. Hope this will help
SAP PI/PO Developers.

Custom Adapter Module Creation Process:-

Module Name–> ReadExcelFile

In NWDS: Go to File –-> New –-> EJB Project

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 1/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

EJB Project–> ExcelToXML_EJB

EAR Project–> ExcelToXML_EAR

EJB module version –> 3.0

Click Next and Next.

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 2/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

EJB Client JAR –> Uncheck

Generate ejb-jar.xml deployment descriptor –> Check

Click on Finish.

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 3/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

Two Projects are Created as below.

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 4/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

Right Click on EJB Project –> New –> Session Bean (EJB 3.x)

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 5/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Choose EJB project created before and provide Java package & Class Name.
Follow RSS feed Like

State Type –> Stateless

Check Remote and Local and Finish.

Below Objects are created.

Add External JAR les and Libraries to EJB project.

Right Click on EJB project –> Preference –> JAVA Build Path –> Add Libraries

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 6/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Select XPI Library –> Click Next


Follow RSS feed Like

Select XPI Adapter Libraries from drop down –> Finish

Add “com.sap.aii.af.svc_api.jar” le as External Jars for auditlog

Add “jxl-2.6.jar” for reading Excel File (.xls).

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 7/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Click on Apply –> Ok


Follow RSS feed Like

Expand META-INF folder of EJB –> Click on ejb-j2ee-engine.xml –> Change the details as below.

Provide EJB and JNDI name.

JNDI name will be the Adapter Module Name in SAP PI/PO Communication Channel.

<?xml version=“1.0” encoding=“UTF-8”?>

<ejb-j2ee-engine xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=“ejb-


j2ee-engine_3_0.xsd”>

<enterprise-beans>

<enterprise-bean>

<ejb-name>ReadExcelFile</ejb-name>

<jndi-name>ReadExcelFile</jndi-name>

</enterprise-bean>

</enterprise-beans>

</ejb-j2ee-engine>

Expand META-INF folder of EJB Project –> Click on ejb-jar.xml –> Change the details as below

<ejb-class> –> This need to be your java package name and your Class name

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 8/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

<display-name> –> Your display name


Follow RSS feed Like

<ejb-name> –> Your ejb name

<?xml version=“1.0” encoding=“UTF-8”?>

<ejb-jar xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns=“http://java.sun.com/xml/ns/javaee”


xmlns:ejb=“http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd”

xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd”
version=“3.0”>

<display-name>ExcelToXML_EJB</display-name>

<enterprise-beans>

<session>

<icon/>

<ejb-name>ReadExcelFile</ejb-name>

<home>com.sap.aii.af.lib.mp.module.ModuleHome</home>

<remote>com.sap.aii.af.lib.mp.module.ModuleRemote</remote>

<local-home>com.sap.aii.af.lib.mp.module.ModuleLocalHome</local-home>

<local>com.sap.aii.af.lib.mp.module.ModuleLocal</local>

<ejb-class>com.sap.java.modules.ReadExcelFile</ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Container</transaction-type>

</session>

</enterprise-beans>

</ejb-jar>

Expand META-INF folder of EAR Project –> Click on application-j2ee-engine.xml –> Change the details as
below.

<?xml version=“1.0” encoding=“UTF-8”?>

<application-j2ee-engine xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:noNamespaceSchemaLocation=“application-j2ee-engine.xsd”>

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 9/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

<reference reference-type=“hard”>
Follow RSS feed Like

<reference-target target-type=“service” provider-name=“sap.com”>engine.security.facade</reference-target>

</reference>

<reference reference-type=“hard”>

<reference-target target-type=“library” provider-name=“sap.com”>engine.j2ee14.facade</reference-target>

</reference>

<reference reference-type=“hard”>

<reference-target target-type=“service” provider-name=“sap.com”>com.sap.aii.af.svc.facade</reference-target>

</reference>

<reference reference-type=“hard”>

<reference-target target-type=“interface” provider-name=“sap.com”>com.sap.aii.af.ifc.facade</reference-target>

</reference>

<reference reference-type=“hard”>

<reference-target target-type=“library” provider-name=“sap.com”>com.sap.aii.af.lib.facade</reference-target>

</reference>

<reference reference-type=“hard”>

<reference-target target-type=“library” provider-name=“sap.com”>com.sap.base.technology.facade</reference-


target>

</reference>

<fail-over-enable xsi:type=“fail-over-enableType_disable”

mode=“disable” ></fail-over-enable>

</application-j2ee-engine>

Deploy the EAR File:-

Open Window –> Preferences –> SAP AS java –> Add

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 10/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

Right Click on EAR Project –> Run As –> Run on Server

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 11/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

Select Your Server –> Click Next

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 12/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

Select EJB project –> Finish

Then the project will be deployed in your server and you can see in EJB Explorer (SAP PI/PO ).

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 13/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

Use Created Adapter Module In Sender Communication Channel.

Deployment to Higher Environments:-

Right Click EAR Project –> Export –> SAP EAR File

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 14/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Follow RSS feed Like

Sample Adapter Module code:-

package com.sap.java.modules;

import javax.ejb.Stateless;

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 15/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

import com.sap.aii.af.lib.mp.module.Module;
Follow RSS feed Like

import com.sap.aii.af.lib.mp.module.ModuleContext;

import com.sap.aii.af.lib.mp.module.ModuleData;

import com.sap.aii.af.lib.mp.module.ModuleException;

import com.sap.engine.interfaces.messaging.api.XMLPayload;

import com.sap.aii.af.service.auditlog.Audit;

import com.sap.engine.interfaces.messaging.api.Message;

import com.sap.engine.interfaces.messaging.api.MessageKey;

import com.sap.engine.interfaces.messaging.api.auditlog.AuditLogStatus;

import java.io.ByteArrayInputStream;

import jxl.Cell;

import jxl.Workbook;

/**

* Session Bean implementation class ReadExcelFile

*/

@Stateless

public class ReadExcelFile implements Module {

MessageKey amk = null;

@Override

public ModuleData process(ModuleContext mc, ModuleData imd) throws ModuleException {

String msgType = null;

String nameSpace = null;

Object obj = null;

Message msg = null;

try {

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 16/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

obj = imd.getPrincipalData();
Follow RSS feed Like

msg = (Message) obj;

amk = new MessageKey(msg.getMessageId(), msg.getMessageDirection());

XMLPayload xp = msg.getDocument();

if (xp != null) {

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,“AO: Now calling Convert Method to convert Excel(.xls) to


XML”);

byte by[] = convert(xp.getContent());

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,“AO: Conversion Done Successfully.”);

xp.setContent(by);

imd.setPrincipalData(msg);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,“AO: Principle data set successfully.”);

} catch (Exception e){

ModuleException me = new ModuleException(e);

throw me;

return imd;

public byte[] convert(byte src[]) throws Exception {

String xmldata = “”;

try {

ByteArrayInputStream byteArr= new ByteArrayInputStream(src);

Workbook wb = Workbook.getWorkbook(byteArr);

xmldata =“<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n\n”+ “<Details>”;

Cell[] cells ;
https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 17/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

Cell[] cellNames ;
Follow RSS feed Like

cellNames = wb.getSheet(0).getRow(0);

for(int j=1;j<wb.getSheet(0).getRows();j++) {

xmldata = xmldata+“<Record>”;

cells = wb.getSheet(0).getRow(j);

for(int i=0;i<wb.getSheet(0).getColumns();i++){

xmldata =
xmldata+“<“+cellNames[i].getContents()+“>”+cells[i].getContents()+“</”+cellNames[i].getContents()+“>”;

xmldata = xmldata + “</Record>”;

xmldata = xmldata + “</Details>”;

wb.close();

} catch (Exception e){

ModuleException me = new ModuleException(e);

throw me;

Alert Moderator
}

return xmldata.getBytes();
Assigned tags
}

} Process Orchestration | SAP Exchange Infrastructure | SAP Process Integration |


SAP

Note:-
Related Blog Posts
1 ) I am using below details for my development.

Upgrading SAP XI or SAP PI to SAP PO


NWDS–> 7.3 SP06 PAT0009 and jdk1.8.0_131
By Mario De Felipe , Feb 01, 2018
Common
SAP issues
PO –> 7.5inSP07
PO while working on PGP Encryption using SFTP
By Merina Acharya , Feb 11, 2020
EJB ModuleResponse
Synchronous Version–> 3.0 format using REST adapter in SAP PO/PI
in CSV
By Balamurugan J , Aug 18, 2020

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 18/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

2) If you will not nd XPI Libraries in your NWDS version, then you can add below jar les , as external jars and
Follow
any other jar les as per your requirements.RSS feed Like
Related Questions

PO 7.5 - NWDS Java EE 5 Libraries - error


By Peter Wallner , Feb 01, 2018
Do I need to recompile to get new EAR if I change the code in EJB
By  Any
3) ArijitSuggestion
Mukherjee , Apr 21, 2017
on this blog is always welcome.
Error while converting XLSX to XML in PO 7.5
4)
By We can create
Prashanth module and
Telagamsetty , Sepwrite Java code in di erent way, which you can nd in di erent blogs.
10, 2019

2 Comments

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

GAPP MOZART

March 10, 2020 at 1:45 am

Hi Bijayashree Banoj Brahma, Very useful blog on topic that has little doc.

Can please share how would one proceed to read channel parameters and use them in further processing .

BR,

Jay

Like(0)

Bijayashree Banoj Brahma | Post author

April 3, 2020 at 11:50 am

Hi Jay,

Thanks.

I will create one more, to need parameter from adapter module and use in processing.

I have already done that and use in my project “ReplaceStringBean”.

Thanks,

Bijayashree

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 19/20
12/23/2020 How to create Custom Adapter Module in SAP PI/PO for EJB 3.0 Version | SAP Blogs

 
Follow RSS feed Like
Like(0)

Find us on

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Cookie Preferences

Newsletter Support

https://blogs.sap.com/2019/05/03/how-to-create-custom-adapter-module-in-sap-pipo-for-ejb-3.0-version/ 20/20

You might also like