cancel
Showing results for 
Search instead for 
Did you mean: 

Value of RFC in Dropdownbykey

Former Member
0 Kudos

Dear All,

I want to fill a Dtodownbykey UI with RFC value. Pl. help me in doing so.

Regards,

Prakash

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Prakash,

A small suggestion is to use DropDownByIndex. Then you just need to bind the 'texts' property to the required output attribute. When you call the RFC, the values will be automatically populated. You needn't write a single line of code.

If you are particular to use DDBK, then :

ISimpleTypeModifiable stmObj =(ISimpleTypeModifiable) wdThis.wdGetAPI().getContext().getModifiableTypeOf("<attribute bound to 'selectedKey' of DD>");

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

Now loop through the ouput node of the RFC & populate the valueset. eg:

IPrivate<view>.I<OutputNode>Element elmt;

for(int i=0;i<wdContext.nodeOuput().size();i++)

{

elmt = wdContext.nodeOutput().getOutputElementAt(i);

valueSet.put(elmt.get<attr>,elmt.get<attr>);

}

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Nibu,

I was using Dropdownbyindex earlier, but I am facing problem in getting the default value as blank. I am creating sales order entry form where taking input of line items in the table. In this case I am facing problem with Dropdownbyindex.

Can you pl suggest how you to do the above with dropdownbyindex.

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

For Dropdownbyindex:

You need to set selection property of your value node to "0..1" for this. And also write following line in init method of your view:

wdContext.node<node name>().setLeadSelection(-1);

Regards,

Bhavik

Former Member
0 Kudos

Hi Prakash,

Try inserting a blank element into the model node after the RFC call and then set the dropdown's lead selection to this element.

After calling the RFC, write these lines of code :

IPrivate<your_View>.I<your_node>Element elmt = wdContext.create<your_node>Element();

elmt.set<your drop down attrb>("");

or something like elmt.set<your drop down attrb>("Select a Value");

wdContext.node<your_node>().addElement(0,elmt);

wdContext.node<your_node>().setLeadSelection(0);

This will show a blank value in the dropdown for sure !

Best Regards,

Nibu.

Former Member
0 Kudos

Dear Nibu,

I am unable to find elmt.set<your drop down attrb>("");

I am getting only elmt.setAttributeValue() , not my dropdown attrib.

I am wrting this in wdDoInt() of View after invokong method of custom controller where RFC is called.

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

what is the attribute bound to your dropdown by Index's 'texts' property?

Can you paste your context structure here ?

Best Regards,

Nibu.

Former Member
0 Kudos

Dear Nibu,

The attibute bound with the text Property is,

Z_Websales_F4_Po_Input.Output_Po.Zpovalues.Zpo

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

Then after calling the RFC write these lines of code :

IPrivate<your_View>.IZpovaluesElement elmt;

elmt = wdContext.createZpovaluesElement();

elmt.setZpo("");

or something like elmt.setZpo("Select a Value");

wdContext.nodeZpovalues().addElement(0,elmt);

wdContext.nodeZpovalues().setLeadSelection(0);

Hope this helps,

Best Regards,

Nibu.

(Please consider awarding points for helpful answers

Former Member
0 Kudos

Hi Prakash,

You need not to do much for that. Just set its selection property to "0..1" and set its leade select to -1 in code. Thats it.

Have you tried with this?

Regards,

Bhavik

Former Member
0 Kudos

Dear Nibu,

I am getting following error,

The method createOut_MatElement

(Zsd_Websales_Material_Values) in the type IPrivateSOCreate.IContextNode is not applicable for the arguments () SOCreate.java

The Code is like this:

ISimpleTypeModifiable stmObj =(ISimpleTypeModifiable) wdThis.wdGetAPI().getContext().getModifiableTypeOf("Material");

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

IPrivateSOCreate.IOut_MatElement elmt;

elmt = wdContext.createOut_MatElement();

elmt.setMaterial("");

wdContext.nodeOut_Mat().addElement(0, elmt);

wdContext.nodeOut_Mat().setLeadSelection(0);

for (int i = 0; i < wdContext.nodeOut_Mat().size(); i++) {

elmt = wdContext.nodeOut_Mat().getOut_MatElementAt(i);

valueSet.put(elmt.getMaterial(), elmt.getMaterial());

}

The selectedKey : Out_Mat.Material

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

The error states that the method 'createOut_MatElement' requires a parameter of type 'Zsd_Websales_Material_Values'.

so replacing 'wdContext.createOut_MatElement();' by wdContext.createOut_MatElement(new Zsd_Websales_Material_Values());' should work provided it has an empty constructor. Please try this out and post your result here.

But your code does have other problems too. Please elaborate on your requirement:

1) Do you want to show this dropdown inside a table?

2) If so, please provide the complete structure of the output node.

3) Specify what data is to be shown in other columns of the table as well. I am sking you this because now in you are trying to create a dropdown directly from an ouput node attribute.

For this just binding the DropDownByIndex's 'texts' property to that attribute should work. But your case seems to be something different. So please provide the complete requirement & we might be able to provide you the correct solution.

Best Regards,

Nibu.

Former Member
0 Kudos

Dear Nibu,

I am creating a Sales Order Entry Form, where I need Sales Order Item Entry in the tabular format. Now in that table I have five column, inwhich one is of Material where I need to provide Dropdown for Value list. Here the problems come, when I am using Dropdonbyindex I need to bind the Table Datasource property with Output Material node and the Text Property of lstMat dropdown with the context element. I need only input for 5 Sales Item record so number of row only 5, now if the Material node have let say 10 record it will set the Item table with 10 records.

Other problem is that when I select a value from the first row all row get filled with the same proble.

Sorry for the bothering you with a long explanation,this is my first live scenario in webDynpro.

Regards,

Prakas

Former Member
0 Kudos

Hi Prakash,

So from where does the dropdown data come from?

Say your Out_Mat node has a structure like :

- Out_Mat

.Attr1

.Attr2

.Material

.Attr3

So you need to display this data in a table & provide a dropdown too. You have bound the selectedkey of the dropdown to 'Material'. What is the data type of 'Material'. Is it returning a list? Only if it holds multiple values, you can display those data in the dropdown. I hope you are getting what I'm trying to convey???

And, about bothering me, when you 'bother' me, I'm learning a lot for myself too :). So keep on bothering me

Best Regards,

Nibu.

Former Member
0 Kudos

Dear Nibu,

Thanks for the quick reply, the data of dropdowm is coming from RFC , model node Out_Mat has only one attribute i.e. Material and in RFC its data type is Text50(Combination of Material No & Name). Right now I am using Dropdownbyindex and the Text Property of lstMat is Out_Mat.Material and the Data Source Property of TableItem is Out_Mat.

I need only 5 Input row in the table. this is the scenario , now suggest the best way. Pl. let me know if any more information required.

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

One more question - Where does the rest of the data in the table come from? Please paste your context structure here. Do you mean to say that you dropdown comes from RFC & the rest of the data is in an indepenedent value node?

To have just 5 rows, create only 5 elements for the node(i.e if you are explicitly creating it). Can you provide a clearer picture?

Best Regards,

Nibu.

Former Member
0 Kudos

Dear Nibu,

The structure of the table is like this:

Sl No. | Material | Quantity | Unit Of meas. | Amount| Delivery Date |

-


I need to take input from the user on all these colunn, only I need to provide value list in Material Column.

Right now I am using like this:

Sl No : - Row No of the table (text view)

Material No: - Dropdownbyindex

Quantity : Inputfield,

Unit Of measure : Dropdownbykey ( Mapped with context attribute of Simple data type)

Amount : Textview (Autocalculated later)

Delivery Date : Inputfiled (Data type Date getting dropdown for datepicker)

So in my case I need o fill only Material from the Data of RFC. That also for giving value help to user.

Pl. let me know if you want to any more informaion.

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

If you need to use DropDownByIndex in this case, you need to make use of a non-singleton node inside the table node. So, I feel it would be simpler if you use DropDownByKey.

Inside the node bound to your table (let's call this node 'table_node'), create an attribute of type 'String' (let's call this attribute 'mat_attribute');

Bind the DropDownByKey's 'selectedKey' property to this attribute.

Now after calling the RFC, write the following lines of code to populate this attribute with the RFC data:

final IModifiableSimpleValueSet ValueSet = wdContext.getNodeInfo().getChild("table_node").getAttribute("mat_attribute").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

for (int i = 0; i < wdContext.nodeOut_Mat().size(); i++) {

elmt = wdContext.nodeOut_Mat().getOut_MatElementAt(i);

valueSet.put(elmt.getMaterial(), elmt.getMaterial());

}

Now create the required five elements of the table node like:

IPrivate<view>.ITable_node tab_elmt;

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

{

tab_elmt = wdContext.createTable_nodeElement();

tab_elmt.setSl_No(i+1);

.

.

wdContext.nodeTable_node().addElement(tab_elmt);

}

These lines of code should work for you !

Hope this helps,

Best Regards,

Nibu.

}

Former Member
0 Kudos

Thanks Nibu. Perfect solution.

Regards,

Prakash

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Prakash,

check following link for the same:

http://help.sap.com/saphelp_nw04/helpdata/en/b3/f68e4ab25d7549888eb612bcb359f1/content.htm

Regards,

Bhavik