on 11-19-2009 4:36 AM
Tushar Sinha ,
Please find below remining code( iam using z function module it is working fine in r/3)
for(int i=0;i<asize;i++)
{ key = wdContext.nodeIt_State().getIt_StateElementAt(i).getAttributeAsText("Statecode");
value = wdContext.nodeIt_State().getIt_StateElementAt(i).getAttributeAsText("Statenm");
stset.put(key,value);
}
asize = wdContext.nodeIt_City().size();
for(int i=0;i<asize;i++)
{ key = wdContext.nodeIt_City().getIt_CityElementAt(i).getAttributeAsText("Psa");
value = wdContext.nodeIt_City().getIt_CityElementAt(i).getAttributeAsText("Btext");
ctset.put(key,value);
}
asize = wdContext.nodeIt_Bloodgp().size();
for(int i=0;i<asize;i++)
{ key = wdContext.nodeIt_Bloodgp().getIt_BloodgpElementAt(i).getAttributeAsText("Wtfld");
value = wdContext.nodeIt_Bloodgp().getIt_BloodgpElementAt(i).getAttributeAsText("Stext");
bgset.put(key,value);
}
asize = wdContext.nodeIt_Rhfact().size();
for(int i=0;i<asize;i++)
{ key = wdContext.nodeIt_Rhfact().getIt_RhfactElementAt(i).getAttributeAsText("Wtfld");
value = wdContext.nodeIt_Rhfact().getIt_RhfactElementAt(i).getAttributeAsText("Stext");
rhset.put(key,value);
}
}
catch(Exception ex)
{ }
Edited by: kishore shikore on Nov 19, 2009 6:15 AM
Hi Kishore,
What now seems to be the issue is you have created seperate Model Node in the View Controller Zhrblood_Group_Input for the BAPI Zhrblood_Group and after you have bound it to Zhrblood_Group_Input structure node of the model imported you have even bound the drop downs for Region, City, BloodGp, Rhfactor to the Nodes within the Parament Model Node. Everytime you call this bapi, new values are getting set to City Node without invalidating the previous node.
So just after
wdContext.currentZhrblood_Group_InputElement().modelObject().execute();
statement, invalidate the Output node under Zhrblood_Group_Input node to delete the earlier values and refresh the output node.
wdContext.nodeZhrblood_Group_InputElement().nodeOutput().invalidate();
Moreover, I can see that you have hard coded the values to be passed in the input structure of the Model Node. So, everytime the same result will be given by the BAPI irrespective of the current value for region selected in the dropdown. You actually have to pick the current element value from the context. Have a look.
Zhrblood_Group_Input input=new Zhrblood_Group_Input();
wdContext.nodeZhrblood_Group_Input().bind(input);
input.setMode("DIS");
input.setStatecode("13");
input.setCity("VASA");
input.setRhfactor("03");
input.setBlood_Gp("01");
Like for setting State, use
input.setStatecode(wdContext.node<State>().current<State>Element().get<StateCode>());
So, i will suggest you to create seperate Context Nodes for Region, City, BloodGp and RhFactor and have context attribute for them. Then, bind them to the drop down UI elements in the Layput of the View Controller.
That should solve your problem.
Regards,
Tushar Sinha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear tushar
iam facing the following error after above changes,
public void wdDoInit()
{
//@@begin wdDoInit()
int asize =0;
String key="";
String value="";
IWDMessageManager msgMrg = wdThis.wdGetAPI().getComponent().getMessageManager();
Zhrblood_Group_Input input=new Zhrblood_Group_Input();
wdContext.nodeZhrblood_Group_Input().bind(input);
input.setMode("DIS");
input.setStatecode(wdContext.nodeCtx_itstate().currentCtx_itstateElement().getCtx_statecode());
input.setCity(wdContext.nodeCtx_itcity().currentCtx_itcityElement().getCtx_psa());
input.setRhfactor("");
input.setBlood_Gp("");
try
{ wdContext.currentZhrblood_Group_InputElement().modelObject().execute();
wdContext.nodeZhrblood_Group_Input().nodeOutput().invalidate();
}
onaction code
public void onActiononstate(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
wdContext.currentZhrblood_Group_InputElement().setStatecode(wdContext.currentContextElement().getCtx_state());
wdContext.currentZhrblood_Group_InputElement().setCity(wdContext.currentContextElement().getCtx_city());
wdContext.currentZhrblood_Group_InputElement().setBlood_Gp(wdContext.currentContextElement().getCtx_bloodgroup());
wdContext.currentZhrblood_Group_InputElement().setRhfactor(wdContext.currentContextElement().getCtx_rhfactor());
//@@end
}
ERROR:
java.lang.NullPointerException
at com.essar.ess.bloodgroup.comp.Overview_bloodgroup.wdDoInit(Overview_bloodgroup.java:113)
at com.essar.ess.bloodgroup.comp.wdp.InternalOverview_bloodgroup.wdDoInit(InternalOverview_bloodgroup.java:270)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)
at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:445)
... 32 more
PLEASE SUGGEST ME
Edited by: kishore shikore on Nov 19, 2009 10:20 AM
Hi Kishore,
I really don't get why you passed hard coded values for Rhfactor and Blood_Gp as input paramaters earlier and now passed nothing (i mean empty string) at all.
input.setRhfactor("");
input.setBlood_Gp("");
Probably, if only one value needs to be passed everytime then better hard code that. Otherwise pick it up from the context as you did before for StateCode.
Also, why do you have to send City as input parameter to get all cities from the State? Isn't StateCode, Mode.Rhfactor and Blood_Gp enough. So, better not set that.
Now, we come to the null pointer.
From the code that you have sent, i am not able to figure out the line at which this exception is generated. Probably, no result is returned in the Output Node and you are trying to retrieve values from there.
So, loop through the Output Node size and get values using
String city = wdContext.node<Output>().get<OutputNode>ElementAt(int index).get<City>();
and then add an element in the final City node bound to the City Dropdown list.
Lemme know if you are still not done.
Regards,
Tushar Sinha
Dear tushar,
now we changed the rfc if we pass statel code it will give all cites related information in cites drop down now cites and rhfactor and blood grop r nor compalsory.
Send me the code how can i write coding without hard coding the values . after deploying application when i select state it should show related cites.help me
Regards,
public void wdDoInit()
{
//@@begin wdDoInit()
/*
1. Create a Context Node Vn_State and attribute Va_StateName and Va_StateCode within. bind the Va_State with the state drop down list
2. Create a Context Attribute Va_City and bind it to the City Input Field.
3. Create a Model node Mn_GetCityForState and bind it to the Zhrblood_Group_Input of the used model Zhrblood_Group in context
4. Write Code to populate the node Vn_State.
IPrivate<Your>View.Ivn_StateElement stateEle = null;
stateEle = wdContext.createVn_StateElement();
stateEle.setVa_StateName("Andhra Pradesh");
stateEle.setVa_StateCode("01");
wdContext.addElement(stateEle);
Similarly populate other states. or you can use the for loop and string arrays as a shortcut for this.
*/
//@@end
}
-
//onaction code
public void onActiononstate(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//Reset City field for the new bapi call to start
wdContext.currentContextElement().setVa_City("");
IWDMessageManager msgMrg = wdThis.wdGetAPI().getComponent().getMessageManager();
//Make a Bapi call
Zhrblood_Group_Input input=new Zhrblood_Group_Input();
wdContext.nodeZhrblood_Group_Input().bind(input);
input.setMode("DIS"); //Not sure if is mandatory to set or you can just miss this line or set empty string instead
input.setStatecode(wdContext.nodeVn_State().currentVn_StateElement().getVa_statecode());
try
{ wdContext.currentZhrblood_Group_InputElement().modelObject().execute();
wdContext.nodeZhrblood_Group_Input().nodeOutput().invalidate();
}catch(Exception e){
msdMrg.reportException("Error in retrieving cities for state: " + e, true);
}
if((wdContext.nodeZhrblood_Group_Input().nodeOutput()!= null)
&& (wdContext.nodeZhrblood_Group_Input().nodeOutput().size>0)
&& (wdContext.nodeZhrblood_Group_Input().nodeOutput().currentOutputElement()!= null)){
}
wdContext.currentContextElement().setCtx_city()(
wdContext.nodeZhrblood_Group_Input().nodeOutput().currentOutputElement().getCtx_city());
//@@end
}
-
Just make sure that your context structure is similar if not the same.
And simply copy past the code in appropriate methods and make changes as per your exact Node and attribute names.
Hope i have addressed to your query.
Regards,
Tushar Sinha
Dear tushar
i dont want hard coded code if iam doing so means i have to pass in runtime andhra only maharastra
stateEle.setVa_StateName("Andhra Pradesh");
stateEle.setVa_StateCode("01");
wdContext.addElement(stateEle);
hi tushar plz give me ur mail id i will send my project to u that is easy to find my error bother about ur points thats i will give u
Edited by: kishore shikore on Nov 20, 2009 8:32 AM
Edited by: kishore shikore on Nov 20, 2009 8:34 AM
Edited by: kishore shikore on Nov 20, 2009 8:34 AM
Hi Kishore,
The following code only creates an element in the Vn_State Node. Similarly you can create elements for other states which would be displayed in the drop down list.
stateEle.setVa_StateName("Andhra Pradesh");
stateEle.setVa_StateCode("01");
wdContext.addElement(stateEle);
Now in the bapi when you pass the State Code, the code passed is of the currently selected state from the drop down list. Look at this line.
input.setStatecode(wdContext.nodeVn_State().currentVn_StateElement().getVa_statecode());
So, at run time if you have chosen Delhi, which has a code "09" then as per currentElement code for Delhi "09" would be passed and not "01" of Andhra Pradesh. So, it would get all cities of Delhi and not Andhra.
One major correction from my end is I had asked you to have create an attribute Va_city for City Input Field. What I actually meant is have a Context Node Vn_City and an attribute within Va_City. Map this Va_City with a drop down for City (and not inputfield).
So, when you get the output of the bapi after excute statement, you have a list of Cities under a node Ctx_itcity under the modelNode>outputNode>CityNode.
Get cities from there and create element for Vn_City Node in the context as you have done for all the States under Vn_States.
So change the code:
wdContext.currentContextElement().setCtx_city()(
wdContext.nodeZhrblood_Group_Input().nodeOutput().currentOutputElement().getCtx_city());
with
IPrivate<Your>View.IVn_CityElement cityEle = null;
for(int i=0; i<wdContext.nodeZhrblood_Group_Input().nodeOutput().nodeCtx_itcity().size();i++){
cityEle = wdContext.createVn_CityElement();
cityEle.setVa_City(wdContext.nodeZhrblood_Group_Input().nodeOutput().nodeCtx_itcity()
.getCtx_itCityNodeElementAt(i).getCtx_itcity());
wdContext.nodeVn_City().addElement(cityEle);
}
Revert for any clarification required on phone.
Regards,
Tushar Sinha
9948806838
Hi
1. [Have a look on this answered thread|; (Using different approach)
2.If data is coming from from RFC for both case 1 Selection of country 2. Based on selected country all state/cities and both object are are in DRopDownByKey UI., Create one method having parameter of type String which will contain the Key of each country , further which will input for that RFC which contain list of state/cities. , this method will be called at ACTION of Country selection witch put all the data in IModifiableSimpleValueSet.
For point 2 : [valuehelp improvements|;
have a look on given line which I explained here
district = wdContext.nodeReturnGetAllDistrict().getReturnGetAllDistrictElementAt(i);
valueSet_dist.put(district.getSalesOrgCode(), district.getSalesOrgName());
and
valueSet_dist.clear();
I hope I am clear?
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.