on 06-23-2010 11:00 AM
hi All,
I am trying to use both Dirctory Name and File Name Dynamically in File Adapter.
My UDF is like this:
String Name ="";
Name = fileName;
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
conf.put(key, Name);
int x = fileName.indexOf(".");
int y = fileName.length();
Name = fileName.substring(0, x);
Name = fileName + ".pgp";
DynamicConfigurationKey keyDir = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "Directory");
conf.put(keyDir, Name);
But at runtime only File Name is available Dynamically. Directory Name is not coming. Is there anything wrong in the above code, or is it that it is not possible to set both the names dynamically.
Thanks,
Mayank
Hi
Goto Sxmb_Moni and check in the Adapter properties for Dynamic configuration and you will see that both File Name and Directory is coming provided you checked both the check box in your adapter.
Now problem with your directory is ...you are not using it anywhere in your code
See you have appended your extension .pgp to the File name:
Name = fileName.substring(0, x);
Name = fileName + ".pgp";
but for directory where are you sending the info:
DynamicConfigurationKey keyDir = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "Directory");
conf.put(keyDir, Name);
See if you want to append directory name with file name then apply string function APPEND else if you want to map it to the target node as it is then write the code
result.addValue("Name");
And becuse you've put keyDir into Name it will give you the output as directory in the target node.
Hope it help you..
Naina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
change your code as
String Name ="";
Name = fileName;
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
int x = fileName.indexOf(".");
int y = fileName.length();
Name = fileName.substring(0, x);
Name = fileName + ".pgp";
//here change the file name after assigning value to Name variable.
conf.put(key, Name);
DynamicConfigurationKey keyDir = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "Directory");
conf.put(keyDir, Name);
also in your code you are not changing the directory name anywhere.that is why may it is not dynamically getting created.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi fatima,
Actually logic is to have different Directory and File Name, in directory name i have to remove characters after '.', so my code is like what i mentioned in the initial post.
It looks like that this code is not working:
DynamicConfigurationKey keyDir = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "Directory");
conf.put(keyDir, Name);
Also if i have two different DynamicConfigurationKey's , how can i retreive same in the channel.
Thanks.
in sxmb_moni, open the message got to the response node -> SOAP Header -> Dynamic Configuration
Do you see the values set by you here? if so the code is working fine.
Then the only reason might be that you have not enabled the ASMA for file name and directory in CC.
Maybe recreate the CC or do a complete cache refresh
check your logic in this part of the code
int x = fileName.indexOf(".");
int y = fileName.length();
Name = fileName.substring(0, x);
Name = fileName + ".pgp";
can you modify the code to;
String Name ="";
Name = fileName;
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
conf.put(key, Name);
String DName = "Test Directory";
DynamicConfigurationKey keyDir = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "Directory");
conf.put(keyDir, DName);
see if the code is working now.
if it is then u will have to revisit the logic of creating the directory name in your code.
What exactly is your requirement in terms of filename and directory?
hi Shabharish,
I got the issue and there was sone cache issue, it's working now ,, Thanks.
Now i want to use it in Variable substitution, so how can i retreive the same,
Before i was using single DC value, so i added below in the module tab :
AF_Modules/DynamicConfigurationBean
key.0 write http://sap.com/xi/XI/System/File Filename
value.0 message.interface
http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot
File Name that i am setting in UDF will be used in Adapter Module only, so i don't have to use same in ASMA in channel. But i want to retrieve Directory name to use it in Variable Substitution.
How can i do so?
I tried using:
keyDir.0 write http://sap.com/xi/XI/System/File Directory
value.0 message.interface
But Directory Name created in the FTP location is as the Service interface name.
Thanks,
Mayank
Edited by: Mayank Gupta on Jun 24, 2010 6:19 AM
hi Shailesh and Abid,
ASMA property for both(Directory and file name) is selected in the channel, any other suggesions.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Make sure if you have checked the Adapter Specific Message attribute for Directory as well.
Shailesh
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 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.