Skip to Content
0
Dec 05, 2006 at 12:37 PM

Problem with adding a new element to a model node.

54 Views

Hi SDN,

I have a bapi with import,export and table parameters.

In my web-dynpro application I need to display several Input box and dropdowns, whose values come from other bapi's

now when the user clicks save button I need to geather all the fields and values, create an element, pass values to the element, add this element to the model node.

when I am trying to add an element to the model node it is giving an null pointer exception.

please tell me where I am wrong in the below code,

public java.lang.String Create_Incident( )

{

//@@begin Create_Incident()

Zbapi_Create_Incident_Input input = new Zbapi_Create_Incident_Input();

AbstractList tablist = new Zbapi_Incident_Create_Wittable.Zbapi_Incident_Create_Wittable_List();

Zbapi_Incident_Create_Wittable tab = new Zbapi_Incident_Create_Wittable();

try

{

input.setEntrytype(wdContext.currentF4_Entry_TypeElement().getIatype());

input.setPlant(wdContext.currentF4_PlantElement().getWerks());

input.setReportableevent(wdContext.currentContextElement().getRepEvent());

input.setLanguage(wdContext.currentF4_LanguageElement().getSprsl());

input.setProductiontimelost(wdContext.currentContextElement().getTimelost());

input.setEventdate(wdContext.currentContextElement().getDate());

input.setEventtime(wdContext.currentContextElement().getTime());

input.setEventdesc(wdContext.currentContextElement().getEvent_txt());

input.setWorkarea(wdContext.currentF4_WorkareaElement().getWorkarea());

input.setAccidentloc(wdContext.currentF4_AclocElement().getAcloc());

input.setDescription(wdContext.currentContextElement().getDesc());

// wdContext.nodePersontable().invalidate();

IPublicEHS_WSOCust.IPersontableElement ele = wdContext.createPersontableElement(new Zbapi_Incident_Create_Wittable());

ele.setPersonrole(wdContext.currentF4_PersonroleElement().getIptype());

ele.setDescofrole(wdContext.currentContextElement().getDescofrole());

ele.setPersons(wdContext.currentContextElement().getTypeOfPerson());

ele.setPersoninvolved(wdContext.currentContextElement().getPersonInvol());

ele.setName(wdContext.currentContextElement().getPersonname());

ele.setWitnesspersontype(wdContext.currentContextElement().getWitnesstype());

ele.setWitnessperson(wdContext.currentContextElement().getWitnessInvolved());

wdContext.nodePersontable().addElement(ele);//***********************//

wdContext.nodePersontable().invalidate();

for(int i=0;i<wdContext.nodePersontable().size();i++)

{

tablist.add(wdContext.nodePersontable().getPersontableElementAt(i).modelObject());

}

input.setPersontable(tablist);

}

catch(Exception ex)

{

return "three"+ex.toString();

}

try

{

wdContext.nodeZbapi_Create_Incident_Input().bind(input);

wdContext.currentZbapi_Create_Incident_InputElement().modelObject().execute();

}

catch(Exception ex)

{

return "four"+ex.toString();

}

wdContext.nodeOutput().invalidate();

return "true";

//@@end

}

When I comment this statement wdContext.nodePersontable().addElement(ele);

there is no error, when I uncomment there is a null pointer exception.

Thanks & Regards,

Sai Krishna.