on 07-28-2009 1:15 PM
Hi Experts
I need advice in the following scenarios where the interface is from a legacy file in the Source to an IDOC posting on the Target
a) The logic for the mapping is that if the File name is A then pass 123 and if the file name is B pass 456
for eg if it is IT_ABYYYYMMDD.350 then i have to pass 123 adn if it is IT_ABYYYYMMDD.350 then i have to pass 456
How is it possible to use the file name PI picks from the folder and use it in the mapping
It has to be done in the File Adapter ? do i have to write an Adapter module for it ??
how do i pass the file name in the mapping in IR ???
b) i need to derive data from the file name
for eg if the filename is IT_ABYYYYMMDD.345 and i have to derive the AB part from it and use it in the message mapping
since it is to be maped to a target field int he idoc .. how can I do that ?
Does it require a lot of coding ?
I have read about Dynamic Configuration but where and how to use it ??
can any one please help me with the steps to use or the code for deriving the value AB from the File name IT_ABYYYYMMDD.345 ??
thanks
Rohan
Hi Rajesh,
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
String a=conf.get(key);
var1 = a;
return var1;
add your logic this code and map this dynamic configuration UDF to the root of message.
do some and trail and error ot wil work fine.
no need to go for module.
cheers,
raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are 3 ways available. But best option is using Dynamic Configuration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dynamic configuration will serve your purpose .
Need to write a udf for fetching the filename using DynamicConfiguration
/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
check the above blog
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its simple after fetching the filename using code provied in the blog
then use the below if the file name is always constant
String ExtractedFilename = filename.substring(2,2) ;
which will provide the value of the filename i.e IT_ABYYYYMMDD.345 (returns AB)
and need some condition then you can put like this below
if (ExtractedFilename.equals("AB") )
return "A";
else if ( ExtractedFilename.equals("BA")
retun "B" ;
I hope you are on track now
Rajesh
Yes I am on track .. just two small questions ..in michal's blog
the UDF code says
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
so does the first argument in the braces = the file path ? as in the server path and location ?
and secondly
does this UDF require no input parameters cos in my mapping there is no source for this ... just that i need to derive this name and pass it to the target field so will this udf take any input argument when i am creating it in message mapping n PI 7.1?
or do I just create a UDF without a variable input and write this code and return as per your code and map it to the target ?
thanks
Rohan
>
> Yes I am on track .. just two small questions ..in michal's blog
> the UDF code says
>
> DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
>
> so does the first argument in the braces = the file path ? as in the server path and location ?
>
> and secondly
> does this UDF require no input parameters cos in my mapping there is no source for this ... just that i need to derive this name and pass it to the target field so will this udf take any input argument when i am creating it in message mapping n PI 7.1?
>
> or do I just create a UDF without a variable input and write this code and return as per your code and map it to the target ?
>
> thanks
> Rohan
first one is not path i.e file adapter property of SAP PI use as it is and need to pass some input to UDF just some variable which does nothing in the mapping and map the output to your target variable
HTH
Rajesh
Hi Rajesh,
if the file nameis not constant then? i am getting error with the code you provided. could you please help?
the 2 file names from diff locations are not constant - they are coming with the date n timestamps. so in the condition I have to give ABC_.txt then File1 else if XYZ.txt then File2.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.