on 03-13-2007 4:11 PM
Hi all.
i have an XML that contain:
FILE:Sales.xml
Directory:c:\new folder
Name: Rodrigo
LastName: Suarez
Age: 21
I must map it to an another File to c:\new folder\Sales.xml
my problem is File and Directory is dinamic--> Directory an File can change
Any Idea How can i do it??
Thanks & Regads
Rodrigo
I think your question is not clear. If you are looking for dynamic directory in target then you can go with variable substitution. Please check this weblogs:
/people/sameer.shadab/blog/2005/09/23/an-interesting-usage-of-variable-substitution-in-xi
/people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i
/people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii
Also go through this thread:
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Satish
sorry my question is not clear.
again
i have an sender xml that contain name an directory where the reciever file must be.
the name an directory can be diferent deppendig the xml values.
for example.
first XML have:
FILE:Sales
DIRECTORY:c:\sales
second XML
FILE:customer
DIRECTORY:c:\customer
Thanks.
RP
Rodrigo,
Give like this in your receiver communication channel:
a) Enable Variable Substitution check box and create two variables.
b) var1 for directory and var2 for filename.
c) For var1 : payload:DIRECTORY,1
For var2 : payload:FILE,1
d) In Target Directory put %var1%
e) In File Name Scheme put %var2%
Then your issue should be solved.
---Satish
Receiver Adapter v2123 for Party '', Service 'XIT':
Configured at 2007-03-13 16:11:46 GMT-03:00
History:
- 2007-03-13 16:35:31 GMT-03:00: Message processing failed: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variables were not found in the message payload: file, dir
- 2007-03-13 16:35:30 GMT-03:00: Processing started
- 2007-03-13 16:35:30 GMT-03:00: Message processing failed: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variables were not found in the message payload: file, dir
- 2007-03-13 16:35:30 GMT-03:00: Processing started
- 2007-03-13 16:35:30 GMT-03:00: Message processing failed: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variables were not found in the message payload: file, dir
dir payload:Directory,1
file payload:file,1
Target XML
-
<?xml version="1.0" encoding="UTF-8"?>
<ns0:file_destino_MT xmlns:ns0="http://dynamicdir.com/xi/dynamicdir">
<Directory>/out</Directory>
<file>Sales.xml</file>
<Nombre>Rodrigo</Nombre>
<Apellido>Pertierra</Apellido>
</ns0:file_destino_MT>
Message was edited by:
Rodrigo Pertierra
Hi Rodrigo -
Should be:
dir payload:file_destino_MT,1,Directory,1
file payload:file_destino_MT,1,file,1
Example and explanation can be found here:
http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm
Regards,
Jin
Message was edited by:
Jin Shin
hi Satish.
it worked perfect. now i have another doubt.
is there any way that file name an directory does not appear in outbound File??
For example:
inbound XML:
-
<data>
<File>Sales</File>
<directory>c:\sales</directory>
<name>Rodrigo</name>
<LastName>Suarez</LastName>
</data>
I need this format.
Outbound File
-
<data>
<name>Rodrigo</name>
<LastName>Suarez</LastName>
</data>
At the moment, my outbound file have the following format
<data>
<File>Sales</File>
<directory>c:\sales</directory>
<name>Rodrigo</name>
<LastName>Suarez</LastName>
</data>
hope its clear
Thaks & Regards.
RP
hi Satish.
it worked perfect. now i have another doubt.
is there any way that file name an directory does not appear in outbound File??
For example:
inbound XML:
-
<data>
<File>Sales</File>
<directory>c:\sales</directory>
<name>Rodrigo</name>
<LastName>Suarez</LastName>
</data>
I need this format.
Outbound File
-
<data>
<name>Rodrigo</name>
<LastName>Suarez</LastName>
</data>
At the moment, my outbound file has the following format
<data>
<File>Sales</File>
<directory>c:\sales</directory>
<name>Rodrigo</name>
<LastName>Suarez</LastName>
</data>
hope its clear
Thaks & Regards.
RP
Message was edited by:
Rodrigo Pertierra
Message was edited by:
Rodrigo Pertierra
Message was edited by:
Rodrigo Pertierra
Hi Rodrigo,
<i>is there any way that file name an directory does not appear in outbound File</i> - No, if the outbound file is not having filenaem and dir, then you cant do variable substiution for filename and dir.....so then you cant dynamincalyy assign dir and filename.........then you will have to specify dir name and file name scheme explicitly in recever comm channel......
Thanks,
Rajeev Gupta
Variable substitution is used only for to substitute the existing the names of the field in the payload. If you dont have them at all in the payload then it is not possible.
So in your scenario it is not possible.
But in your requirement if you make some changes then it may be possible. Check this weblog which may be useful for it:
/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
---Satish
Hi Rodrigo -
You can use Adapter Specific Message Attributes (DynamicConfiguration) instead of variable substituion if you don't want the filename and directory to appear in your outbound file. This requires a little UDF coding in your mapping, but it's definitely possible.
Here's an example of the UDF code required for setting the filename:
http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm
Regards,
Jin
hi Jin
im trayin do a UDF enconding, but in dont know how to do that. I Created a User Function.
Imports: com.sap.aii.mapping.api.DynamicConfigurationKey;com.sap.aii.mapping.api.DynamicConfiguration;
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey keyF = DynamicConfigurationKey.create( URLFile, "FileName");
DynamicConfigurationKey keyD = DynamicConfigurationKey.create( URLFile, "Directory");
String valueOld = conf.get(keyF);
String valueOldD = conf.get(keyD);
if (valueOld != null) {
String valueNew = valueOld.replaceAll("Sender.xml",file);
conf.put(keyF, valueNew);
}
if (valueOldD != null) {
String valueNewD = valueOldD.replaceAll("/IN",dir);
conf.put(keyD, valueNewD);
}
return name;
URLFile: http://sap.com/xi/XI/System/File.
I dont know if the logic of function is right.
I made a Test in XI and the result was this:
Compilation of dynamic_directory_MM successful Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._dynamic_directory_MM_ method FileCOutput$[http://sap.com/xi/XI/System/File, Sales.xml, c:/, Rodrigo, com.sap.aii.mappingtool.tf3.rt.Context@9159fe] com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._dynamic_directory_MM_ method FileCOutput$[http://sap.com/xi/XI/System/File, Sales.xml, c:/, Rodrigo, com.sap.aii.mappingtool.tf3.rt.Context@9159fe]
....
...
...
Regards
RP
Hi Rodrigo -
While troubleshooting, just try for FileName first. This code is all you need:
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
conf.put(key, newFileName);
return "";
- No need for the DynamicConfiguration classes in the <i>Imports</i> statement as you had before.
- The variable <i>newFileName</i> above is the input for file name from your source payload.
- As you can see, nothing is returned since the file name is just being set in the DynamicConfiguration part of the message header.
- This function can be applied anywhere where it would be executed once (e.g. root of the target message).
- You cannot test this locally in IR (will get exceptions) - have to do a real end-to-end test.
Finally, in your receiver file adapter, make sure that you check the option "Use Adapter Specific Message Attributes" and that "File Name" is selected. This will look for the <i>FileName</i> value that you set and use it for the target file name.
Once this works, you can adjust to account for your directory as well.
Regards,
Jin
when put URL:http://sap.com/xi/XI/System/File, explorer take me to URL:
http://www.sap.com/platform/netweaver/index.epx
:S :S
In my receiver comunication channel, whats parameter i must difine for Target Directory and File Name Scheme??
should i define a a variable sustitution: message:XXX??
Rgds
RP
The URL (http://sap.com/xi/XI/System/File) is just used as an attribute namespace - it's not a URL in the normal sense (e.g. not to be used in a browser).
<i>>>>In my receiver comunication channel, whats parameter i must difine for Target Directory and File Name Scheme??</i>
It doesn't matter if you're using ASMA (adapter specific message attributes). The ASMA attribute used will override whatever you have configured in the channel.
<i>>>>should i define a a variable sustitution: message:XXX??</i>
In this case, you don't need to use variable substitution at all.
Regards,
Jin
It Workedddddddddddddd!!!!! :D:D:D
Now only rest save output file in a directory i get from de inbound XML!!!!!
I select Directory in Adapter-Specific Message Autributes fom inbound and outbound Channel, but it does not work. in my function code add this lines:
//get the Key of Directory
DynamicConfigurationKey keyD = DynamicConfigurationKey.create( URLFile, "Directory");
//replace value of Attribute Directory.
conf.put(keyD,dir);
Any Idea??
Rgds
RP
Hi,
It is better to use dynamic folder choose in receiver side , see below code
String newfilename="";
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
// Get Sourcefilename
String oldfilename=conf.get(key);
//extract first 3 chars of source filename
newfilename=oldfilename.substring(0,2);
//get the date
java.text.SimpleDateFormat dateformat = new java.text.SimpleDateFormat( "yyyyMMdd" );
dateformat.format( new java.util.Date() );
//append sourcedateL
newfilename=newfilenamedateformat"L";
// determine if prod/ dev / qa
map = container.getTransformationParameters();
senderService = (String) map.get("SenderService");
if(senderServcie.equald("Prod"){
newfilename=newfilename+"P";
}
// change to new file name
conf.put(key, newfilename+".tmp");
Also see the below links
/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
Regards
Chilla..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Chilla.
your post was very useful.
this my function.
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
//obtengo la Key del FileName
DynamicConfigurationKey keyF = DynamicConfigurationKey.create( URLFile, "FileName");
//get the Key of Directory atribute
DynamicConfigurationKey keyD = DynamicConfigurationKey.create( URLFile, "Directory");
// replace the value of FileName for the value from inbound XML (Sales.xml)
conf.put(keyF,file);
// replace the value of Directory for the value from inbound XML (c:/)
conf.put(keyD,dir);
return name;
nevertheless, function still return an error:
Compilation of dynamic_directory_MM successful Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._dynamic_directory_MM_ method FileCOutput$[http://sap.com/xi/XI/System/File, Sales.xml, c:/, Rodrigo, com.sap.aii.mappingtool.tf3.rt.Context@16c120b] com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._dynamic_directory_MM_ method FileCOutput$[http://sap.com/xi/XI/System/File, Sales.xml, c:/, Rodrigo, com.sap.aii.mappingtool.tf3.rt.Context@16c120b]
...
...
What can i do??
Regards!
RP
Message was edited by:
Rodrigo Pertierra
Rodrigo,
Is it a question of depending on the incoming value then it can be one of n receiver directories and file names?
So for example if calue is 1 then directory 1 is used with the relevant file name and if it is 2 then directory 2 is used with the relevant file name?
What I am getting at is if you know of all the directories and filenames that could be used in advanced then the work around could be to simply have n number of reciever file comm channels and simple have conditions on the recievers...
Obviously for this you would need a list of possible directories and filenames...
Otherwise I think the others are right... with variable substitution you have to have the value there otherwise it cant be used...
Although having said that I do remember someone mentioning a while ago about putting the value in the header... i dont know if this could work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rodrigo,
if you have dynamic file name you can use wild charaters such "*" and "_" to pick up the file.
i think we dont have option about dynamic directories . you can use adanced file selection option then you can specify the different directoies and files name which are fixed but you will know what directories you have in our landscape you configure all directoies path here.it is just work around
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.