SAP
PI FILE TO FILE SCENARIO
In SAP PI
file to File scenario, we transfer a file from source system to a target system.
Once the components are built in SAP PI, we can transfer a file in SAP PI
system by creating objects in the Enterprise Service Builder.
Here in this
example our source structure and target structure are both XML File.
DESIGNING OF OBJECTS
Go to SAP PI Tools Page. Then click on Enterprise
Service Builder under ESR.
The first
object that we create is a namespace. Enter the namespace in the form of URL. The
namespace that we used in this example is: urn:ppg.com:Training:NV3
CREATING DATA TYPE
Once the
Namespace is saved and activated, create a data type. The source data type that
we used in this example is: DT_ShoppingCart.
The target
data type that we used in this example is: DT_MYShopping.
Form the
input message structure by entering the names of elements and sub elements as
required. Define the type and occurrence. Occurrence defines how many times
that element will appear in the file. You can select minimum occurrence and
maximum occurrence value.
CREATING MESSAGE TYPE
After
creation of data type, create a message type of that data type. The message
type for the source structure is: MT_ShoppingCart
and for the target structure is MT_MYShopping.
Define the
Data Types that you will be using for the respective Message Types. Drag the
Data Type from the left bar to the Data Type option under Message Type (
). Then click on
Save button.
The source
message type is shown below:
The target
message type is shown below:
If the
structure of the input file and output file is same, you can use one Data Type
and one Message Type only. If the structure is different, you have to create
two data types and message types for inbound and outbound. In this example we
are using the same structure for both input and output file.
CREATING SERVICE INTERFACE
Create
Service Interface for the Source XML Structure. The outbound service interface
that we used in this example is: SI_ShoppingCart_Asyn_Out.
Give the category of the interface to be outbound and mode to be
asynchronous. Drag the Message Type from the left bar to the Request option
under Messages bar.
The inbound
service interface that we used in this example is: SI_MYShopping_Asyn_In. Give the category of the interface to be inbound
and mode to be asynchronous.
Outbound Service Interface:
Inbound Service Interface:
CREATING MESSAGE MAPPING
Now, create
Message Mapping for the source and target structure. The message mapping that
we used in this example is: MM_ShoppingCart_To_MyShoppingCart.
Define source and target message by dragging the message type under Message in
the source and target.
Map the
messages of the target structure to the corresponding messages of the source
structure as per given requirements.
The rules
and requirements of mapping is given in the mapping sheet below:
CREATING OPERATION MAPPING
Create
Operation Mapping. The operation mapping that we used in this example is: OM_ShoppingCart_Asyn_Out_MyShopping_Asyn_In.
Enter Source
and Target Operation by dragging the Outbound Service Interface from the left
pane to Source Operation and Inbound Service Interface from the left pane to
the Target Operation.
Unit Test Data:
Input test
payload:
Expected
Output:
CONFIGURATION OF
OBJECTS
Go to Integration Builder under Integration Directory on SAP
PI Tools Home Page to configure a scenario. Create communication channel for both sender and receiver. The
sender and receiver channels that we created here are FTP_SND_ShoppingCart_Shopping_Cart_CC
and FTP_RCV_ShoppingCart_Shopping_Cart_CC respectively.
For sender
communication channel go to Adapter and click the available adapter types. Here
we use File adapter. The Adapter Type is selected as Sender as the type of
communication channel is a sender channel. Enter the file name and path of the
file.
For receiver
communication channel go to Adapter and click the available adapter types. Here
also we use File adapter. The Adapter Type is selected as Receiver as the type
of communication channel is a receiver channel.
Create integrated configuration.
In the
Inbound Processing tab, select the communication channel as created for the
Sender.
In the
Receiver tab, select the communication.
In the
Receiver Interfaces tab, select Operation Mapping. Click Search and select the
Operation Mapping as shown in the following screenshot. Operation Mapping will
be created the same way as in the previous steps.
In the Outbound
Processing tab and select the Receiver Communication channel.
hi nitish
ReplyDeleteif source file name and target file shoud be same then kind of activity to possible ?
and dynamic in file to file scenario