Quantcast
Channel: Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 741

How to persist custom data in SAP PI java table - Part 1

$
0
0

Introduction:


In this blog, we will have a look on how to store and retrieve data in SAP PI on java database in a custom table. And perform CRUD (Create, Read,Update and Delete) of records in the custom table. Also, I will show how to expose this functionality as a web service of that other local applications can easily access the data stored in the custom table and perform operations on the table (after authentication of course).

 

Why store data:

 

There can be many use cases to store data and retrieve data from SAP PI database tables, for example, to store key attributes of set of interfaces for administration or store business error details of set of interfaces for tracking purpose.

 

Why on java stack:

 

In dual stack PI systems, data persistence can be achieved in ABAP stack or Java stack. However, in single stack PI systems (SAP Process Orchestration),  data persistence can be achieved only in Java stack. Also, by persisting data on java stack in dual stack systems, interfaces can be PO ready.

 

Scenario:

 

Let’s assume that PI is interfacing ticketing tool, and we want to store all the tickets operations (like create, update, close etc.) made on all tickets through PI. Later we can check for any particular ticket what operations were made through PI.

 

Step 1: Create new table using Java dictionary.

 

Open NWDS and Select Window > Open Perspective > Other > Dictionary

1.a.jpg

Create new project. Select File > New > Other

1.b.jpg

Select Development Infrastructure > Development Component

1.c.jpg

Select Dictionary in Development Component Type and Click Next

1.d.jpg

Select MyComponents and Click Next

1.e.jpg

Provide development component name and click Finish

1.f.jpg

In Dictionary Explorer, Expand Dictionaries > Local Dictionary > Database Tables and right click and select Create Table

1.g.jpg


Give a prefix and suffix and select Finish

1.h.jpg

Add columns to the table and save

1.jpg

Right-click on project, Select Development Component > Build

1.j.jpg

Right-click on project, Select Development Component > Deploy

1.k.jpg

Verify the table created in SAP PI NWA > Troubleshooting > Database > Open SQL Data Browser

1.l.jpg

STEP 2: Create Entity Bean for the table created

 

Create new project in NWDS

2.a.jpeg

Select Development Infrastructure > Development Component and click Next

2.b.jpg

Select J2EE > EJB Module and click Next

2.c.jpg

Select MyComponents and Click Next

2.d.jpg

Provide Development Component Name and click Next

2.e.jpg

Select Java EE Version 5.0 and click Finish

2.f.jpg

Switch to Java EE perspective

2.g.jpg

In project explorer, Expand to ejbModule and Right-click on it and select New Class

2.h.jpg

Provide package name and Class name. Implement Serializable interface and click Finish

2.i.jpg

Add @Entity, @Table annotations to entity bean class. Add @Id annotation to all primary key fields. The attributes of the class should be exactly same as columns of the database table. The table name should be same as the table created in java dictionary

2.j.jpg

Since our primary key is composite (more than 1 column) we have to create composite key class and implement Serializable interface. Right click on EJB project and select New > Class and provide package name and class name and Implement Serializable interface

2.k.jpg

Add all the primary key fields in this key class

2.l.jpg

Generate getters and setters for the primary key class attributes

2.m.jpg

Select all attributes and click OK

2.n.jpg

The primary key class should look like this

2.o.jpg

Generate getters and setters method for entity bean class

2.p.JPG

Add default default serial version ID and IdClass annotation to the entity bean class

2.q.jpg

Add a NamedQuery to the entity bean. Provide a name to this named query so that we can call this query later. This query will return all the rows in the table

2.r.jpg

Next steps are available in part-2


Viewing all articles
Browse latest Browse all 741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>