on 07-29-2008 11:43 AM
Hello Experts,
I have a unique situation. In my file to file scenario, the source file name is of the format XYZ_yymmddHHMM.dat. there is field in the target file which has to filled with the date that is there in the file name of the source file (yymmdd). How can this be achieved? Normally we do the other way round using vaiable substitution where we can name a file depending on the value in any of the target field structure.
Please help.
Regards,
Yash
for the UDF use the context as Value.
public String GetFileName(Container container)
{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String ourSourceFileName = conf.get(key);
return ourSourceFileName;
}
output of the above UDF
GetFileName->substring(4,10)->targetfield
Enable adapter specific attributes in the sender file communication channel and check file name.
Edited by: malini balasubramaniam on Jul 29, 2008 1:02 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Yash,
You can access Adapter specific parameter (Like File Name)
and can perform the changes you wish to.
Use following code to extract file name
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
u201Chttp://sap.com/xi/XI/System/Fileu201D,
u201CFileNameu201D);
String valueOld = conf.get(key);
if (valueOld != null) {
}
In if (valueOld != null) part of above code you can perform subString Operation and output of this UDF can be given to any target field.
Reward Points IF Helpful
Thanks
Sunil Singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
please prepare the udf with the following code.
i mean, dynamic configuration concept.
where u get the file name, then use substring function to capture date from right side.
//write your code here
// getFileName User Defined Function
// function to create name of output file
String filename;
filename = strFile;
try {
// initialize DynamicConfiguration for create file with given name
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
//create file with the specified name
conf.put(key, filename);
} catch (Exception ex) {
}
return filename;
warm regards
mahesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mahesh,
I have not used Dynamic configuration before and hence i am new to it. Can you please explain me in complete details as what i have to do, what would be the exact code of the udf, where will i use the UDF and what will be the input to it? If somehow i can get the souce file name in the mapping i can use substring to get the timestamp.
Thanks,
Yash
Hi,
you have set adapter speific attributes in file sender adapter.
like file name..etc details
then you can see file name in soap header message(in sxmb_moni).
from saop header, the UDF get the file name and written to one of the variable in the target.
for more information, please check help documenttation.
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/frameset.htm
warm regards
mahesh.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.