cancel
Showing results for 
Search instead for 
Did you mean: 

File Name in UDF

Former Member
0 Kudos

Hi,

I am writing one UDF in which based on the input value, the target file name has to be changed. For example if the input value is "1120" then the target file name should be "1120.txt" and if the input value is null then ".txt" should be the file name. My code is working fine if the input contains value and if the input value is null, then it is giving run time exception "Base run time error in message mapping". My requirement is the empty file ".txt" has to be created. Can you please help me to handle the situation.

Thanks,

Naresh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

PI uses traget field mapping. That is if the source is not present or empty nothing is done. Maybe you can change your mapping with if-else. If source value is not present, assign ".txt" as constant, else call your UDF.

Regards,

Volker

Former Member
0 Kudos

I used if - else condition.. but same error. I dont know why?

Former Member
0 Kudos

Hi!

I think we need your UDF coding here ...

What do the others say?

Regards,

Volker

Former Member
0 Kudos

are u checking the response of RFC and then determining the filename? If you can paste the UDF, it will be great to identify the issue.

Former Member
0 Kudos

fileName = endResult + ".txt"; // this endResult is the RFC output

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

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

objDynConf.put(objKey1, fileName);

container.setParameter(StreamTransformationConstants.DYNAMIC_CONFIGURATION, objDynConf);

Former Member
0 Kudos

Hi!

The complete UDF would be of interest. How is the RFC part looking like?

Regards,

Volker

SudhirT
Active Contributor
0 Kudos

Hi,

why dont u use the rfc udf function output concatenated with constant .txt with concat function in text category.

i dont understand y u r using this dynamic configuration code?

Answers (5)

Answers (5)

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

HI Naresh

Why dont you use variable substituion based on the paylaod field value. What the need to set Dynamic configuration.

Whats the exact requirement

Check this

Thanks

Gaurav

Former Member
0 Kudos

Sorry experts,

I can not use variable substitution.. here i am giving my error and code.. Please help me out..

Runtime exception during processing target field mapping /ns0:MT_InternalOrder/Record/E_IbuyEntity. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._MM_INF00083_02_SAP_to_IBUY_ method Dynamic$[114S.txt, com.sap.aii.mappingtool.tf3.rt.Context@735c735c] com.sap.aii.mappingtool.tf3.MessageMappingException: Runtime exception during processing target field mapping /ns0:MT_InternalOrder/Record/E_IbuyEntity. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._MM_INF00083_02_SAP_to_IBUY_ method Dynamic$[114S.txt, com.sap.aii.mappingtool.tf3.rt.Context@735c735c]

MappingTrace importanttrace;

importanttrace = container.getTrace();

importanttrace.addWarning(a);

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

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

objDynConf.put(objKey1, a);

container.setParameter(StreamTransformationConstants.DYNAMIC_CONFIGURATION, objDynConf);

return (a);

Thanks,

Naresh

Former Member
0 Kudos

Did you check adapter specific message attributes in Receiver File Adapter...

If not, then select adapter specific message attributes-...select File name, File Type

Then it should work

SudhirT
Active Contributor
0 Kudos

Hi,

Still dint get you(Y cant you use Direct mapping suggested), Anyways if you are using this Dynamic Configuration function, It will not work in Mapping Editor test(It will always give you error as it works runtime). for this you need to run your end to end scenario.

Thanks!

Former Member
0 Kudos

Thank you very much experts, my code is working fine now..

pedro_baroni3
Active Contributor
0 Kudos

Test if your variable "endResult" is initial:


if (endResult.trim().equals("")) {
...
}

Former Member
0 Kudos

paste ur UDF logic here.. else check for null condition in the code. I think it is throwing NPE

Former Member
0 Kudos

Hello Naresh,

You can put a simple logical check in UDF for emoty value and assign it some default name.

Else if you want to use graphical mapping, use string function Compare, to check if this is empty, then assign it default name else proceed.

Thanks

-Kulwant

Former Member
0 Kudos

I am very sorry guys, I forgot to tell one thing here, the file name is the string coming from the RFC. I am calling the RFC inside my UDF. I can not use graphical mapping.

Edited by: naresh j on Nov 13, 2008 5:43 PM