on 01-12-2012 11:50 AM
Hi All,
I am facing node binding error. Please someone help me. I wrote following code.
Zhr_Str_Employee_Rel eno = new Zhr_Str_Employee_Rel();
wdContext.nodeIt_Emp_No().bind(eno);
eno.setEmp_No(wdContext.currentOutput_usernameElement().getEmployeenumber());
IPrivateZsubordinatesView.IIt_Emp_NoNode empno = null;
empno.bind(eno);
when i run the application I am getting folllowing error.
com.sap.tc.webdynpro.progmodel.context.ContextException: Node(ZsubordinatesView.Zhr_Fm_Relations_Down_Input.Output.It_Emp_No): cannot bind or add elements because the node has no valid parent
It seems that I am going somewhere wrong. Please someone help me.
Thanks
Uday
Edited by: Uday Kumar Kanike on Jan 12, 2012 1:00 PM
Is the parent node element of the node you want to bind already created?
You can only add elements to child nodes when all parents are bound and have at least one element.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robin,
following is my model node : Zhr_Str_Employee_Rel
and It_Emp_No is my node to which i need to bind the value.
however, model node is mapped to this node when I checked model binding.
so please suggest me how to proceed.
i need to fetch the value of the following node and bind it to above node.
wdContext.currentOutput_usernameElement().getEmployeenumber()
thanks
uday
In your code, you have:
IPrivateZsubordinatesView.IIt_Emp_NoNode empno = null;
empno.bind(eno);
You cannot bind to a 'null' value. Instead, you need to instantiate the node, use something like:
IPrivateZsubordinatesView.IIt_Emp_NoNode empno = wdContext.nodeIt_Emp_No();
empnode.createAndAddIIt_Emp_NoElement();
empno.bind(eno);
Apologies, a copy-paste error on my side...
Anyways, in your code you have
Zhr_Str_Employee_Rel eno = new Zhr_Str_Employee_Rel();
wdContext.nodeIt_Emp_No().bind(eno);
and later on you tried to bind 'eno' again:
IPrivateZsubordinatesView.IIt_Emp_NoNode empno = null;
empno.bind(eno);
That latest part is not necessary, and I believeyou just need to execute your function
Dear Uday,
Please try this :-
Zhr_Str_Employee_Rel eno = new Zhr_Str_Employee_Rel(WDModelScopeType.APPLICATION_SCOPE);
wdContext.nodehr_Str_Employee_Rel().bind(eno);
eno.setEmp_No(<PASS THE VALUE TO MODEL FOR EXECUTION>);
try
{
eno.execute();
wdContext.nodeOutput_username().invalidate();
}catch(WDDynamicRFCExecuteException ce) {
wdComponentAPI.getMessageManager().reportException("executing Model:: "+ce.getMessage(),false);
}catch(Exception ex){
wdComponentAPI.getMessageManager().reportException("executing Model:: " +ex.getMessage(),false);
}finally{
// Copy Results into IIt_Emp_NoNode Node:
populateIt_Emp_No();
//Disconnect model instance
wdContext.currentZhr_Str_Employee_RelElement().modelObject().modelInstance().disconnectIfAlive();
}
//Create method to populate the value in It_Emp_No
populateIt_Emp_No(){
wdContext.nodeIt_Emp_No().invalidate();
IIt_Emp_NoElement eleEmp = null
if(wdcontext.nodeOutput_username().size() > 0){
for(int i=0; i<wdcontext.nodeOutput_username().size(); i++) {
eleEmp = wdContext.createIt_Emp_NoElement();
eleEmp.set<YOur Attribute to set>(wdContext.nodeOutput_username ().getOutput_usernameElementAt(j).getEmp_No());
wdContext.nodeIt_Emp_No().addElement(eleEmp);
}
}
}
Hope it will helps
Best Regards
Arun Jaiswal
Hi Arun,
My model node name is Zhr_Fm_Relations_Down_Input
Zhr_Str_Employee_Rel is only a root node of RFC to which my It_Emp_No is bounded.
I tried many ways but it dint work.
when I am trying to create instance of It_Emp_No , it is asking for parameter of type Zhr_Str_Employee_Rel.
so i am bit confused how to pass parameter of type to other node.
regards
uday
I am trying this new type. here also i am getting type casting error. i could not convert either e01 to string nor i can take the value as below.
Zhr_Str_Employee_Rel eno = new Zhr_Str_Employee_Rel();
wdContext.nodeIt_Emp_No().invalidate();
IIt_Emp_NoElement e01 = (IIt_Emp_NoElement) wdContext.currentOutput_usernameElement().getEmployeenumber();
wdContext.nodeIt_Emp_No().bind(e01);
Dear Uday,
Once you create the object of the Zhr_Fm_Relations_Down_Input xyz and binded.
Then there is no need to bind for Zhr_Str_Employee_Rel to It_Emp_No. you only need to add or set. like
Zhr_Str_Employee_Rel one = new Zhr_Str_Employee_Rel ();
It_Emp_No two = new It_Emp_No()
two.setEmp("VALUE");
one.addAAA OR SetBBB(two);
xyz.addAAA OR SetBBB(one);
Try it should work.
You might refer to [http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/761eba66-0401-0010-b982-d5f5bd9e8f90|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/761eba66-0401-0010-b982-d5f5bd9e8f90]
Hope it will helps
Best Regards
Arun Jaiswal
Uday Kumar, the problem is with your Output relation. When you initialize the table before execution you should use the table relation from your executable class model (Zhr_Str_Employee_Rel in your case) not from Output. I the context you actually have to create 2 nodes: one under execuatable model class node, and one under Output.
So the context should look like:
Zhr_Str_Employee_Rel
- It_Emp_No
- Output
---It_Emp_No_Output
Hi Arun,
The link was very helpful but still I could not resolve node binding error. Please find the code I wrote.
for( int i=0; i<wdContext.nodeOutput_username().size();i++)
{
inp2.setI_Im_Report("x");
inp2.setI_Ad_Report("x");
inp2.setI_Bh_Report("x");
inp2.setI_Fh_Report("x");
inp2.setI_Hr_Report("x");
inp2.setI_It_Report("x");
String empnumber = wdContext.currentOutput_usernameElement().getEmployeenumber();
Zhr_Str_Employee_Rel eno = new Zhr_Str_Employee_Rel();
eno.setEmp_No(empnumber);
inp2.addIt_Emp_No(eno);
wdThis.wdGetZsubordinatesCompController().executeZhr_Fm_Relations_Down_Input();
}
In my case, Rfc needs "x" value to be passed along with the employee number. so I have set the values manually.
Please help.
Thanks
Uday
Dear Uday,
Apart from inp2 values setting in for loop. you can other code to out of for loop.
for( int i=0; i<wdContext.nodeOutput_username().size();i++)
{
inp2.setI_Im_Report("x");
inp2.setI_Ad_Report("x");
inp2.setI_Bh_Report("x");
inp2.setI_Fh_Report("x");
inp2.setI_Hr_Report("x");
inp2.setI_It_Report("x");
}
If you are passing only constant values then there is no need to user FOR loop.
Try to execute the RFC in backend directly and check what are all attibute and parameter required and set it accordingly.
Best Regards
Arun Jaiswal
Hi Arun,
Finally it worked. Thanks to all who helped me.
Following are the final lines of code I wrote which worked.
for( int i=0; i<wdContext.nodeOutput_username().size();i++)
{
inp2.setI_Im_Report("x");
//inp2.setI_Ad_Report("x");
//inp2.setI_Bh_Report("x");
//inp2.setI_Fh_Report("x");
//inp2.setI_Hr_Report("x");
//inp2.setI_It_Report("x");
//String empnumber = wdContext.currentOutput_usernameElement().getEmployeenumber();
Zhr_Str_Employee_Rel eno = new Zhr_Str_Employee_Rel();
eno.setEmp_No(wdContext.currentOutput_usernameElement().getEmployeenumber());
inp2.addIt_Emp_No(eno);
wdThis.wdGetZsubordinatesCompController().executeZhr_Fm_Relations_Down_Input();
}
Thanks
Uday
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.