Skip to Content
0

Dynamic filename SFTP receiver

Dec 02, 2016 at 02:56 PM

112

avatar image
Former Member

Hi Dear,

I create XML file in SFTP from SAP PI, but i need set the name : XXX_DATETIME.XML

The format of date is YYYYMMDD and time HHMMSS.

Several ways but nothing worked and I can only write a file that is named 'newfile' and is always overwritten, even with the flag not being marked. (UDF, mapping....)

Communication channel receiver using SAP PI 7.30.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Andrzej Filusz Dec 02, 2016 at 03:14 PM
0

Hi,

You have checked "Use Adapter Specific Message Attributes" option. But have you ever put any values there in your UDF or java mapping?

Here is an example from my UDF:

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters() .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);  
DynamicConfigurationKey fileNameKey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System","FileName"); 
if (conf != null) { 
   conf.put(fileNameKey, fileName); 
} else 
   throw new StreamTransformationException("your exception message!"); 
return " ";

Make sure you have used the same namespaces in your CC and java code.

Other option is to use "Add timestamp to filename" option (uncheck ASMA option in that case). But you have to decide which method you want to use.

Best regards,

Andrzej

Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Andrzej,

thanks for your response.

I try insert my UDF in function of my mapping, it's correct right?

0

Hi,

Yes, you can implement the logic of creating file names in your UDF in your mapping. Don't forget to invoke that UDF in your mapping (attach it to the root tag of your target message, for example).

Andrzej

1
Former Member
Andrzej Filusz

Andrzej,

Can you send a print of your UDF in MM ?

Do you using a module to convert in communication module?

0

1. Create an UDF with 1 parameter.

2. Write your code that creates file name in the format you need, for example:

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;

String datePattern = "yyyyMMddHHmmss";
TimeZone timeZone = TimeZone.getTimeZone("Europe/Warsaw");
Locale locale = new Locale("pl", "PL");
SimpleDateFormat dateFormatter = new SimpleDateFormat(datePattern, locale);
Calendar calDate = Calendar.getInstance(timeZone, locale);	
String fileName = dateFormatter.format(calDate.getTime());
// copy & paste here the code I wrote above :-)

Make sure you changed a timezone and locale to yours.

3. Click on the root tag of your target message and map it using your UDF.

If I have to convert the content of my message, then yes, I use a module.

BTW, the standard timestamp has the following format: yyyyMMdd-HHmmss-SSS. Are you sure that you can't use it? If it doesn't meet your requirements, then use UDF.

Andrzej

0