cancel
Showing results for 
Search instead for 
Did you mean: 

File to file. Create target file

Former Member
0 Kudos

HI guys,

I'm working in PI 7.1 and I have to create a target file that contains the names of source files. Is this possible?

For example:

Source Directory:

Archive_1.txt

Archive_2.txt

Archive_3.txt


Content of target file:

Archive_1.txt, Archive_2.txt, Archive_3.txt


Regards

Martin


Accepted Solutions (1)

Accepted Solutions (1)

former_member186851
Active Contributor
0 Kudos

Hello Martin,

It is possible.

Use the below UDF in mapping to get the input file name and map it to the target fields

try { 

String filename    = ""; 

String timestamp = ""; 

DynamicConfiguration conf1 = (DynamicConfiguration) container 

    .getTransformationParameters() 

    .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); 

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


filename = conf1.get(key1); 

return filename; 

catch(Exception e) 

     String exception = e.toString(); 

      return exception; 

}

You can use append mode in the receiver file adapter to write all the filenames in the single file

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Raghuraman/Ramkumar,

I implement their suggestions, that is, use a UDF that obtains the source file name.

The Receiver channel is configured as follows:

The XML I get the channel receiver is:

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

<ns0:MT_FILE xmlns:ns0="http://test.com/pi/test/">

     <LINE>Archive_1.txt</LINE>

</ns0:MT_FILE>

And the target file is created but empty.

I need help to set the destination channel for my flat file containing the file name "Archive_1.txt".

Regards.

Martin

Former Member
0 Kudos

can you make sure to enable the Adapter Specific setting (ASMA) - file name in your sender and receiver channels.

former_member186851
Active Contributor
0 Kudos

As Ram suggested check whether ASMA with filename

Former Member
0 Kudos
Former Member
0 Kudos

Hi Ramkumar,

That's not what I need.

I need the contents of the target file, containing the names of the source files.



Content of target file (fe: TargetFile.txt):

"Archive_1.txt, Archive_2.txt, Archive_3.txt"


Regards.

Martin

Former Member
0 Kudos

ok you can use dynamic configuration ASMA in mapping and get the source file name and map it to target field.

<MT_Target>

    <data> source file name </data>

</MT-Target>

in the channel you need to use File content conversion to take only data values.. .and mode should be "append"..

or you can use Java mapping and create a file.

Sample Code - Dynamic Configuration in Java and ABAP Mapping - Process Integration - SCN Wiki