cancel
Showing results for 
Search instead for 
Did you mean: 

Null pointer Exception while using DynamicConfiguration

Former Member
0 Kudos

Hi All,

I am working on a proxy to jdbc scenario in which we have to throw validation errors to NWPM(Net Weaver Process Monitor Tool)

I am following the below steps,

step 1 - In message mapping a UDF is created to catch errors and store them in a variable using dynamic configuration

step 2 - writing abap mapping for handling this thrown exception and im reading the dynamic configuration in the abap class and raising exception.

I was using DynamicConfiguration odject as "Conf"

and DynamicConfigurationKey object as "Key".

I wrote below code for Dynamic cofiguration in UDF.

String error="";

error=error+ "missing required field"

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

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

DynamicConfigurationKey keyHeader1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/Error", "ERROR");

conf.put(keyHeader1, error);

but while i am trying to test the data in message mapping it will show one error at the time of runtime .

"Runtime exception when processing target-field mapping /ns0:MT_DB2_SourcePlant/Record/SourcePlant; root message: Exception:java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.put(com.sap.aii.mapping.api.DynamicConfigurationKey, java.lang.String) of an object loaded from local variable .

I am using addInfo method inAbstractTrace class.Using this i find error at conf.put(keyHeader1, error);

before the conf.put(keyHeader1, error);its working correctly.

Could you please help in finding the solution for getting currect error message from ABAP class?

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor

> String error="";

> error=error+ "missing required field"

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

add this statement here:

if (conf != null) {

> //DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Error", "ERROR");

> DynamicConfigurationKey keyHeader1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/Error", "ERROR");

>

> conf.put(keyHeader1, error);

}

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Experts,

My scenario is IDoc to CSV where the part of target folder varies according to a field value in input payload to PI, I have written UDF with type as "Single Values"

public String DynDir(String inp, Container container) throws StreamTransformationException

{

String str = "/Dump/testop/"+inp+"/" ;

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

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

conf.put(key1,str);

return str ;

}

Where the Target folder should be determined according to the input value say /Dump/testop/BG for input WERKS value in IDoc BG001.

When I execute the code it throws an error:

Where DynDir is UDF name and I mapped the input value and UDF to root node of Target structure.

But I get an error code like:

"Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.put(com.sap.aii.mapping.api.DynamicConfigurationKey, java.lang.String) of a null object loaded from a local variable at slot 4] in class com.sap.xi.tf._MM_XYZ_ method DynDir[DIR2, com.sap.aii.mappingtool.tf7.rt.Context@efc623]
com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.put(com.sap.aii.mapping.api.DynamicConfigurationKey, java.lang.String) of a null object loaded from a local variable at slot 4] in class com.sap.xi.tf._MM_XYZ_ method DynDir[DIR2, com.sap.aii.mappingtool.tf7.rt.Context@efc623]  .
Please help to solve this, I can even do this by Variable substitution but I need to achieve this by UDF.  

Thanks,

Nithin.

manoj_khavatkopp
Active Contributor
0 Kudos

Nitin,

FYI : Dynamic configuration can't be tested in ESR(mapping) directly run the interface from rwb or end to end.

Br,

Manoj

Former Member
0 Kudos

Hi Manoj,

Yes you are right, when I checked end to end it's working now.

Thanks,Nithin.

Former Member
0 Kudos

Hi

Thank you for reply