Skip to Content
Technical Articles
Author's profile photo Bijayashree Banoj Brahma

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


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 find any blog, where each steps are clearly mentioned, with detail configuration. Hope this will help SAP PI/PO Developers.

Custom Adapter Module Creation Process:-

Module Name–> ReadExcelFile

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

EJB Project–> ExcelToXML_EJB

EAR Project–> ExcelToXML_EAR

EJB module version –> 3.0

Click Next and Next.

EJB Client JAR –> Uncheck

Generate ejb-jar.xml deployment descriptor –> Check

Click on Finish.

Two Projects are Created as below.

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

Choose EJB project created before and provide Java package & Class Name.

State Type –> Stateless

Check Remote and Local and Finish.

Below Objects are created.

Add External JAR files and Libraries to EJB project.

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

Select XPI Library –> Click Next

Select XPI Adapter Libraries from drop down –> Finish

Add “” file as External Jars for auditlog

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

Click on Apply –> Ok

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=“” xsi:noNamespaceSchemaLocation=“ejb-j2ee-engine_3_0.xsd”>








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

<display-name> –> Your display name

<ejb-name> –> Your ejb name

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

<ejb-jar xmlns:xsi=“” xmlns=“” xmlns:ejb=“”

xsi:schemaLocation=“” version=“3.0”>
















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=“” xsi:noNamespaceSchemaLocation=“application-j2ee-engine.xsd”>

<reference reference-type=“hard”>

<reference-target target-type=“service” provider-name=“”></reference-target>


<reference reference-type=“hard”>

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


<reference reference-type=“hard”>

<reference-target target-type=“service” provider-name=“”></reference-target>


<reference reference-type=“hard”>

<reference-target target-type=“interface” provider-name=“”></reference-target>


<reference reference-type=“hard”>

<reference-target target-type=“library” provider-name=“”></reference-target>


<reference reference-type=“hard”>

<reference-target target-type=“library” provider-name=“”></reference-target>


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


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


Deploy the EAR File:-

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

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


Select Your Server –> Click Next

Select EJB project –> Finish

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

Use Created Adapter Module In Sender Communication Channel.

Deployment to Higher Environments:-

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

Sample Adapter Module code:-


import javax.ejb.Stateless;











import jxl.Cell;

import jxl.Workbook;


* Session Bean implementation class ReadExcelFile



public class ReadExcelFile implements Module {

MessageKey amk = null;


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

String msgType = null;

String nameSpace = null;

Object obj = null;

Message msg = null;

try {

obj = imd.getPrincipalData();

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.”);




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 ;

Cell[] cellNames ;

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>”;


} catch (Exception e){

ModuleException me = new ModuleException(e);

throw me;


return xmldata.getBytes();




1 ) I am using below details for my development.

NWDS–> 7.3 SP06 PAT0009 and jdk1.8.0_131

SAP PO –> 7.5 SP07

EJB Module Version–> 3.0

2) If you will not find XPI Libraries in your NWDS version, then you can add below jar files , as external jars and any other jar files as per your requirements.

3)  Any Suggestion on this blog is always welcome.

4) We can create module and write Java code in different way, which you can find in different blogs.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo GAPP MOZART

      Hi 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 .




      Author's profile photo Bijayashree Banoj Brahma
      Bijayashree Banoj Brahma
      Blog Post Author

      Hi Jay,


      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".




      Author's profile photo Joel Langoyan
      Joel Langoyan

      Hi Bijayashree,

      May I know what EAR version is selected in relation to having EJB 3.0? I was told that it has to be related to some apparent reason. Thank you.