Quantcast
Channel: SCN : Document List - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 571

SAP PI NWBPM from the scratch

$
0
0

Netweaver BPM


How different it is from CCBPM


Unlike traditional CCBPM, NWBPM is not a part of PI anymore. But it is now a separate module of Netweaver. And that is why we call it Netweaver BPM. We can develop a CCBPM from Integration repository. But coming to NWBPM, we do all development part in Netweaver Developer Studioand then deploy it to server. We can use CCBPMs only in dual stack PI. Coming to Single stack PI systems, we use NWBPMs.

To begin with NWBPMs, we need to


  1. Install suitable NWDS version from SAP market place.
  2. Install java JDK 6u31 or higher.



Installing Netweaver Developer Studio (NWDS)


To install suitable NWDS version, go to Administration and there we can see software build information. Check service pack of your current PI system.

3.png


Usually we select NWDS SP version which is five times greater than PI service pack. For instance if PI SP is 7, we install NWDS SP 12.To install NWDS visit following link (SAP Market Place).

https://nwds.sap.com/swdc/downloads/updates/netweaver/nwds/nw/731/doc/auto_com.sap.netweaver.developerstudio.distribution.complete.extsoa_versions.html


You’ll see list of versions and download suitable version.

2.png


You will get a zipped folder and inside that NWDS exe file will be there. You can directly use it without any installation.Besides NWDS, install suitable java JDK version 6 update 31 or higher.Next thing we need to do is set up link between NWDS and our PI system.



Establishing linkup between NWDS and PI


Open NWDS and go to Window-->Preferences-->PI Tools Configuration-->Connections1.png


Here give PI system URL. URL will be in following syntax.http://<hostName>:<portNumber>Default port number will be 80Now go to Window-->Preferences-->SAP AS Java and click on Add button.


Here give PI host name, instance number, add to default and click ok.1.png


Now NWDS is linked up with PI system. If it asks for credentials or connection details anywhere while development give same details like above.Now following is simple Data merge scenario based on message count using NWBPM.



Sample BPM Requirement


NWBPM should collect similar kind of messages (with same structure) and when message count reaches 5, it should merge all 5 in to one single XML and send it to receiver.

 

Design in Integration repository

Data types and message types

Create some simple structure for sender files like below.1.png

Here ID will be used for correlation. I have created only single field Material_Number for simplification.Now create receiver file structure. Since we want to merge multiple sender files in to one, create0-unbounded occurrence for ‘Material_Number’ in receiver structure.1.png

Similarly create Message Types


Service interfaces

While creating service interfaces, interface pattern should be Stateless (XI3.0 compatible)1.png


From Sender to PI

1.png


From PI to NWBPM

1.png


From NWBPM to PI

1.png


From PI to Receiver

1.png


Mapping is not required.


ID configuration

  1. Create business component for sender
  2. Create business component for receiver
  3. Create business component for NWBPM


For simplicity, I will be creating single business component BS_DataMerge and will be using it as sender component and receiver component.


For NWBPM, I will be creating business component BPM_DataMergeWhenever we use BPM there will be 2 flows. Instead of directly sending data from sender to receiver, we send it to NWBPM and then NWBPM does it functionality and sends data to receiver.


  1. Sender to NWBPM
  2. NWBPM to Receiver


So data flow will be like following:

1.png

1.png

 

Business Components

Create business component BS_DataMerge for sender and receiver. Import sender and receiver service interfaces referring above flow diagrams.

1.png

 

Create Business system for BPM_DataMerge. Import service interfaces required by referring above flow diagrams.

1.png

Communication channels

Referring above flow diagrams create communication channels.


Channels in first flow (sender-->PI-->NWBPM)

1. Channel from sender to NWBPM

     Let's use file adapter

1.png    

 

2. Channel from PI to NWBPM

1.png

From PI to NWBPM, we use SOAP communication with XI 3.0 message protocol. And following will be target URL to NWBPM. For username and password, use any PI user ID which have access to send data to


http://<hostname>:<port>/MessagingSystem/receive/JPR/XI

 

Note: We can use this channel as common channel in all interfaces involving NWBPM

 

Channels in second flow (NWBPM-->PI-->Receiver)

1. Channel from NWBPM  to PI

1.png            

We use SOAP communication with XI3.0 message protocol.

 

2. Channel from PI to receiver.

      Let’s use File adapter to receive merged file.

1.png

 


ICOs


Create ICO for first flow(Sender-->PI-->NWBPM). This ICO sends data from Sender to NWBPM.

1.png

 

Create ICO for second flow (NWBPM-->PI-->Receiver)

1.png

We are done with IR and ID configuration.



Development inside NWBPM

 

Open NWDS and create a new Product.

1.png

 

Uncheck all, click on New Software Component. Give it a name in CAPITALS, and click finish.

1.png

Now a new product will be created in left pane

1.png


Expand tree, right click on Process and create a new process

1.png

1.png

 

 

Now import all required service interfaces which comes in to BPM (MI_SenderFiles_IB) and which goes out of BPM (MI_MergedFile_OB) in following way.

1.png


Similarly import MI_Merged_OB too.

1.png


Now go to workspace. Initially you’ll get this in workspace.

1.png


Delete the line in between and select start and configure properties.

1.png


We have to create an event trigger which will trigger start step. In our case we give inbound service interface i.e. in first flow as below, we give service interface from PI to NWBPM.


          Sender-->PI--> MI_SenderFiles_IB-->NWBPM

1.png


Create a new trigger and give it a name. Then, select our inbound service interfaceMI_File1_File2_IB.

1.png

1.png


Now go to output mapping

1.png


Here you see the receiving file structure (message type). This means when this start step is triggered, data will be coming in to NWBPM in this structure.


As soon as we get data in this start step, we should store this data in some intermediate object. We call them data objects.


We should use an intermediate data object which is having same structure. It will be available in data types in left pane. This is nothing but data type for this message type.


So basically, when you import a service interface, corresponding Message types and Data types will also be imported.

1.png

 

Now, just drag corresponding data type to our work area. In this case it is DT_SenderFileStructure

1.png


Change its name to something relevant.

1.png


Prefix it with DO. DO indicates Data Object.


Now we have our intermediate data object ready. Now we can use this data object to store the received data in start step.


Select start, go to propertiesàoutput mapping. You will see our data object in right pane. Map like following (Just do a drag and drop for root nodes).

1.png


By mapping both root nodes all child nodes will also be mapped.

1.png


So now as soon as start step receives some data, it will be stored in this data object.


Now drag another Data Object (of type string) like below and rename it to correlationID. We store value in field ID in this data object so we can use it in next step for correlation.

1.png


Again select start and go to properties-->output mapping. Here map field ID to this data object.

1.png


As per our requirement, NWBPM should collect messages and when message count reaches 5, it should merge all 5 in one single XML and send it to receiver.


So here, with Start step, we have collected the first message which comes to NWBPM. 4 more messages are remaining. We collect them in next step.


In next step we drag an intermediate message to workspace as below.

1.png


In this step we collect remaining 4 messages.In this step we do 2 things:


  1. Set correlation ID condition
  2. Set loop to receive remaining 4 messages


We will collect messages based on correlation ID. Here we use data object correlationID which holds value of field ID for correlating the arriving messages.


First give some relevant name to intermediate step and set event trigger as below. Event trigger will be same as start step since both are receiving same kind of messages.

1.png


Go to output mapping. Here we append the upcoming message to previously arrived message in start step.


Since we are concerned about appending only material numbers and we do not need ID in receiver XML, I am only mapping Material_Number and giving assignment as Append.

1.png


Now go to next step Correlation Condition


Here we give correlation condition. In this case technically ID value in first message should match ID value in upcoming 4 messages. We have already stored ID value of first message in data object ‘correlationID’. Hence condition should be ‘correlationID’ value should match ID value in upcoming messages.

1.png


Type string-equal(  or drag it from ‘Rules and Functions’. Then drag ID from local/MT_SenderFileStrcuture.


Now drag correlationID from Global as below.

1.png


We have set correlation condition. Now we should create a loop for this step so that it would iterate 4 times and receives 4 messages.


I am taking a count variable to count no. of iterations. Drag Mapping and rename it to Count++.

1.png


Drag another data object, rename it to count and change its data type to integer.

1.png

1.png

We should initiate this count value somewhere in above step. Hence go to start step properties-->operation mapping and double click count in right side pane.


Just type ‘0’ in text box and click ok. This will be initialized to 0 in start step.

1.png


Now go to properties of ‘count++’ and increment count like below.

1.png


Now we need to repeat the loop 4 times.


Drag an exclusive choice (create 2 branches) and one automated activity to work area. In exclusive choice, one branch should go back to intermediate message nextmsg and one should go to automated activity sendMergedFile like below.

1.png


Now go to exclusive choice properties.

1.png


Give relevant names to branches. In this case I have given name getNextMessage to left branch which goes up and name send to below branch which goes to automated activity.


Make getNextMessage branch default branch by checking text box. Now select send branch and click edit. Give below condition in expression editor.

1.png


Now go to sendMergedFile automated activity. In this step we send the merged XML file to receiver. Technically we will be calling the corresponding ICO through service interface. Following is the technical procedure how we do it.



Go to properties-->interface.

1.png

Select the corresponding service interface and click on service reference.

1.png

Select type as XI and in sender Component, type our BPM business component name. In our case, it is BPM_DataMerge. Save it and close the window.

1.png

Now go to input mapping and map Material_Number to receiver structure’s Material_Number.

1.png

Now, connect the flow to end and complete flow looks like below.

1.png


That’s it. We are done with NWBPM development part. We should deploy it to our PI server now.

Just do right-click on our product and click on deploy.

1.png



Testing and Monitoring NWBPMs


As per requirement BPM should merge 5 files and send it to receiver.

So from test tab, trigger first message. As per our BPM design, first message should initiate the BPM i.e. first message is trigger for initiating BPM.


After triggering it, let’s see if BPM is initiated or not.


Go to Configuration and Administration-->Processes and Tasks-->Process Repository


Select our BPM component in the list

1.png


In Processes and Tasks tab, select our process and click on it. Another window will be opened.

1.png


Now go to History tab and select Advanced to see the BPM log.

1.png


Once you select Advanced, BPM log will be displayed.

1.png


Log says, BPM process is initiated. So, our first message has initiated the BPM process.


Now trigger the next message and see this log again.

1.png

 

Now log says Intermediate message event‘next msg’ has consumed next message. So now BPM is waiting for 3 more messages to complete the process.


Now trigger 3 more messages and check the log again.

1.png

 

Finally all 5 messages will be appended and final merged payload will look like below

1.png

Please post in comments section if you have any queries.


Viewing all articles
Browse latest Browse all 571

Trending Articles



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