on 12-02-2016 2:56 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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. 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
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.