cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Configuration or Adapter module ?

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

rajasekhar_reddy14
Active Contributor
0 Kudos

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

GabrielSagaya
Active Contributor
0 Kudos

There are 3 ways available. But best option is using Dynamic Configuration.

https://wiki.sdn.sap.com/wiki/display/XI/Combining%20three%20different%20aspects%20of%20PI%20in%20on...

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi

I am seeking the code for that UDF and where to use it, since i am not sure of it

what i am looking at is if some one can please help me with the code for deriving the value AB from the File name IT_ABYYYYMMDD.345 ??

by using Dynamic Configuration steps

thanks

Rohan

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

>

> 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

Former Member
0 Kudos

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.