Skip to Content
Author's profile photo Anand V D

How to persist custom data in SAP PI java table – Part 2

In part-1 we created table in java dictionary and deployed it on SAP PI server. And we also created Entity bean class for the table. Next we have to create EAR project for the EJB entity bean and create session bean to access entity bean and deploy it in the java server.

STEP 3: Create EAR project for the entity bean project.

Select File > New > Other


Select Development Infrastructure > Development Component and click Next


Select Java EE > Enterprise Application and click Next


Select MyComponents and click Next


Provide Development Component Name and click Next


Select the EJB project and click Finish


STEP 4: Create JDBC DataSource Alias

Open SAP PI NWA and navigate to Configuration > Infrastructure > Application Resource and create new JDBC DataSource Alias


Provide DataSource Alias Name and Select DataSource Name (In format SAP<SID>DB) and click save


STEP 5: Create DataSource Descriptor for EAR project

Right click the EAR project and select properties


Select Project Facets and check SAP Data Source Aliases Provider Module and click OK


In project explorer Expand the EAR project and navigate to META-INF and double click on data-source-aliases.xml


Select General tab and expand to Aliases > ${} and give the DataSource Alias name created in previous step and save it.


STEP 6: Create Session Bean to Access Entity Bean

For the session bean to access the entity bean, we must create persistence descriptor in EJB project to identify datasource

Right click on EJB project and select properties. Click on project Facets and check Java Persistence and click OK


In project explorer, Expand the EJB project > ejbModule > META-INF and open persistence.xml in XML editor and add jta-data-source to persistence-unit


Provide Persistence-unit name and enter the datasource alias name created previously


Right click on EJB project and Select New > Session Bean


Enter package, class name and check Local business interface and provide local interface name and click Finish


Add @Webservice and @PersistenceContext annotations in the session bean


Add methods to create, read, update and delete rows in the table in the session bean

Create method:


Read method:


Update method:


Delete method:


Get all rows in the table:


Add the methods to the local interface to expose the methods to local clients. Right click on method and Select EJB Methods > Add to Local Interfaces


Local interface should look this


Right click on EJB project and Select Development Component > Build


Right click on EAR project and Select Development Component > Deploy


Deployment should be successful without errors

STEP 7: Add authentication to the webserivce deployed

Open NWA in SAP PI and navigate to SOA > Application and Scenario Communication > Single service administration and search for the service deployed


Select Configuration tab below and select the endpoint and click edit button below it


Select Security tab and check  User ID/Password in HTTP authentication and save it


Next steps are covered in Part 3

Assigned Tags

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


      Hi Anand,


      Thanks for this detailed blog, very helpful.

      I tried all the steps and the web service deployment seems successful as confirmed by Basis team at PI NWA. But somehow, I am not able to see the web service 'Ticket' at NWA. Can you please guide what can be missing at this point?

      Also to say that the table created as per part 1 is reflecting in PI NWA.



      Shaily Chaudhary



      Author's profile photo Rajesh PS
      Rajesh PS


      Anand V D

      Your valuable thoughts/suggestions on this please. Many Thanks in advance!

      Author's profile photo Rajesh PS
      Rajesh PS

      Hello Anand V D,


      Nice blog anand. Thanks for sharing.


      I have a question is this updating to a singleton java instance and also will the stored values remain if a complete Java restart is done or any chance of causing  Cache issues.