cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple receivers using Variable Substitution

sherin_jose4
Participant
0 Kudos

Hi,

I have a File to File scenario with no mapping involved. A file from a single source has to be sent to one of the 4 receiver locations based on the source file name. How do i achieve this using Variable Substitution or any other method ?

I do not prefer to create 4 receiver communication channels for receiving the data, since it will be complicated when i need to add more receivers.

Your help would be appreciated !

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi,

When you have no mapping involved, then Variable Substitution is a good choice. It will let you achieve your goal with a single receiver communication channel, as you require. See a nice example of Variable Substitution configuration here: http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=272171407

Let me know if you had further detailed questions.

Hope this helps,

Greg

sherin_jose4
Participant
0 Kudos

Hi,

Thanks for the replies.

I am currently doing the below configs,

Target Directory : Interface/XI/%DIR%

File Name Scheme : SampleFile_%Filename%.txt

In Variable Substitution,

Variable Name                                           Reference

Filename                                                   IN,AU,UK,DE

DIR                                                           DBA,SAR,EKY,QUR

Please tell me if i am doing something wrong, i don't use IR objects in my scenario since i don't have any mapping.

former_member184681
Active Contributor
0 Kudos

Hi,

Your config of Variable Substitution doesn't seem correct. You do not provide the list of possible values as the Reference, but rather something similar to an XPath expression that defines from which field of the XML payload the respective value should be taken. See "Defining Variables for Elements in the XML Schema of the Payload" here: http://help.sap.com/saphelp_nwpi71/helpdata/en/44/6a316af5a23672e10000000a114a6b/content.htm

It gives more details about how to build those expressions.

Hope this helps,

Greg

sherin_jose4
Participant
0 Kudos

I'm  a bit confused on my particular scenario. I do not see, how i can read a particular file name and send that to the appropriate directory.

For example, i get a file called Name1.txt and it has to be sent to DIR1 and if i get a file called Name2.txt, it has to be sent to DIR2. how do i achieve this and what should be the correct entries in my communication channel.

former_member184681
Active Contributor
0 Kudos

OK, a little more explanation, here it goes The Variable Substitution enables using particular fields of message payload, or some message "general" attributes, to create the target file name. So you define a variable, that will be supplied with a value automatically during message processing (based on the expression defined) and you use this variable in the file name scheme or directory name.

I guess what you also need to understand is, that you can only assign a value that appears somewhere in the message payload. For instance, if you want to put one of the values: IN,AU,UK,DE, into the file name, this value has to be present in the payload. Now for some example payload:

<root>

   <child>

      <field1>UK</field1>

       ...

   </child>

</root>

Your expressions looks like that: payload:root,1,child,1,field1,1. At runtime, PI will examine the target XML message payload, searching for a value root/child/filed1, take that value and place it in the file name, as you defined: SampleFile_%Filename%.txt.

Hope this helps,

Greg

Former Member
0 Kudos

Hi,

I have one more suggestion, in this case (file to file pass through scenario where no  mapping is involved) u can also opt for adapter module (a few lines code will help u)

chk my wiki:

http://wiki.sdn.sap.com/wiki/display/Snippets/Dynamic+file+name+in+a+File+to+File+pass+through+scena...

this wiki shows how to set file name dynamically but u can also use the same for setting the directory (re adjust this code)

Thanks

Amit Srivastava

Message was edited by: Amit Srivastava

Answers (3)

Answers (3)

Former Member
0 Kudos
markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can achieve this using the run OS script after message processing e.g dump in just a single folder and then let the OS script move the files to its respective directory based on the filename.

Hope this helps,

Mark

former_member184681
Active Contributor
0 Kudos

Hi Mark,

This is also a solution to consider, but I would recommend it only if respective values are not available in the payload, for the following reasons:

  1. In case renaming & moving the file fails, PI will still show the message as successful.
  2. Writing an OS command is much more difficult than using Variable Substitution.
  3. OS command is only possible with File transport protocol (impossible with FTP, as far as I know) - not sure if this applies here.

Regards,

Greg

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Grzegorz,

Yup, true, what you said is correct. My suggestion was based on the statement made by Sherin earlier

"I do not see, how i can read a particular file name and send that to the appropriate directory." So, I just assumed that he is not passing the filename as a field in the payload.

As always, thanks for your inputs

Regards,

Mark

sherin_jose4
Participant
0 Kudos

Thanks all for your valuable suggestions. There was a small change in our requirement and it became a simple file to file scenario to only one location.

Former Member
0 Kudos