SAP PI NWBPM from the scratch
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
- Install suitable NWDS version from SAP market place.
- 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.
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).
You’ll see list of versions and download suitable version.
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
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.
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
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.
Similarly create Message Types
From Sender to PI
From PI to NWBPM
From NWBPM to PI
From PI to Receiver
Mapping is not required.
- Create business component for sender
- Create business component for receiver
- 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.
- Sender to NWBPM
- NWBPM to Receiver
So data flow will be like following:
Create business component BS_DataMerge for sender and receiver. Import sender and receiver service interfaces referring above flow diagrams.
Create Business system for BPM_DataMerge. Import service interfaces required by referring above flow diagrams.
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
2. Channel from PI to NWBPM
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
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
We use SOAP communication with XI3.0 message protocol.
2. Channel from PI to receiver.
Let’s use File adapter to receive merged file.
Create ICO for first flow (Sender–>PI–>NWBPM). This ICO sends data from Sender to NWBPM.
Create ICO for second flow (NWBPM–>PI–>Receiver)
We are done with IR and ID configuration.
Development inside NWBPM
Open NWDS and create a new Product.
Uncheck all, click on New Software Component. Give it a name in CAPITALS, and click finish.
Now a new product will be created in left pane
Expand tree, right click on Process and create a new process
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.
Similarly import MI_Merged_OB too.
Now go to workspace. Initially you’ll get this in workspace.
Delete the line in between and select start and configure properties.
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.
Create a new trigger and give it a name. Then, select our inbound service interfaceMI_File1_File2_IB.
Now go to output mapping
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.
Now, just drag corresponding data type to our work area. In this case it is DT_SenderFileStructure
Change its name to something relevant.
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).
By mapping both root nodes all child nodes will also be mapped.
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.
Again select start and go to properties–>output mapping. Here map field ID to this data object.
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.
In this step we collect remaining 4 messages.In this step we do 2 things:
- Set correlation ID condition
- 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.
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.
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.
Type string-equal( or drag it from ‘Rules and Functions’. Then drag ID from local/MT_SenderFileStrcuture.
Now drag correlationID from Global as below.
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++.
Drag another data object, rename it to count and change its data type to integer.
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.
Now go to properties of ‘count++’ and increment count like below.
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.
Now go to exclusive choice properties.
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.
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.
Select the corresponding service interface and click on service reference.
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.
Now go to input mapping and map Material_Number to receiver structure’s Material_Number.
Now, connect the flow to end and complete flow looks like below.
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.
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
In Processes and Tasks tab, select our process and click on it. Another window will be opened.
Now go to History tab and select Advanced to see the BPM log.
Once you select Advanced, BPM log will be displayed.
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.
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.
Finally all 5 messages will be appended and final merged payload will look like below
Please post in comments section if you have any queries.