cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic FIle Name JAVA code

Former Member
0 Kudos

Hi Guys,

he requirement is to get File Name as XYZ.ddmmyyyy where as XYZ is constant.

To achive this I am writing UDF in message mapping with dynamic configuaration below is the code:

While I was trying to test end to end it is giving Runtime Exception in message mapping. please advice if this code needs correction?

I have mapped as Source Main Node .....> UDF > Target main node correct if it is wrong.

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

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

DateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");

Date date = new Date();

String filename = "XYZ" + dateFormat.format(date);

conf.put (key,filename);

return null;

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

anupam_ghosh2
Active Contributor
0 Kudos

Hi ,

Please try replacing this line


DateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");

with this line


java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("ddMMyyyy");

Hope this solves your problem.

regards

Anupam

Former Member
0 Kudos

Thanks Mark , it worked.

Thanks Anup...i had imported package so nt using this code format.

Closing the thread.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

While I was trying to test end to end it is giving Runtime Exception in message mapping. please advice if this code needs correction?

Anything that uses dynamic configuration cannot be tested at design time. You have to do end-to-end testing to see if it is working.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark, thanks for the reply.

I am geting the error while doing end to end testing only.

Please advice if code needs modification.

Thanks.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

It is possible that you are experiencing a mapping issue because of this line


return null; 

Use


return "";

instead.

Hope this helps,

Mark