cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException for one element in the Model.

Former Member
0 Kudos

Hello Experts,

I executed an RFC from my WebDynpro project. I believe it gets the correct values in the model, but when I try to bind the node to a screen element, the exception occurs.

The node in question is of the type BigDecimal. I'm not sure if this is the cause but when I try to display other nodes from the same level in the node hierarchy, it displays the String nodes correctly.

Here is the exception I got:

java.lang.NullPointerException

    at com.sap.aii.proxy.framework.core.JcoBaseTypeData.getElementValueAsBigDecimal(JcoBaseTypeData.java:648)
    at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.getAttributeValueAsBigDecimal(DynamicRFCModelClass.java:259)
    at com.kaisa.mwci.models.getnetworks.Zps_Fm_Get_Network_Num_Output.getEx_Plcstt(Zps_Fm_Get_Network_Num_Output.java:179)
    at com.kaisa.mwci.wd.wdp.IPublicMainComp$INetworksElement.wdGetObject(IPublicMainComp.java:1156)
    at com.sap.tc.webdynpro.progmodel.context.MappedNodeElement.wdGetObject(MappedNodeElement.java:351)

Thanks in advance. The members of this forum has always been helpful.

Cheers,

Alfonso

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello Experts,

First of all, let me thank all of you for sharing you ideas.

Pravesh, I already checked the values of the Node/Nodes in question and they all have at least one element.

Anagha, How do I do that? If you mean if I execute the RFC in R/3, it works perfectly.

Satish, The field in question is already defined as a BigInteger in the Model Dictionary.

Yogesh, I'm not sure what you mean. The error occurs only if I choose to display this specific field. The program works fine when I display the other fields in the same node. I don't know why this is the only field that causes trouble.

Again, thank you all.

Cheers,

Alfonso

Former Member
0 Kudos

Hi Paul,

Look for the same line of code in your java code for the view which is giving the UI element error.

This means an object is not getting created.

The simplest way to remove this error is to put a Exception handler around your same java code. In the catch clause, put in the same code that you want to get executed.

Former Member
0 Kudos

Check what is the value returned for this Big decimal field when you execute RFC in backend.

former_member185086
Active Contributor
0 Kudos

Hi

Problem is due to BigDecimal Field of return by rfc Before binding this field to UI element do the proper conversion , Because this field work fine ABAP but have problem in java , I ll suggest to avoid direct binding of the ui element from model node create separate Value node for this.

String str1 = "456.42";
        String str2 = "-356.32";
        
        // To convert s String to a BigDecimal
        BigDecimal bigDecimal1 = new BigDecimal(str1); 

        // To convert s String to a BigDecimal
        BigDecimal bigDecimal2 = new BigDecimal(str2);

Best Regards

Satish Kumar

pravesh_verma
Active Contributor
0 Kudos

Hello Alfonso,

The error in your code is in JAVA file: Zps_Fm_Get_Network_Num_Output.java. Probably you can check the size of the getnetworks.Zps_Fm_Get_Network_Num_Output node. I guess this node size is zero and when you have tried to getthe value of getEx_Plcstt from this node it has given you this null pointer exception.

Please try this:


if(wdContext.nodeZps_Fm_Get_Network_Num_Output().size<0){
wdContext.nodeZps_Fm_Get_Network_Num_Output().createAndAddElement();
}

I hope this is helps you!!

Thanks and Regards

Pravesh