cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Filename in Receiver cc for SFTP Adapter

Former Member
0 Kudos

Hi All,

I have a SFTP Receiver communication channel and I need to concatenate the "Plan number" to the filename (the last 5 digits of plan number). The interface is Proxy to File scenario and the source data type has "Plan Number" as field.  I searched and found some documents but couldn't able to move further as I am new to pi, can anybody explain me with screen shots or documents if possible.  Is there anyway to achieve this by without any coding because I used graphical mapping.

Eg: Filename = Payroll(+Plan Number last 5 character).txt

      Plan Number = '123456'.

The result should be --> Filename = Payroll23456.txt

Thanks in advance,

Vichu

Accepted Solutions (0)

Answers (5)

Answers (5)

juan_vasquez2
Active Participant
0 Kudos

Hello Vichu

Be sure to use the same namespace in udf and channel

In chanel remember to check Filename, and directory if you need

former_member184681
Active Contributor
0 Kudos

Hi,

One more thing. The UDFs above won't work correctly with SFTP adapter, until you change the Dynamic Configuration Key namespace from:

http://sap.com/xi/XI/System/File

to:

http://advantco.com/xi/XI/SFTP

Also, don't forget to enable use of Adapter-Specific Message Attributes in the receiver Communication Channel.

Regards,

Greg

Former Member
0 Kudos

Hello

I tried with Name space http://advantco.com/xi/XI/SFTP

still I was not successfull .I am getting MP: exception caught with cause javax.resource.ResourceException: 4:

Because I have given * as the filename in receiver SFTP channel.I have also enable ASMA attributes in receiver sftp channel.

Regards

Advit

anupam_ghosh2
Active Contributor
0 Kudos

Hi,

         you can try putting this UDF in the message mapping, the field  "Number" should be input to the mapping.

 

   public String getFileName(String Number,Container container)

{     

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

    DynamicConfigurationKey key = DynamicConfigurationKey.create("'http://advantco.com/xi/XI/SFTP","FileName");

    String s="payroll"+Number.substring(Number.length()-5)+".txt" ;  

    conf.put(key, s);   

    return " ";   

}   

 

Map this UDF to root element  or any dummy field in target XML.

In Receiver CC you need to set these

1. Receiver Comm Channel has ASMA , file name and "fail if ASMA missing" ticked.

2. in receiver communication channel -> File access parameters-> File name scheme -


> put any value say "*". This step is not compulsory.

3. In target directory of receiver CC put the name of the directory where you need the file to be formed.

Hope this solves your problem.

Hi Greg,

Thanks  for the helpful information . Updated the UDF.

Regards

Anupam

Former Member
0 Kudos

Eg: Filename = Payroll(+Plan Number last 5 character).txt

      Plan Number = '123456'.

Constant (Payroll) + paln number + substring(1,5)(if 6 digits only) ->  concat -> costant(.txt) -> concat -> udf-> target root node

refer below screen:

udf:

String a = "";

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

conf.put(key,a);

return "";

and in comm.channel, enable ASMA properties.

and regfer below thread:

http://wiki.sdn.sap.com/wiki/display/XI/Combining+three+different+aspects+of+PI+in+one+shot

gagandeep_batra
Active Contributor
0 Kudos

Hi Vichu

Following link might help u

http://www.saptechnical.com/Tips/XI/ASMA/Index.htm

Regards

Gagandeep