on 09-10-2008 9:56 PM
Hi,
I have a BAPI ZHRECMFM_002_PERFRAT_WARNING that has two table parameter one is PERNR_LIST of type HROBJECT and another one is PERNR_PERFRAT of type ZHRECMGLS_002_PERNR_PERFRAT that consists of two elements pernr and perf_text.
I need to set PERNR_LIST(set of pernrs) in my WDA and call the BAPI.that BAPI will return PERNR_PERFRAT table parameter.
1.How will I pass PERNR_LIST(that consists of multiple HROBJECTS) to the BAPI.
2.After executing the BAPI How will I iterate thru PERNR_PERFRAT to get pernr and corresponding perf_text.
I tried to set PERNR_LIST using the following way suggested SivaRama Krushna
IPrivate<viewname>.I<nodeame>Node prNode = wdContext.node<node>();
IPrivate<viewname>.I<nodeame>Element prEle;
for (int i = 0; i < table.size(); i++) {
HROBJECT pernrList = new HROBJECT();
pernrList.setPernr(pernr); // Set the pernr from current record
prEle = prNode.create<nodeame>Element(pernrList);
prNode.addElement(prEle);
}
My code
IPrivateVEcmPlanningView.IPERFWARNNode prNode = wdContext.nodePERFWARN();
IPrivateVEcmPlanningView.IPERFWARNElement prEle ;
Hrobject pernrList = new Hrobject();
pernrList.setPlvar("01");
pernrList.setOtype("NA");
pernrList.setObjid(pernr);
prEle= prNode.createPERFWARNElement(pernrList);
prNode.addElement(prEle);
Type Mismarch:cannot convert IWDNodeElement to IPrivate<viewname>.I<nodeame>Element.
Please help me in resolving this issue
Thanks
Bala Duvvuri
Hi Bala,
You did not provide the node(table) name that you created for PERNR_LIST. Try this out in your Planning VAC of MSS ECM DC:
// you need to create reference to the PERNR_LIST node
// I am assuming the node name is PERNR_LIST
IPrivateVEcmPlanningView.IPERNR_LISTNode prNode = wdContext.nodePERNR_LIST();
// you need to create element of the type PERNR_LIST node
IPrivateVEcmPlanningView.IPERNR_LISTElement prEle ;
Hrobject pernrList = new Hrobject();
pernrList.setPlvar("01");
pernrList.setOtype("NA");
pernrList.setObjid(pernr);
prEle= prNode.createPERNR_LISTElement(pernrList);
prNode.addElement(prEle);
Regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I wrote the following code
float amount = 0;
Zhrecmfm_002_Perfrat_Warning_Input input = new Zhrecmfm_002_Perfrat_Warning_Input();
wdContext.nodePERFWARN().bind(input);
if(cpamt!=null)
{
String amt = "";
amt = cpamt.toString();
amount = Float.parseFloat(amt);
}
//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Amount"+amount);
if(amount>0.0){
pernrCounter = 1;
IPublicVEcmPlanningComp.IPernr_ListNode prNode = wdContext.nodePernr_List();
IPublicVEcmPlanningComp.IPernr_ListElement prEle ;
Hrobject pernrList = new Hrobject();
pernrList.setPlvar("01");
pernrList.setOtype("NA");
pernrList.setObjid(pernr);
if(prNode!=null)
{prEle= prNode.createPernr_ListElement(pernrList);
prNode.addElement(prEle);
//wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Inside Amount"+prNode.size());
}
and context is like this
PERFWARN 0:n
output 0:1
Pernr_List 0:n
Perf_rat 0:n
it is not giving any syntax errors but when i am executing it si giving runtime erros saying that
com.sap.tc.webdynpro.progmodel.context.ContextException: Node(VEcmPlanningComp.PERFWARN.Output.Pernr_List): cannot bind or add elements because the node has no valid parent
* at com.sap.tc.webdynpro.progmodel.context.Node.prepareAddElement(Node.java:656)*
* at com.sap.tc.webdynpro.progmodel.context.Node.addElement(Node.java:635)*
Please let me know how to resolve this
Hi Bala,
Your context structure is:
PERFWARN 0:n
output 0:1
Pernr_List 0:n
Perf_rat 0:n
I think this is not exact replica of model. i.e. you have not bound entire model to Controller.
General BAPI or RFC model is like this:
<BAPI>Input
-Input tables
-Output
--Output tables
Input tables are used to send data and output tables are used to retrieve data.
In your case, the model may be like this
Zhrecmfm_002_Perfrat_Warning_Input
-Pernr_List
-Perf_rat
-Output
-
Pernr_List
-
Perf_rat
-
<Return>
-<Return>
The Component controller must contain all these model node.
Your problem is com.sap.tc.webdynpro.progmodel.context.ContextException: Node(VEcmPlanningComp.PERFWARN.Output.Pernr_List): cannot bind or add elements because the node has no valid parent
You are trying to send data through output table, that is why you are getting exception. Use input tables for sending data and output tables for see the result or any other manipulataion.
Regards,
Siva
Hi Bala,
Try following:
float amount = 0;
Zhrecmfm_002_Perfrat_Warning_Input input = new Zhrecmfm_002_Perfrat_Warning_Input();
wdContext.nodePERFWARN().bind(input);
if(cpamt!=null)
{
String amt = "";
amt = cpamt.toString();
amount = Float.parseFloat(amt);
}
if(amount>0.0){
pernrCounter = 1;
Hrobject pernrList = new Hrobject();
pernrList.setPlvar("01");
pernrList.setOtype("NA");
pernrList.setObjid(pernr);
input.addPERNR_LIST(pernrList);
}
Regards,
Gopal
I need to add multiple HROBJECT not just one so i think
float amount = 0;
Zhrecmfm_002_Perfrat_Warning_Input input = new Zhrecmfm_002_Perfrat_Warning_Input();
wdContext.nodePERFWARN().bind(input);
if(cpamt!=null)
{
String amt = "";
amt = cpamt.toString();
amount = Float.parseFloat(amt);
}
if(amount>0.0){
pernrCounter = 1;
Hrobject pernrList = new Hrobject();
pernrList.setPlvar("01");
pernrList.setOtype("NA");
pernrList.setObjid(pernr);
input.addPERNR_LIST(pernrList);
}
wont work
Hi Bala,
What I had given was a sample code from which you can take the clue. To send table parameter as input you multiple times use add method.
It is up to you what logic you are using to send table parameter. Once again I am giving you the sample code. Try to take clue from it:
//Initializing The RFC model class
Zhrecmfm_002_Perfrat_Warning_Input input = new Zhrecmfm_002_Perfrat_Warning_Input();
wdContext.nodePERFWARN().bind(input);
//Sending 2 rows to table parameter to RFC input
Hrobject pernrList = new Hrobject();
pernrList.setPlvar("01");
pernrList.setOtype("NA");
pernrList.setObjid(pernr);
input.addPERNR_LIST(pernrList);
Hrobject pernrList1 = new Hrobject();
pernrList1.setPlvar("02");
pernrList1.setOtype("NA");
pernrList1.setObjid(pernr1);
input.addPERNR_LIST(pernrList1);
OR
//Using some kind of for loop. Sending 5 rows to table parameter to RFC //input
for(int i=0;i<5;i++){
Hrobject pernrList = new Hrobject();
pernrList.setPlvar(""+i);
pernrList.setOtype("NA");
pernrList.setObjid(pernr);
input.addPERNR_LIST(pernrList);
}
//Executing the RFC
input.execute();
OR
//if RFC execution is done from some different method
wdContext.nodePERFWARN().currentPERFWARNElement().modelObject().execute();
Hope you got some insight as to how table parameter have to be sent as input to RFC.
Warm Regards,
Gopal
Hi Bala,
In your code
prEle= prNode.createPERFWARNElement(pernrList);
prNode.addElement(prEle);
Can you please try like this?
prEle= wdContext.createPERFWARNElement(pernrList);
prNode.addElement(prEle);
I will explain the difference
If you want get the reference of the node element that already exist then we use this coding
//prEle= prNode.getPERFWARNElementAt(i);
now in prEle you have (i+1) record of PERNR_LIST.
Hope you understand.
Regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Bala,
I am not sure of the node structure but here is an example for you
Parent Node :- ParentNode
tables:- table1,table2
table 1 and table2 are the other two node which ar eof type table
you can try this
Parent p=new parent().
table1 t1= new table1(p); //if required pass p
t1.set<>;
....
table2 t2=new table2(p);
t2.set<>.....
p.settable1(t1);
p.settable2(t2);
wdContext.nodeParent.bind(p);
regards
Pankaj Prasoon
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.