cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException at ISimpleTypeModifiable

Former Member
0 Kudos

Hi all,

I want to implement EVS to my inputfield and i have to fill data in this at runtime .

I have a MainView with Inputfiled(Werks)I want to impelemt EVS to this field

The code i wrote in my mainView(wdDoInit())is


 IWDAttributeInfo attributeinfo=wdContext.getNodeInfo().getAttribute(IPrivateSearchView.IZ_Matrls_For_Plant_InputElement.WERKS);
     wdThis.wdGetFlightCustController().executePO(attributeinfo);

the method executePO(attributeinfo) in my Custom Controller is


public void executePO( com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo valueSet )
  {
    //@@begin executePO()
	    ISimpleTypeModifiable WerksType=valueSet.getModifiableSimpleType();
		IModifiableSimpleValueSet EVSvalueSet=WerksType.getSVServices().getModifiableSimpleValueSet();
	try
	   {
		   wdContext.currentZ_Matrls_For_Plant_InputElement().modelObject().execute();
		   wdContext.nodeOutput().invalidate();
		   int n=wdContext.nodeMatrl_List().size();
		   for(int i=0;i<n;i++)
		   {
		   	IMatrl_ListElement item=wdContext.nodeMatrl_List().getMatrl_ListElementAt(i);
			EVSvalueSet.put(item.getWerks(),item.getWerks());
		   }
	   }
	   catch(Exception e)
	   {
		   e.printStackTrace();
    	
	   }
    //@@end
  }

<b>

I am gettting NullPointerException at ISimpleTypeModifiable WerksType=valueSet.getModifiableSimpleType();

</b>

can any one tell me why it is showing null pointer exception

Regards

Padma

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member193726
Active Participant
0 Kudos

Hi Padma,

Try to create an attribute called PurOrd in your view. Attach this attribute to your inputfield. Now create the IWDAttributeInfo for the PurOrd and proceed with it.

This should populate the data. When the data gets populated and when you select one among the list, set the selected value to PurchaseOrder(attribute of BAPI_PO_GETITEMS_INPUT).

Hope this helps.

Regards,

Rekha Malavathu

Former Member
0 Kudos

Hi Rekha,

Is it enough to create PurOrd in myView or shall i have to create PurOrd in my custController and map them i.e both view and custController???

How to set the selected value to PurchaseOrder(attribute of BAPI_PO_GETITEMS_INPUT).

Regards

Padma

Former Member
0 Kudos

Hi,

Use the below code

in ur custom contoller,creare an attribute "Werks"

In your view you create a similar attribute "werks"

map the view context with the custom controller context.

then use the below code in custom contorller and call this method from the view when required.

public void executePO()

{

//@@begin executePO()

IWDAttributeInfo attributeinfo=wdContext.getNodeInfo().getAttribute("werks");

ISimpleTypeModifiable WerksType=attributeinfo.getModifiableSimpleType();

IModifiableSimpleValueSet EVSvalueSet=WerksType.getSVServices().getModifiableSimpleValueSet();

try

{

wdContext.currentZ_Matrls_For_Plant_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

int n=wdContext.nodeMatrl_List().size();

for(int i=0;i<n;i++)

{

IMatrl_ListElement item=wdContext.nodeMatrl_List().getMatrl_ListElementAt(i);

EVSvalueSet.put(item.getWerks(),item.getWerks());

}

}

catch(Exception e)

{

e.printStackTrace();

}

//@@end

}

AM

Former Member
0 Kudos

Hi,

My context is BAPI_PO_GETITEMS_INPUT(RootNode)

OUTPUT(SubNode)

MATRL_LIST(SubNode)

po_item,shipping etc(Attributes)

PurchaseOrder(attribute of BAPI_PO_GETITEMS_INPUT)

In My project PurchaseOrder is inputfiled.Now i want to implement EVS to this field.

the code i used in my custController is



IWDAttributeInfo attributeinfo=wdContext.nodeBAPI_PO_GETITEMS_INPUT().getNodeInfo().getAttribute("Purchaseorder");
	ISimpleTypeModifiable WerksType=attributeinfo.getModifiableSimpleType();
	IModifiableSimpleValueSet EVSvalueSet=WerksType.getSVServices().getModifiableSimpleValueSet();
	executeBapi_Po_GetItems_Input( );
	int n=wdContext.nodeBAPI_PO_GETITEMS_INPUT().size();
	for(int i=0;i<n;i++)
	{
		IBAPI_PO_GETITEMS_INPUTElement item=wdContext.nodeBAPI_PO_GETITEMS_INPUT().getBAPI_PO_GETITEMS_INPUTElementAt(i);
		EVSvalueSet.put(item.getPurchaseorder(),item.getPurchaseorder());
	}

The problem is Data is not getting populated in that EVS.It is showing Empty

Regards

Padma

former_member193726
Active Participant
0 Kudos

Hi Padma,

I know why you are getting that error!!!

The attribute that you are trying to modify in your view is mapped to the similar attribute in your component controller/custom controller.

Please remove the mapping and try executing the code.

It should work.

Regards,

Rekha Malavathu

Former Member
0 Kudos

Hi Padma,

Ur attributeInfo is null bcos of that u r getting null pointer exception :-).

print the attributeInfo before calling executePo method.

it seems Ur node is IZ_Matrls_For_Plant_Input but u r taking it from context directly.

U r using IWDAttributeInfo attributeinfo=wdContext.getNodeInfo().getAttribute(IPrivateSearchView.IZ_Matrls_For_Plant_InputElement.WERKS);

i think u should use wdContext.nodeIZ_Matrls_For_Plant_Input.getNodeInfo().getAttribute("attributename");

regards

Sumit

Message was edited by:

Sumit Malhotra

Former Member
0 Kudos

HI Padma,

Instead of

IWDAttributeInfo attributeinfo=wdContext.getNodeInfo().getAttribute(IPrivateSearchView.IZ_Matrls_For_Plant_InputElement.WERKS);

Use

<b>IWDAttributeInfo attributeinfo=wdContext.nodeIZ_Matrls_For_Plant_Input().getNodeInfo().getAttribute(IPrivateSearchView.IZ_Matrls_For_Plant_InputElement.WERKS);</b>

Note:

The program is confusing the variable names.. The variable u declared <b>valueSet</b> is AttributeInfo of a context variable, so try to give some other name for better understandability of program

Regards

Fahad Hamsa

Former Member
0 Kudos

Hi,

I modified as ypu mentioned

Now i am getting a new error as given below

Error stacktrace:

com.sap.tc.webdynpro.progmodel.context.ContextException: AttributeInfo(SearchView.Z_Matrls_For_Plant_Input.Werks): must not modify the datatype of a mapped attribute

at com.sap.tc.webdynpro.progmodel.context.AttributeInfo.getModifiableSimpleType(AttributeInfo.java:323)

at com.sap.tc.webdynpro.tutorial.SearchView.wdDoInit(SearchView.java:101)

at com.sap.tc.webdynpro.tutorial.wdp.InternalSearchView.wdDoInit(InternalSearchView.java:124)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)

Former Member
0 Kudos

Hi Padma,

U r trying to get the simpleType in view,(ur search view). Do it in controller.I think SearchView.java:101 is ur line where u r getting the modifiableSimpleType.

regards

Sumit

Former Member
0 Kudos

Hi Sumit,

Do u mean in Custom Controller.I did it in SeatchViewController.

Shall i do in wdDoInit() method of custom Controller.

But how to get IPrivateSearchView.IZ_Matrls_For_Plant_InputElement.WERKS value in Custom Controller

Former Member
0 Kudos

Hi Padma,

The reason is very simple. U cant map a Simple type to controller.

If u remove the mapping, it wont give u any error.

But, since u mapped the model nodes to View, u need tat mapping.

So, the possible solution is, create a context variable in the context(Say <b>ValHelp</b> ) and bind it to InputField.Remove attributeInfo parameter from executePO() method

Call the RFC to load the values in context node.

ie.

try

{

wdContext.currentZ_Matrls_For_Plant_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

}

catch(Exception e)

{

e.printStackTrace();

}

Then get the values from model node to this context variable <b>ValHelp</b> as

IWDAttributeInfo a=wdContext.getNodeInfo().getAttribute(IPrivate<View>.IContextElement.VALHELP);

ISimpleTypeModifiable stm=a.getModifiableSimpleType();

EVSvalueSet=stm.getSVServices().getModifiableSimpleValueSet();

int n=wdContext.nodeMatrl_List().size();

for(int i=0;i<n;i++)

{

IMatrl_ListElement item=wdContext.nodeMatrl_List().getMatrl_ListElementAt(i);

EVSvalueSet.put(item.getWerks(),item.getWerks());

}

Here, u r getting value from model node and putting it to local context variable valHelp.

Regards

Fahad Hamsa

Former Member
0 Kudos

Hi Padma,

U can try this;

create a value node in controller.

get the modifiableSimpleType for that.get the value from the model node & set it to valueSet.Map that value node to the node in view.

regards

Sumit