cancel
Showing results for 
Search instead for 
Did you mean: 

Populating dropdown by key from model..

Former Member
0 Kudos

Hi all,

I need to fillup the RFC data in dropdown by key..

I have cretaed upto importing the model and executing the RFC method in controller and binded the dropdown with the model context node.

i.,e doinit() and executeRFCmethod() is impleted in the controller...

I dont know how to fill this dropdown by ke in the init emthod...

Whats code to write in init() method of controller to populate with RFC data...

Can anyone help me on this...

Regards

Sireesha.

Accepted Solutions (1)

Accepted Solutions (1)

lokesh_kamana
Active Contributor
0 Kudos

Hi sirisha,

For your information i tried out an example please check it once.

Function Module is BAPI_CURRENCY_GETLIST.

Node structure is as follows.

BAPI_CURRENCY_GETLIST_INPUT(node)

---Output(subnode)

---Currency_List(subnode)

---Currency(attribute)

This is the context which we will get from model.

Take another value attribute "curr" in the root context .

context

-


curr.

You take an elment Drop down by key in the layout and bind the poperty selcted key to the attribute "curr".

WDDOINIT


public void wdDoInit()
  {
    //@@begin wdDoInit()
    try
    {
    
    Bapi_Currency_Getlist_Input input = new Bapi_Currency_Getlist_Input();
    wdContext.nodeBapi_Currency_Getlist_Input().bind(input);
    wdContext.currentBapi_Currency_Getlist_InputElement().modelObject().execute();
	wdContext.nodeBapi_Currency_Getlist_Input().nodeOutput().nodeCurrency_List().invalidate();
    }
    
    catch (Exception e) {
		// TODO: handle exception
	}
	int size=wdContext.nodeOutput().nodeCurrency_List().size();
	wdComponentAPI.getMessageManager().reportSuccess(size+"");
	
	IWDAttributeInfo info = wdContext.getNodeInfo().getAttribute("curr");
	IModifiableSimpleValueSet svs = info.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
	for(int i=0;i<size;i++)
	{
		svs.put(wdContext.nodeBapi_Currency_Getlist_Input().nodeOutput().nodeCurrency_List().getElementAt(i).getAttributeValue("Currency"),wdContext.nodeBapi_Currency_Getlist_Input().nodeOutput().nodeCurrency_List().getElementAt(i).getAttributeValue("Currency")+"");
		
	}
  
    //@@end
  }

Thanks & Regards,

Lokesh

Edited by: lokesh kamana on Nov 7, 2008 9:51 AM

Answers (7)

Answers (7)

lokesh_kamana
Active Contributor
0 Kudos

Hi sirisha,

Is ur issue resolved or not.

If it is resolved plz close the thread.

If not plesae let us know where ur facing the problem.

Thanks & Regards,

Lokesh

Former Member
0 Kudos

Hi lokesh and all,

Sorry!!!.

I could not connect to SDN due to some network issues.

Anyway i have assigned the points n closed it.

Actually it was problem with the RFC. Rtype has been checked out for one particular field in the Table Type.

Though RFC is getting executed from the backend , data is not populating in the dropdown.

The code which i wrote initially was also correct. Only the problem is with this checkbox in the Table Type in the RFC.

Anyway thanks a lot for all who helped me in solving the issue.

Former Member
0 Kudos

Hi,

Following links could be useful for your scenario, please have a look:

Value of RFC in Dropdownbykey:

OVS: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e038cf90-0201-0010-0a9a-ec69262a...

Regards,

Anagha

Former Member
0 Kudos

Hi Sreesha,

After executing the RFC , you need to invalidate the output node of RFC.Since you have not mentioned about it in the code used for executing the RFC,add the below mentioned code...

wdContext.node<output node name>.invalidate();

Hope this helps you !!!

regards,

amit bagati

Former Member
0 Kudos

Try the following Code :

METHOD IN COMPONENT CONTROLLER FOR DROP DOWN

public void mth_GetCurrency( )

{

//@@begin mth_GetCurrency()

try

{

/*Method to get currency data from Bapi_Currency_Getlist into the drop down for currency.

Executes Bapi_Currency_Getlist./

object_CurrencyFind.execute();

wdContext.nodeBapi_Currency_Getlist_Input().nodeOutputCurrency().nodeCurrency_List().invalidate();

}

catch(Exception e){

wdComponentAPI.getMessageManager().raiseException(""+e,true);

}

//calculate number of elements in the currency_list node of Bapi_Currency_Getlist.

int size=wdContext.nodeOutputCurrency().nodeCurrency_List().size();

/Get simple type modifiable serices for the context attribute to which drop down is to be applied/

IWDAttributeInfo name1Info1 =wdContext.nodeCn_Currency().getNodeInfo().getAttribute("Ca_Currency");

ISimpleTypeModifiable name1=name1Info1.getModifiableSimpleType();

IModifiableSimpleValueSet name1ValueSet=name1.getSVServices().getModifiableSimpleValueSet();

/Enumerate the context attribute with data from Bapi for currency/

String type="";

String typeValue="";

for(int i=0;i<size;i++)

{

type = wdContext.nodeBapi_Currency_Getlist_Input().nodeOutputCurrency().nodeCurrency_List().currentCurrency_ListElement().getCurrency();

typeValue= wdContext.nodeBapi_Currency_Getlist_Input().nodeOutputCurrency().nodeCurrency_List().currentCurrency_ListElement().getLong_Text();

wdContext.nodeBapi_Currency_Getlist_Input().nodeOutputCurrency().nodeCurrency_List().moveNext();

name1ValueSet.put(type" "typeValue,typeValue" "type);

}

//@@end

}

Thanx.

lokesh_kamana
Active Contributor
0 Kudos

Hi,

My Context is like this.

context

---zbapi_vendor_input

---output

-


vendortable

---lifnr(attribute)

context i had another attribute -


Vendor.

Code:-


zbapi_vendor_input vendor = new zbapi_vendor_input();
wdcontext.nodezbapi_vendor_input.bind(vendor);
wdcontext.currentzbapi_vendor_input.modelobject().execute();
int n = wdcontext.nodevendortable().size();
IWDAttributeInfo vendorinfo = wdcontext.getNodeInfo.getattribute("Vendor");
IModifiablesimplevalueset values = vendorinfo.getModifiablesimpleType.getSVServices.getModifiablesimplevalueset();
for(int i =;i<n:i++)
{
String ven = string.valueof(wdcontext.nodezbapi_vendor_input().nodeoutput.nodevendortable.getElementAt(i).getAttributeValue("lifnr"));
values.put(ven,ven);
}

Thanks & regards,

Lokesh

Former Member
0 Kudos

Hi Lokesh,

Thank you for your clear explanation.

I have tried with the below code but am getting exception java.lang.NullPointerException at ISimpleTypeModifiable simpletype = attributeinfo.getModifiableSimpleType(); I have checked the cause of the exception by commenting each n every line. So i am getting the exception at the above line....

I dont understand y am getting the null pointer exception when the data exists in the context attribute(model node attribute)

Context Struct Cardinality , selection

Z_Get_Vbeln_Input(Parent model node) 0..1 0..1

-


List_Vbeln(Child node) 0..n 0..1

-


Vbeln(Attribute)

My code :

IWDAttributeInfo attributeinfo = wdContext.getNodeInfo().getAttribute("Vbeln");

ISimpleTypeModifiable simpletype = attributeinfo.getModifiableSimpleType();

IModifiableSimpleValueSet valueSet = simpletype.getSVServices().getModifiableSimpleValueSet();

int size = wdContext.nodeList_Vbeln().size();

for (int i = 0; i < size ; i++)

{

String Vbeln = String.valueOf(wdContext.nodeZ_Get_Vbeln_Input().nodeList_Vbeln().getElementAt(1).getAttributeValue("Vbeln"));

valueSet.put(Vbeln,Vbeln);

}

Could you please check the above code whether there is any mistake...

Is simple type required when importing data from model....?

Regards

Sireesha.

Former Member
0 Kudos

Hi,

Check that attributeinfo is not null before exacuting this line (if(attributeinfo !=null)).

If attributeinfo is null. check attribute name. Is it context attribute? If its inside node then use:

wdContext.node<nodename>().getNodeInfo().getAttribute("Vbeln");

Regards,

Apurva

Former Member
0 Kudos

Hi,

Z_Get_Vbeln_Input(Parent model node) 0..1 0..1

-


List_Vbeln(Child node) 0..n 0..1

-


Vbeln(Attribute)

My code :

IWDAttributeInfo attributeinfo = wdContext.getNodeInfo().getAttribute("Vbeln");

Change your code as follows

IWDAttributeInfo attributeinfo = wdContext.nodeList_Vbeln().getAttribute("Vbeln");

Regards

Ayyapparaj

Former Member
0 Kudos

Hi ayyapparaj and apurva,

After changing it to the below code Am not getting the null pointer exception now.

IWDAttributeInfo attributeinfo = wdContext.nodeList_Vbeln().getNodeInfo().getAttribute("Vbeln");

But i have checked the node size with the code int size = wdContext.nodeList_Vbeln().size(); The value its displaying is 0 . Hence values r not populating into the dropdown.

I have treid with the below combinations...

wdContext.nodeList_Vbeln().size(); (returns 0)

wdContext.nodeZ_Get_Vbeln_Input().size(); (returns 1)

wdContext.nodeZ_Get_Vbeln_Input().nodeList_Vbeln().size() ( returns 0)

Actually my RFC returns 500 entries in a table. Is that would be a problem to get the node size?

Guide me ...

Regards

Sireesha.

Former Member
0 Kudos

Hi,

Did you execute the model?

Can you post the entire context structure.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi ayyapparaj,

Do u mean executing the RFC ?

I have executed the RFC from the backend. Its working fine. Getting the values in the table. Nearly there are 900 entries in the output table.

As of now my component controller has only one model node which is given below.

Z_Get_Vbeln_Input(Parent model node) 0..1(Cardinality) , 0..1(selection)

-


List_Vbeln(Child node) 0..n (cardi) , 0..1 (selection)

-


Vbeln(Attribute)

Main Properties of dropdown by key UI elemnt.

id - DropDownByKey_sales

enabled - true

readonly - false

selected key - Z_Get_Vbeln_Input.List_Vbeln.Vbeln

Regards

Sireesha.

Former Member
0 Kudos

Hi,

You need to execute this RFC from Webdynpro to get the values populated to the node.

Regards

Ayyapparaj

Former Member
0 Kudos

Ayyapparaj,

ya. I have executed it in the wd controller. This is the code in the Init() method of component controller.

wdContext.nodeZ_Get_Vbeln_Input().bind(new Z_Get_Vbeln_Input());

wdThis.executeZ_Get_Vbeln_Input();

Any idea why the node size is null? or am i missing anything?

Regards

Sireesha.

Saravanan_SD
Advisor
Advisor
0 Kudos

Hi Sireesha,

Please check the following.

1. If the RFC has any input parameters, make sure to set the values (Some parameters would be case sensitive).

Then call the executeZ_Get_Vbeln_Input method.

2. In the executeZ_Get_Vbeln_Input method, did you implement code for executing the RFC.

 
i.e . wdContext.currentZ_Get_Vbeln_Input().modelobject().execute();

3. After executing the RFC, check if the node values are populated in the output node of the RFC.

Make sure you access the correct output node for the 900 entries.

4. Check if the user which you are using in Portal has access in the R/3 to execute the RFC.

Hope it helps.

Regards,

Saravanan

Former Member
0 Kudos

Hi,

Check the mapping between model node & model.

And if nothing works, ask ABAPer to switch on remote debugging.

By this, debugging will be activated in the R/3 and ABAPer will be able to check data passed to the RFC and RFC result.

Regards,

Apurva

Former Member
0 Kudos

Hi,

you have any specific reason to use DropDownByKey here.

as ayyapparaj said it is easy to use DropDownByIndex.

just you have to bind the attribute to its texts property.

Regards,

ramesh

Former Member
0 Kudos

Hi,

Why not use the drop down by index?

Regards

Ayyapparaj