on 12-28-2005 6:42 AM
hi
I am creating an web dynpro application for calling a BAPI.
I am developing an application in which I am using dropdownbyindex for creating dropdown boxes.
Each dropdown displays a list of options from where we can select a particular value.
Now my problem is I am not able to bind the value selected from the dropdown to the context of the BAPI.
What I have done is that I tried to capture the values from the drop down and pass those values to the BAPI, but when I passed those dropdown values to the BAPI as the input parameters I am not able to execute that BAPI as the passes values are returning NULL.
SO please help me is there any other way to create dropdowns such that we can bind those dropdown list to the context of the BAPI.
thanks and regards
gopi krishna
Hi gopi,
Use this code to bind the dropdown by index Also check with the selection mode and cardinality of the DD by index property is 1:n
String id1="vijay";
IPrivatePermission_Adminview.INode_subElement x=wdContext.nodeNode_sub().createNode_subElement(); wdContext.nodeNode_sub().addElement(x);
wdContext.currentNode_subElement().setid(id1);
Regards,
Vijayakhanna Raman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Raman
Thanks for your fast response.
we have defined the dropdown options by creating the Value Nodes.
Is this the correct way, or is there any other way to create the drop downs.we have set the cardinality and selection mode for the DD by Index to 1:n
please tell us how to define the options for the Dropdown if that values have to be captured and passed as input paramaters to a BAPI.
thanks and regards
gopi
Hi gopi,
When u create a node and a value attribute bind it to the DD ui element,
This is the way u will populate value in the DD box by my above code and i populated one value in the DD box i.e. one id value,
Why i ask u change the selection mode is there wont be a null value returned from the attribute.
Just write the code to pass value to the BAPI in the Event OnSelect method in the DD by index property
String id=wdContext.currentNode_subElement().getid();
Pass this value.
Regards,
Vijayakhanna Raman
Message was edited by: Vijayakhanna Raman
closing the thread
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gopi,
Could you please give the structure of your context?
Bcaz actually you can not map Value node with Model node.
for that you have to do copyCorresponding method.
Regards,
Karthick K Eswaran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Shakthi
thanks for your fast reply.
Actually we have defined the dropdown options by creating Value nodes and passing the values to that dropdown.
Is there any other way to create the dropdowns such that the values selected in the dropdown can be captured and passed as the input paramaters to the BAPI.
I am giving you the complete structure of the context:
First of all we have four dropdowns:
1.Document type: with 4 options
2.Document status: with 3 options
3.Time frame: with 4 options
4.search type: with 3 options
For each dropdown we have created a Value Node and one value attribute.
In the code part I have declared a String array and declared the options for each dropdown box in that array, and from there by using ArrayList I am adding the options to that dropdown box.
And using for statement I am retrieving the options from the String Array and binding the values to that particular Value Node.
and finally the Node which is being called is displayed with all the possible options.
Please suggest me is there any other way to do this.
Thanks and regards
gopi
Hi Gopi,
If you are hard coding the values of Dropdown,you have to create a simply type,add some key value pairs in that.Create DropdownByKey UI element.assign the attribute to that UI element.Now onselect action get the selected value by using
(example:
Category - Value attribute bind with simple type )
wdThis.wdGetDDController().wdGetContext().currentContextElement().setCategory(wdContext.currentContextElement().getCatagory());
now you can pass it to the bapi as input.
Regards,
Karthick
Hi Gopi,
1. Create a context node "X" with the cardinality 0..n.
Insert the value attribute "Y" of the type String into this node.
2. Create DropdownByIndex UI element and bind the TEXT
property attribute of this element to Y attribute of X node.
3. Populate the dropdown in wdDoInit() method.
String[] values = new String []{"SAP", "MSN", "IBM"};
List nodeElements = new ArrayList();
for (int i = 0; i <letters.length; ++i)
{
IPrivate<your view name>.IXElement xElement =
wdContext.createXElement();
xElement.setY(values<i>);
nodeElements.add(xElement);
}
wdContext.nodeX().bind(nodeElements);
If you want it to default it to a specific value, set it like this
wdContext.nodeX().setLeadSelection(0);
Above statement will default the value in dropdown to "SAP".
On some event, you can capture the selected values of the dropdownlist...
Thanks
Senthil
P.S: Rewards points for useful/helpful answers
Message was edited by: SenthilKumar Radhakrishnan
hi Senthil
Thanks for your response.
The thing you have mentioned we have followed that only.
I am not able to capture the selected values of the dropdownlist.
I tried to capture the values and tried to pass as inputs to the BAPI, but the values are returning NULL.
Can you please suggest me what has to be done for capturing the values from the dropdown.
After that I have to pass the captured values to a BAPI, which has to execute from R/3.
Thanks and regards
gopi
Hi Gopi,
I am assuming that you have some button , User selects the values in all four dropdown list and clicks on this button.
1. In onActionButtonClick() method, try reading the selected value from context
// Select the value selected in FIRST DROPDOWN
String selValue = wdContext.nodeX().getXElementAt
(wdContext.nodeX().getLeadSelection()).getY();
// Set the value to your BAPI input node.
I tried it, it works fine and hope it works for you as well.
If it works, don't forget to give points.
Note: Above is code is related to the nodes etc which i have mentioned in my above thread.
Thanks
Senthil
hi
Thanks for the response.
Now we are able to capture the values from the dropdown, but I am not able to pass these values to the BAPI.
what is the way to pass these values to the BAPI, for example if I am using BAPI as "BAPI_Ytest"
and I have to the values captured from the dropdown to this particular BAPI.
Thanks and regards
gopi krishna
hi
How are you passing values to the BAPI.
Let me give you a example for a single dropdown and you can apply the same to the remaining 3 of them :).
Assume that the values in the dropdown are in the BAPI structure "BAPI_VALUE".
You have created a value node called "va_dropdown" with a value attribute "va_dropattr" and cardinality of the value node is 1..n
When you execute the bapi you will have the BAPI_VALUE filled with values.
loop through the bapi_value model node and then write the code to fill the value node that you created.
//Code Snippet
for(int i=0;i<=wdContext.nodeBAPI_VALUE().size();i++)
{
IPrivate<ViewName>.IVaNodeElement ele = wdContext.nodeVaNodeElement().createVa_NodeElement();
wdContext.nodeVaNodeElement().addElement(ele);
wdContext.nodeBAPI_VALUE().getBAPI_VALUEelementat(i).get<BAPIATTR1>();
wdContext.currentVaNodeElement().setVadropattr();
}
Now the above code would have retrieved the values from the bapi structure and then populated your dropdown value node.
Now to pass values
Say your bapi node is Bapi_Input.
Bapi_Input inp = new Bapi_Input();
wdContext.nodeBapiInputElement().bind(inp);
BAPI_Value b = new BAPI_Value(); //Assuming that your //BAPI_VALUE is defined in the Tables Tab of the RFC
b.set<ModelAttr>();
inp.add<Bapistruct>(b);
then execute the model. i guess that shoudl work for you. The above code is based on assumptions. Its just the concept that you need to use and please dont cut and paste the code and expect it to run.
Hope that helps. But if it still doesnt work let me know the exact bapi structure and your value node declarations and iw ill give you the exact code
regards
Ravi
hi ravi
Thanks for your kind reply, we tried to implement the code you have send to me but we are not able to get thru.
Please can you explain me what do you mean by BAPI structure as you have mentioned that the values in the dropdown will be in the BAPI structure, where can we see that structure.
we are not able to get the structure that is having the dropdown values.
Can you please reply.
thanks and regards
gopi krishna
hi Ravi
we have modified the BAPI and got the dropdown values being populated.
Now I am mapping the values from the dropdown to the input paramaters, but when I am deploying and running the application, I am getting an error.
java.lang.NullPointerException
at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.checkRelatedModelObject(DynamicRFCModelClass.java:754)
at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.setRelatedModelObject(DynamicRFCModelClass.java:771)
at com.sap.tut.wd.flightlist.model.Ytest_1_1_1_Input.setSearch(Ytest_1_1_1_Input.java:192)
at com.sap.tut.wd.flightlist.FlightListCust.wdDoInit(FlightListCust.java:104)
at com.sap.tut.wd.flightlist.wdp.InternalFlightListCust.wdDoInit(InternalFlightListCust.java:212)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingCustomController.doInit(DelegatingCustomController.java:73)
at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)
at com.sap.tc.webdynpro.progmodel.controller.Component.getCustomControllerInternal(Component.java:436)
at com.sap.tc.webdynpro.progmodel.controller.Component.getMappableContext(Component.java:374)
at com.sap.tc.webdynpro.progmodel.controller.Component.getMappableContext(Component.java:403)
at com.sap.tc.webdynpro.progmodel.context.MappingInfo.getDataNode(MappingInfo.java:79)
at com.sap.tc.webdynpro.progmodel.context.MappingInfo.initMapping(MappingInfo.java:121)
at com.sap.tc.webdynpro.progmodel.context.MappingInfo.init(MappingInfo.java:117)
at com.sap.tc.webdynpro.progmodel.context.MappedNodeInfo.doInit(MappedNodeInfo.java:207)
at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:654)
at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:657)
at com.sap.tc.webdynpro.progmodel.context.Context.init(Context.java:40)
at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:199)
at com.sap.tc.webdynpro.progmodel.view.ViewManager.getView(ViewManager.java:540)
at com.sap.tc.webdynpro.progmodel.view.ViewManager.bindRoot(ViewManager.java:422)
at com.sap.tc.webdynpro.progmodel.view.ViewManager.init(ViewManager.java:130)
at com.sap.tc.webdynpro.progmodel.view.InterfaceView.initController(InterfaceView.java:41)
at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)
at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.displayToplevelComponent(ClientComponent.java:135)
at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:392)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:608)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:248)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:48)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)
Do you have any idea about this error.
Moreover if you can provide me with your contact number, I would like to discuss the issue with you.
thanks and regards
gopi
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.