cancel
Showing results for 
Search instead for 
Did you mean: 

call RFC and receive a java.lang.NullPointerException ...

former_member215107
Active Participant
0 Kudos

Hello,

I develop a RFC adaptative project.

When i execute the application, i obtain the following exception:

java.lang.NullPointerException

at com.sap.tc.webdynpro.modelimpl.dynamicrfc.AiiModelClass.createNewBaseTypeDescriptor(AiiModelClass.java:256)

at com.sap.tc.webdynpro.modelimpl.dynamicrfc.AiiModelClass.descriptor(AiiModelClass.java:222)

at com.sap.tut.wd.rodlist.model.Ztest_Rod_Input.<init>(Ztest_Rod_Input.java:51)

at com.sap.tut.wd.rodocomponent.RodoCust.wdDoInit(RodoCust.java:98)

at com.sap.tut.wd.rodocomponent.wdp.InternalRodoCust.wdDoInit(InternalRodoCust.java:130)

... 45 more

Ztest_Rod_Input is my adaptative RFC ...

This excception appears with the following code line:

> ztest_rod_Input input = new ztest_rod_Input();

I tried with a known BAPI in other project and i don't have this exception ...

Have you any suggestions ?

Thanks a lot,

Rodolphe.

Accepted Solutions (0)

Answers (8)

Answers (8)

former_member215107
Active Participant
0 Kudos

Hi Arch,

I execute your code and in the Input View i enter the following code:

> public void onActionSearch {

>String RFCelement = wdContext.currentContextElement().getLocalMatnr();

>wdThis.wdGetRodoCustController().wdGetContext().currentZtest_Rod_InputElement().setMatnr(RFCelement);

> wdThis.wdGetRodoCustController().executeZtest_Rod_Input();

When the user complete the input field and he execute the button Search ...

i obtain the following exception:

java.lang.NullPointerException

at com.sap.tut.wd.rodocomponent.InputRodView.onActionSearch(InputRodView.java:145)

at com.sap.tut.wd.rodocomponent.wdp.InternalInputRodView.wdInvokeEventHandler(InternalInputRodView.java:140)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)

at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)

... 26 more

Then when i look the SDL server log i see:

#1141 05/06/2008 14:06:04.607 [SAPEngine_Application_Thread[impl:3]_12] ERROR com.sap.lcrabapapi.ejb.AbapSLDRequestBean: Caught an Exception while processing a JCO request. Check the RFC engine for sanity and check your server logs and traces for more information.

Thrown:

java.lang.NullPointerException

Rodolphe

Former Member
0 Kudos

Try this

public void onActionSearch {

try

{

Ztest_Rod_Input input = new Ztest_Rod_Input();

wdContext.nodeZtest_Rod_Input().bind(input);

String RFCelement = wdContext.currentContextElement().getLocalMatnr();

wdThis.wdGetRodoCustController().wdGetContext().currentZtest_Rod_InputElement().setMatnr(RFCelement);

wdThis.wdGetRodoCustController().executeZtest_Rod_Input();

}

catch (Exception ex)

{

wdComponentAPI.getMessageManager().reportSuccess( ex.getLocalizedMessage());

}

Arch

former_member201361
Active Contributor
0 Kudos

hi,

Is there any othe Model classes available ? .

in the DoInit Method of the component Controller , after binding the input to the model node .

Just type input.set(ctrl+space);

are u able to get any model nodes to be initialised for the RFC Model , if Yes the do it with corresponding Objects .

please trace out the error logs from the server for information for this Exception.

Thanks and regards

Fazal B

former_member215107
Active Participant
0 Kudos

Hi Fistae,

I don't know this procedure.

The server ? it is the server where the SDL is running ?

How i proceed to execute the service registry ?

Hi Mikhil,

here my code ... it's simply:

>public void wdDoInit()

> {

> try

> {

> Ztest_Rod_Input input = new Ztest_Rod_Input();

> wdContext.nodeZtest_Rod_Input().bind(input);

> input.setMatnr(new String());

>

> }

> catch (Exception ex)

> {

> //ex.printStackTrace();

> wdComponentAPI.getMessageManager).reportSuccess( ex.getLocalizedMessage());

> }

HI Arch,

In the Input View where there is my inputField,

i go to the context. Then, i see:

Context

Ztest_Rod_Input

Matnr

In properties of Ztest_Rod_Input, i see cardinality 0..n

but i can't change the value ...

Thanks!

Rodolphe

Former Member
0 Kudos

Hi,

Try to compare your code with this article

Adaptive Web Service Model – Controller Coding

Explained

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/900bbf94-a7a8-2910-e298-a651b470...

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Rodolphe

I will suggest you that if you need to send one matnr value to your BAPI,

create a separate attribute say localMantr in your view context & bind that attribute with your input field.

Then in your code when you need to set it...

like input.setMatr("") that you had posted earlier

write this

input.setMatr(wdcontext.currentContextElement.getLocalMantr())

& execute your model.

Hoping that you are writting your model execution code in View itself.

Hope it helps

Arch

former_member201361
Active Contributor
0 Kudos

Hi,

I am not sure how to execute the RFC Module in the server .

But while Importing the Model u might have given the MetaData For the RFC Module , then only the Rfc Model Classes will be Visible In the Model tab.

and we cannot change the cardinality of the model node .

Thanks and Regards

Fazal B

former_member215107
Active Participant
0 Kudos

Hi Vinod V,

Thanks for your attention ...

It is strange, because when i add your try/catch code,

i have no error report and

I see my application but... with my InputField deactivated ....

Other ideas ?

Rodolphe.

former_member201361
Active Contributor
0 Kudos

hi,

just check whether the Rfc model is getting excecuted in the server.

Just go the servise registry in the server and execute ur model in the server and check whether it is excecuting correctly.

please check whether u have instantiated the model in the doinit method of the component Controller and bind the Model to the Model Nodes.

Thanks and Regards

Fazal

Former Member
0 Kudos

Rudolf,

Are you sure that you have done binding in right manner? I think that the cause of the NPE.

For enabling the input field, you have to create a context element of type string and bind that to the input UI element. and in init() method, you have to assign the input model context element to the local element.

say


wdContext.currentContextElement().setLocalElement(wdContext.current<yournode>InputElement().setFldName( "value"));

here LocalElement is the local context element and other is the model context element name.

Regards

Vinod V

Former Member
0 Kudos

Hi,

Please check the cardinality property of the node whose attribute you have binded with your input field.

It seems the input node has some attribute say mantr which you have binded to your input field.

Just let me know the cardinality of your input node...

If the value for this is 0...n , your input field will be disabled.

Arch

former_member215107
Active Participant
0 Kudos

Hi Arch,

I obtain the same error exception !

The exception is coming from THIS line:

> ztest_rod_Input input = new ztest_rod_Input();

Former Member
0 Kudos

Hi Rudolf,

Try this code in your application and report what is the error report showing:


try
{
 Ztest_Rod_Input input = new Ztest_Rod_Input(); 
 wdContext.nodeZtest_Rod_Input().bind(input);
}
catch (Exception ex)
{
wdComponentAPI.getMessageManager().reportSuccess( ex.getLocalizedMessage());
}

Regards

Vinod V

nikhil_bose
Active Contributor
0 Kudos

sol:

1) can you check/post codes before ztest_rod_Input input = new ztest_rod_Input();

Hope you creating this in wdDoInit() itself.

nikhiL

former_member215107
Active Participant
0 Kudos

Furthermode, i don t know how manage exception to obtain more inofrmation about my problem.

Former Member
0 Kudos

Hi,

Try to delete your input field from UI layout & set your input through code & then test if you recieve the same error.

input.setMantr(new String("11"));

Thanks,

Arch

former_member215107
Active Participant
0 Kudos

Hello,

When i put the following code:

>Ztest_Rod_Input input = new Ztest_Rod_Input();

>wdContext.nodeZtest_Rod_Input().bind(input);

>input.setMatnr(new String());

I got the exception "java.lang.NullPointerException "

But when i use the following code:

>try

>{

> Ztest_Rod_Input input = new Ztest_Rod_Input();

> wdContext.nodeZtest_Rod_Input().bind(input);

> input.setMatnr(new String());

>}

>catch (Exception ex)

>{

> ex.printStackTrace();

>}

I don't have the exception and the InputField that i have created is always deactivated...

I think that all is bound (object to model).

Any ideas?

Thanks

Rodolphe

Former Member
0 Kudos

Please post the piece of code for creating objects and setting input parameters.

Do check if you have bound the objet with the model node.

former_member201361
Active Contributor
0 Kudos

hi,

Here u are creating an Object and i dont think u will get the null pointer exception.when u re trying to invoke a method with a null object we will get this exception.

Use message manager to trace the actual place of Exception and out the codes in the try and catch block to catch the exception.

Thanks and regards

Fistae