Receiver Determination Enhancement
By Balakrishna Reddy Annapareddy, YASH PI Competency Core Team, YASH Technologies
Pre-requisites
- Aware
of File-to-File Scenario using Standard Receiver Determination.
Standard Receiver determination:
In the standard receiver
determination, we used XPath to find out the Receivers in the Condition editor.
But, with the use of XPath, the functionalities are limited. Using XPath become
complex in case we have to get substring or do arithmetic operations etc.
Moreover, more than one node cannot be used in evaluating conditions.
All these features can be incorporated using the enhanced receiver
determination. The list of receivers can be determined dynamically at runtime,
using a message mapping.
This enhancement is
available from Support Package Stack 06 in PI 7.0 and also its equivalent
package in XI 3.0, which is Support Package Stack 15 onwards.
Enhanced Receiver Determination
You use an
enhanced receiver determination to have a mapping program determine the
receivers of the message dynamically at runtime. Instead of creating the
receivers in the receiver determination manually, you assign a mapping to the
receiver determination and this returns a list of receivers at runtime.
A typical
usage case is if you do not yet know the names of the receivers at configuration
time. In this case, you can define a mapping program, for example, which reads a
list of receivers from a table or from the payload of the message at runtime.
Need for Usage
When there is
a need of separating Applicants list into two, one for Major and other is for
Minor grouping by age limits (<=25, >25) and send lists to different
servers, then we can use this enhancement.
Graphical
Representation of Scenario
Steps
to be Maintained in Integration Repository
- Create
Data Type, Message Type and Message Interfaces for Source and Target
Systems.
- Create
Message Mapping between Source and Target Message types. One message mapping
is to map applicants age less than or equal to 25 and other is greater than
25 into target message type.
- Create
Interface Mapping between Source and Target Interfaces and use the message
mappings created above.
Additional
steps to be maintained in Integration Repository
Ø
Define Message
Mapping between Outbound Message Type and Standard Message Type “Receivers”
which is as Inbound message type and which is in the SAP BASIS --> http://sap.com/xi/XI/System
Ø
Define the
message mapping or mapping program that is to determine the receivers at
runtime. The screen shot of message Mapping is as shown below.
Ø
Create User Defined Function: User Defined function “countLevels” is to determine
number of receivers dynamically. The logic includes, If there is at least one
EMP having Age <= 25 then “A1Service” is added to the receivers list. In
similar manner if there is at least one EMP is having Age > 25 then
“A2Service” is added to the receivers list. This is accomplished using the
user defined function “countLevels” and the code is given below and is used
in the above Message Mapping.
- Define
Interface Mapping:
Ø
During the
definition of the interface mapping, you assign the abstract message interface ReceiverDetermination
as the target interface. The message interface ReceiverDetermination is
in the Integration Repository in the software component SAP BASIS
(namespace http://sap.com/xi/XI/System).
Ø
The message
interface uses the message type Receivers and the data type Receivers. The data
type Receivers describes a list of receivers.
Ø
Assign the
message mapping or mapping program to the interface mapping
Steps
to be maintained in Integration Directory
- Receiver
Determination:
While defining receiver determination, chose the “extended” option
button. Now we can select the Interface Mapping that we created in
Integration repository as shown below.
- Define
Interface Determinations, Sender and Receiver Agreements:
Ø
Interface
determinations can be created and the original interface mappings for
functionality can be chosen in these interface determinations.
The
necessary sender and receiver agreements are created.
Testing the
Scenario:
Case 1: In order to test the scenario, creating and
Applicants source file with one
employee age less than or equal to 25 and other one employee with age greater than 25.
The corresponding XML file to be placed in the source FTP
server is,
Source File:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:MT_EMP xmlns:ns0="http://yash.com/YH196/Rec_det_enh">
<RT_EMP>
<Name>Ravi</Name>
<Age>26</Age>
</RT_EMP>
<RT_EMP>
<Name>Rajesh</Name>
<Age>23</Age>
</RT_EMP>
</ns0:MT_EMP>
Output:
The output of the above file is, two target files on two target FTP Servers, one
with employees age <= 25 and other with employee age > 25. Here two
receivers are identified based on content of the payload.
FTP Server one:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:MT_Minor xmlns:ns0="http://yash.com/YH196/Rec_det_enh">
<RT_Minor>
<Name>Rajesh</Name>
<Age>23</Age>
</RT_Minor>
</ns0:MT_Minor>
FTP Server two:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:MT_Major xmlns:ns0="http://yash.com/YH196/Rec_det_enh">
<RT_Major>
<Name>Ravi</Name>
<Age>26</Age>
</RT_Major>
</ns0:MT_Major>
Case 2: Creating Applicants source file with two employee greater than 25.
The corresponding XML file to be placed in the source FTP
server is,
Source File:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:MT_EMP xmlns:ns0="http://yash.com/YH196/Rec_det_enh">
<RT_EMP>
<Name>Ravi</Name>
<Age>26</Age>
</RT_EMP>
<RT_EMP>
<Name>Raju</Name>
<Age>28</Age>
</RT_EMP>
</ns0:MT_EMP>
Output: The output of the above file is only one target file on FTP Server, with employee age > 25.
Here only one receiver is identified based on content of the payload.
FTP Server two:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:MT_Major xmlns:ns0="http://yash.com/YH196/Rec_det_enh">
<RT_Major>
<Name>Ravi</Name>
<Age>26</Age>
</RT_Major>
<RT_Major>
<Name>Raju</Name>
<Age>28</Age>
</RT_Major>
</ns0:MT_Major>
|