cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic file name in receiver SFTP channel

Former Member
0 Kudos

Hi,

I have scenario of SFTP - SFTP.

Receiver wants the file name dynamically like X0000+part of source file name_ datestamp.

I have message mapping, Can someone suggest me how to achive this through UDF of through channel parameters in SFTP receiver channel.

Thanks in Advance

Thanks

Sarada

Accepted Solutions (0)

Answers (4)

Answers (4)

Bhavani_Baisani
Participant
0 Kudos
monikandan_p
Active Participant
0 Kudos

Hi Sarada,

       You can achieve this dynamic file name in meesage mapping by below udf.

1. Create a UDF

2. Set Dynamic configuration checked in Receiver adapter.

UDF:

public String getFileName(Container container, var1 String, var2 String) throws StreamTransformationException{

//For getting filename

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

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

String filename = var1 + var2;

conf.put(key, filename);

Best Regards,

Monikandan.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Sarada,

The format for DynamicConfiguration:


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

DynamicConfigurationKey key = DynamicConfigurationKey.create(String namespace, String TechnicalName);

conf.put(key, String TechnicalNameValue);

Depending on the Adapter Specific message attributes, the namespaces differ e.g for File it is http://sap.com/xi/XI/System/File, for SFTP it is usually

http://sap.com/xi/XI/System/SFTP , same is true with the FileName, the TechnicalName is usually "FileName". The TechnicalNameValue is the value of the FileName in your case X0000+partOfSourceFileName_ datestamp.

Hope this helps,

Mark

hariprasad24
Explorer
0 Kudos

Hi Sarada,

"Nikhil" reply helps you from the link provided by Mr.Hareesh Gampa.

I suggest you, don't go through entire thread which makes you confuse. 

************************************

you can do this in message mapping.

1. Create a UDF

2. Set Dynamic configuration checked in Receiver adapter.

UDF will accept two parameters


public String getFileName(Container container, var1 String, var2 String) throws StreamTransformationException{

//For getting filename

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

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

String filename = var1 + var2;

conf.put(key, filename);

return FileName;}

- Nikhil

**********************************************

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Hari,

The reason I used a namespace and a technical name is because it is entirely vendor-specific. For example, we are using Aedaptive SFTP so the namespace would be "http://aedaptive.com/xi" and the technical name for the FileName would be "fileName". Best would be to consult the vendor SFTP documentation for the namespace and technical name.

Hope this helps,

Mark

hariprasad24
Explorer
0 Kudos

Thank you Mark.

It makes sense.

Hari

former_member184720
Active Contributor
0 Kudos

You can write a simple UDF..

Please refer to below link for UDF code..