on 12-08-2005 9:30 AM
Hey,
im trying to call a RFC function from Webdynpro where i have to give a table as parameter. When creating the table i following exception:
java.lang.IllegalArgumentException: model object must not be null
at com.sap.tc.webdynpro.progmodel.context.ModelNodeElement.<init>(ModelNodeElement.java:66)
at be.vrt.wdp.IPublicPlanning_Validation$IP_Update_TableElement.<init>(IPublicPlanning_Validation.java:3667)
at be.vrt.wdp.IPublicPlanning_Validation$IContextNode.doCreateElement(IPublicPlanning_Validation.java:87)
at com.sap.tc.webdynpro.progmodel.context.NodeInfo.createElement(NodeInfo.java:854)
at com.sap.tc.webdynpro.progmodel.context.Node.createElementInternal(Node.java:1346)
at com.sap.tc.webdynpro.progmodel.context.Node.createElement(Node.java:1365)
at be.vrt.Planning_Validation.executeRFC_Z_Whatson_Sap_Update_Transmissio_Input(Planning_Validation.java:265)
The code from Planning_Validation (controller class)
public void executeRFC_Z_Whatson_Sap_Update_Transmissio_Input( java.util.Vector nodes, java.lang.String display_value )
{
//@@begin executeRFC_Z_Whatson_Sap_Update_Transmissio_Input()
Z_Whatson_Sap_Update_Transmiss_Input transmiss = new Z_Whatson_Sap_Update_Transmiss_Input();
//transmiss.addP_Update_Table(new Zmm_S_Update_Status_Table());
wdContext.nodeZ_WHATSON_SAP_UPDATE_TRANSMIS().bind(transmiss);
//wdContext.createP_Update_TableElement(new Zmm_S_Update_Status_Table());
for (int i = 0; i < nodes.size(); i++){
String [] node = (String[])nodes.get(i);
IWDNodeElement el = wdContext.nodeP_Update_Table().createElement();
el.setAttributeValue("Won_Id", node[0]);
el.setAttributeValue("Won_Status", node[1]);
el.setAttributeValue("Display_Status", display_value);
}
try {
// Call remote function
wdContext.currentZ_WHATSON_SAP_UPDATE_TRANSMISElement().modelObject().execute();
// synchronise data in context with data in model
wdContext.nodeOutput().invalidate();
} catch (WDDynamicRFCExecuteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Line 265 is where i call wdContext.nodeP_Update_Table().createElement();
Any ideas ?
grtz,
Hannes
Hi,
The error may be coming probably because in the code given below
for (int i = 0; i < nodes.size(); i++){
String [] node = (String[])nodes.get(i);
IWDNodeElement el = wdContext.nodeP_Update_Table().createElement();
el.setAttributeValue("Won_Id", node[0]);
el.setAttributeValue("Won_Status", node[1]);
el.setAttributeValue("Display_Status", display_value);
}
You have created the element and also set the values for the attribute but you haven't added the element to the node. So you must include the code
wdContext.nodeP_Update_Table().addElement(el);
as the last step inside the for loop.
I think this will slove the problem.
Regards,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Well you can do the following.
Assume the name of the table is Tablename then,
//following would be the code
TableName tab = new TableName();
tab.set<tableAttr1>(<Parameter>);
tab.set<tableAttr2>(<Parameter>);
.
.
//Similarly for all attributes of the table.
then say
transmiss.add<Tablename>(tab);
the above snippet should be in a loop.
That should solve your problem.
Hope that helps.
Let me know if you require more information.
regards
Ravi
Thanks for your help so far but i did not succeed to get it working yet...
The table is located here: Context->Z_WHATSON_SAP_UPDATE_TRANSMISS->P_Update_Table-> with attributes Display_Status, Won_Id, Won_Status.
When i add wdContext.nodeP_Update_Table().addElement(el);, the "model object must not be null"-Exception still occurs at the wdContext.nodeP_Update_Table().createElement(); statement,
Did not get to work Ravi's solution either:
IP_Update_TableNode tab = wdContext.nodeP_Update_Table();
but then i cannot access tab.set?? function. Im pretty sure you need to create elements though ..
greetings,
Hannes
Hi
Shouldnt it be wdContext.nodeP_Update_Table().create_UpdateTableElement();
Are you binding your model node to the table meaning P_Update_Table to the table ui element.
try the following code :
Z_WHATSON_SAP_UPDATE_TRANSMISS tran = new Z_WHATSON_SAP_UPDATE_TRANSMISS();
Try this for a single value and see.
wdContext.nodeZ_WHATSON_SAP_UPDATE_TRANSMISSElement().bind(tran);
IP_Update_TableNodeElement ele = wdContext.nodeP_Update_Tablenode().createP_UpdateTAbleNodeElement();
wdContext.nodeP_UpdateTableNode().addElement(ele);
P_UpdateTable tab = new P_UpdateTable();
tab.setDisplay_Status(<Parameter>);
tab.setWon_Id(<Parameter>);
tab.setWon_Status(<Parameter>);
tran.addP_UpdateTable(tab);
Once the above is done also check the size to ensure that the record is filled in the model.
int Tablesize = wdContext.nodeP_updateTableNode().size();
wdComponentAPI.getMessageManager().reportSuccess("Size ::"+Tablesize);
try
{
wdContext.currentZ_WHATSON_SAP_UPDATE_TRANSMISSElement().modelObject().execute();
}
catch(Exception e)
{
}
The above code might not be exact but since i do not have a system i have just typed it in with some approx. So Do let me know if that helped you.
It should solve your problem but in any case let me know.
regards
Ravi
> Shouldnt it be wdContext.nodeP_Update_Table().create_UpdateTableElement(Zmm_S_Update_Status_Table p)
This needs a Zmm_S_Update_Status_Table as parameter, where should i get that ?
> P_UpdateTable tab = new P_UpdateTable();
this does not exist, the closest similar that i can find is:
IP_Update_TableNode tab = wdContext.nodeP_Update_Table();
but then tab.setDisplay_Status(<Parameter>) methods do not exist, the only set functions are:
tab.setLeadSelection()
tab.setSelected()
tab.setTreeSelection()
Greetings,
Hannes
Hi
In the context menu of your model what are the proxy classes that got generated. There you can see a separate class generated for the table parameter in the RFC. You should use that parameter to instantiate and then try doing the set.
normally you would have a structure like <BAPINAME>_Input , BAPINAME_Output followed by table classes if any.
Anyway if you still have a problem tell me the name of the proxy classes.
regards
Ravi
Hey, thanks .. i managed to solve it
this is the code:
//@@begin javadoc:executeRFC_Z_Whatson_Sap_Update_Transmissio_Input()
/** Declared method. */
//@@end
public void executeRFC_Z_Whatson_Sap_Update_Transmissio_Input( java.util.Vector nodes, java.lang.String display_value )
{
//@@begin executeRFC_Z_Whatson_Sap_Update_Transmissio_Input()
Z_Whatson_Sap_Update_Transmiss_Input transmiss = new Z_Whatson_Sap_Update_Transmiss_Input();
wdContext.nodeZ_WHATSON_SAP_UPDATE_TRANSMIS().bind(transmiss);
for (int i = 0; i < nodes.size() ; i++){
String [] node = (String[])nodes.get(i);
Zmm_S_Update_Status_Table updEl = new Zmm_S_Update_Status_Table();
updEl.setWon_Id(node[0]);
updEl.setWon_Status(node[1]);
updEl.setDisplay_Status(display_value);
transmiss.addP_Update_Table(updEl);
}
wdComponentAPI.getMessageManager().reportSuccess("wohoo!");
try {
// Call remote function
wdContext.currentZ_WHATSON_SAP_UPDATE_TRANSMISElement().modelObject().execute();
// synchronise data in context with data in model
wdContext.nodeOutput().invalidate();
} catch (WDDynamicRFCExecuteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//@@end
}
Hi
As Mahesh suggested you need to include the line
wdContext.nodeP_Update.addElement(el);
should be written in for loop.
But still can you send more information about the node as there is no mention of the table and other such parameters.
Thanks
Srikant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.