Hi Felipe,
Kindly use this udf for dynamic file name.
public
class
DynamicFileName_JavaMapping
extends
AbstractTransformation
{
public
void
transform(TransformationInput transformationInput, TransformationOutput transformationOutput)
throws
StreamTransformationException
{
try
{
InputStream inputstream = transformationInput.getInputPayload().getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
Map mapParameters = (Map) transformationInput.getInputHeader().getAll();
// a) Set Output File name
mapParameters.put(DynamicConfigurationKey.create(
"http://sap.com/xi/XI/Dynamic"
,
StreamTransformationConstants.DYNAMIC_CONFIGURATION),
""
);
DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
"http://sap.com/xi/XI/System/File"
,
"FileName"
);
//Depending on your requirement edit this logic. Here, NewDynamicName + CurrentDate will be output file name.
DateFormat dateFormat =
new
SimpleDateFormat(
"yyyyMMdd"
);
conf.put(key, (
"NewDynamicName_"
+ dateFormat.format(
new
Date())) +
".pdf"
);
// b) Just copy Input file content to Output file content
byte
[] b =
new
byte
[inputstream.available()];
inputstream.read(b);
outputstream.write(b);
}
catch
(Exception exception)
{
getTrace().addDebugMessage(exception.getMessage());
throw
new
StreamTransformationException(exception.toString());
}
}
}
Best Regards,
Monikandan