cancel
Showing results for 
Search instead for 
Did you mean: 

Processing the filename in the payload

Former Member
0 Kudos

Hi,

I am getting the filename in the payload, I want to read that file.

How do I achieve this..

Regards,

Varun

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member192295
Active Contributor
0 Kudos

Hi,

File name is getting as a value, we can read through UDF or use Variable substitution mechanism to read file name from payload.

Former Member
0 Kudos

Hi,

For Example if we want to get the Input file name & Directory Details into Target message.

Ex:

I/P File name is :::::231004.xml Ftp Serve Path : //xideveloper/Test_XI/PO

O/P File name can be :::Any thing

Input File : 231004.xml

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_TEST_AGCO xmlns:ns0="http://tafe.test.com">

<Header>

<NAME>giri</NAME>

</Header>

</ns0:MT_TEST_AGCO>

Output File : Out.xml

Here in this output we are able to get the Filename & Directory Info in the FileName_1 Field.

<?xml version="1.0" encoding="UTF-8" ?>

- <ns0:MT_target xmlns:ns0="http://test.com">

- <Header>

<Name_1>giri</Name_1>

<File_Name_1>231004.xml //xideveloper/Test_XI/PO/</File_Name_1>

</Header>

</ns0:MT_target>

You should capture the Source File name & Directory Info into Target Message.

1) Write One UDF & Map Like Constant(u201Cu201D)---UDF----FileName_1

2) In Advanced mode check the check box Set Adapter-Specific Attributes

3) Check the ASMA Parameters in Sender Adapter Alone

4) No need to check the check box ASMA in the receiver side

UDF Code:

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

//for getting filename

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

//for getting directory

DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");

/similarly for getting filetype, filesize you need to specify in the above code instead of filename or directory/

String FileName = conf.get(key1);

String Directory = conf.get(key2);

String Cat = FileName+ " "+Directory;

//return FileName;

//return Directory;

return Cat;

Regards

Seshagiri

former_member189441
Active Participant
0 Kudos

Hi,

you want to read the filename or File contents?

can you explain exactly what's your requirment

prateek
Active Contributor
0 Kudos

Do u mean that u will be receiving two files?

First file will contain the filename in payload based on which u have to pick second file.

This doesn't seems to be possible with available standard functionalities. The only option could be creating ur own adapter module dynamically editing the sender filename.

Regards,

Prateek