cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down values for table in a view not getting populated dynamically

0 Kudos

Hi Experts,

The problem which i am facing is as follows

In an existing web dynpro component , i already have a view and it consists of table which has 3 columns.All the three columns are non editable

MATERIAL MAT_DESC MAT_DEL_FLAG

ABC

EFG

HIJ

Now i need to add 2 more columns after the MAT_DEL_FLAG.These two PLANt and STORAGE LOCATION columns must have drop down values

The context refers to a standard Database ZTABLE to which these two fields are added.

MATERIAL MAT_DESC MAT_DEL_FLAG PLANT STORAGE_LOCATION

ABC

EFG

HIJ

The Plant column must have the drop down values based on Material .

If we select some value for Plant , then based on the value of plant the storage location drop down values must be populated.

So as per this logic , the drop down values for plant for each row must be different.

Please let me know how to achieve this.

This is a normal table and not an ALV table.

Also please let me know whether the drop down field must be drop down by key or drop down by index.

This is very urgent.

Thanks in advance

Sindhu

Accepted Solutions (1)

Accepted Solutions (1)

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi

You need to use the table lead selection even.create an action and bind to the table lead selection.

When ever the user selected a row are highlightened row element data you need to capture the material.

Based on the material you must populate the Plant column dropdown dynamically.

Use OnSelect method of the plant and as per the selected plan value extract the details of storage location and populate the storage location drop down

You can user Drop down by key or index any thng.It is upto you .There may be a little difference in coding wise but the functionality and as well as the look and feel will be the same between the two categories of drop down.

Regards

KALYAN

0 Kudos

Hi Kalyan,

Thanks for your reply.

I tried the way you have mentioned.

 
  DATA: lo_node_info TYPE REF TO if_wd_context_node_info,
             lo_nd type ref to if_wd_context_node,
              lv_index type sy-index.

                lo_nd = wd_context->get_child_node( name = 'MARA_DET').
                lo_node_info = lo_nd->get_node_info( ).

                lv_index = lo_nd->get_lead_selection_index( ).

                Read table wd_assist->mara_det into lw_mara index lv_index.
                if sy-subrc eq 0.    
     
                 Loop at wd_assist->TAB_MARC  into lw_marc where matnr eq  lw_mara-matnr.
                        l_value-value = lw_marc-werks.
                       l_value-text = lw_marc-werks.
                     INSERT l_value INTO TABLE lt_valueset.
               endloop.
                     CALL METHOD lo_node_info->set_attribute_value_set( EXPORTING name =
                                 'WERKS'
                               value_set = lt_valueset
                                    ).

This sets the Drop down value for all the rows as the same .

Is this code correct or is there something wrong with this.

Please guide me.

Answers (2)

Answers (2)

Madhu2004
Active Contributor
0 Kudos

Hi Sindhu,

To achieve this you need to have a drop down by key and drop down by index in the table.

For plant field use Drop by key and for storage loction field use drop down by index.

Fro plant field popluate the values initially in the node using the SET_ATTRIBUTE_VALUE_SET method of the node info. Bind the attribute to the drop down by key field.

For storage location field have a sub node in the main node with attributes as SLOC and SLOC_DESC. In the onselect method of the plant, populate this node with the values using the same SET_ATTRIBUTE_VALUE_SET Method. Bind SLOC attribute of the sub node to the dropdown by indexs field.

Try this and it will definately work.

Regards,

Madhu

0 Kudos

Hi Madhu,

I tried the way you have mentioned for the Plant column.

The problem with this is the SET_ATTRIBUTE_VALUE_SET sets the same value of plant for all the rows, whereas in my case for each row of the table i.e. for each material , the plant drop down should be different.

Please let me know if there is any method which will set different values of plant for each row of the table.

I have also tried the approach mentioned by Venkat in the Thread , but the requirement says the user should click on the drop down and the values should be displayed. Hence I cannot use the approach suggessted by Venkat.

Thanks

Sindhu

Former Member
0 Kudos

Hi,

Go to the PLANT column, for cell editor either a dropbykey or index as per your deisgn, OnSelect or Onleadselect of that dropdown, create an action for it and write the code for it, you can use the code i have posted in my earlier replies....You will value selected or index selected in WDEVENT of that Event..based on this fill the valueset..for teh Storage location...

What is the status of your requirement...Till what you have achieved...

0 Kudos

Hi Lekha,

Thanks you so much for replying.

I tried the way you have mentioned by creating an event in at lead selection , drop down values are getting populated.

but bcos of the method SET_ATTRIBUTE_VALUE_SET , all the other rows have the same values.

When the user selects Row1 , thr drop down for plants for the material of row1 is popualted correctly, but the rows below it which the user has not selected , also has the plants of material 1 itself as the drop down.

So even if the user does not select the lead index, the other rows have the drop down populated.

This is the issue which i am facing now.

Is there any way to set the drop down only for only the row for which the user has clicked the lead index?

The end user wants all the rows to be open for editing , so i cannot go with the option of making the plant column editable only when the the lead index is selected.

Former Member
0 Kudos

Refreshing things again for you -

1. As I have already pointed, create 2 context attributes for VALUESETS for both plant and St.loc.

2. Create dropdown by indexes for both of them, assign valusets to respective attributes using node information.

3. Go to the plant dropdown and create the action for it ONSELECT event - when you chagne the dropdown of plant then populate the respective storage loc.

4.Now, As you are selecting a row (leadselect) you have populated the plant and loc details....write the code for lead selection event of the table

You will get the lead selection index right using node interface (IF_WD_CONTEXT_NODE)

LOOP AT ITAB INTO WA_ITAB.
if sy-tabix eq lv_lead_index.
clear wa_valuset.
wa_valueset-key = 'X'.   "plant
wa_valueset-value = 'X'.
append wa_valueset to it_valueset1.

* popultae the storage location valuset based on the plant selected (bydefault it is 1 right in dropdown)
clear wa_valuset.
wa_valueset-key = 'XX'.   "storage loc
wa_valueset-value = 'XY'.
append wa_valueset to it_valueset2.
else.
* Fill the valusets for all other rows as different or as per your requirement.

endif.
wa_itab-valuset1 = lt_valueset1.
wa_itab-valuset2 = lt_valueset2.
modify itab from wa_itab transporting valuset1 valuset2.
clear wa_itab.
ENDLOOP.
lo_node->bind_table ( it_tab).

Now for that Row, if a plant value is changed, respective storgae loc has to be filled right...then in that ONSELECT of plnat drodpwon again you need to write a piece of code...using the same code with a little modifications.

Hope this is clear.

Check this article on the same - but here ALV is used...the concept is same use it for your table -

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0cbdde3-fe58-2c10-fcbc-8db18e693...

the above code you hvae pasted - i think it fills only for the 1st time....

Regards,

Lekha.

Edited by: Lekha on Dec 20, 2011 12:00 PM

0 Kudos

Hey Guys,

Thanks for the help.

I took a combined approach based on the answers you had provided and issue is resolved.

I have awarded points to you.

Regards

Sindhu

Former Member
0 Kudos

Hi,

Please refer for my replies in this below thread on similar requirement -

Hope this meets your requirement.

Regards,

Lekha.

0 Kudos

Hi Lekha ,

Thanks for the reply.

I tried doing as you have mentioned by creating a context, but this gives the error as the already written code to populate the already existing 3 columns and the newly added plant (type werks) doesnt match with the context type WDR_CONTEXT_VALUE_ATTR_LIST.

Thanks again for the help

Sindhu

Former Member
0 Kudos

The additional columns should be a part of the node that is already bound to the TABLE UI element. You cannot create a sepearte context. Have you already created the attributes in that node...

0 Kudos

HI Lekha,

The existing node refers to a standard Z table which has the following structure

Material

Material Desc

Material Deletion flag

i added the Plant and Storage location

and when i tried to create a new attribute to that node , it allowed me to select plant and staorage location from that structure only.

Thanks

Former Member
0 Kudos

Have you modififed that structure in SE11 where by these fields are autimaticaly created/shown in the node..

Please clarify this

Edited by: Lekha on Dec 19, 2011 12:22 PM

0 Kudos

Hi Lekha ,

I have done that.

Former Member
0 Kudos

Is your requirement done...or still waiting for the inputs.

0 Kudos

Hi ,

I am still trying it.

Will update shortly the status

Former Member
0 Kudos

you have to create two attributes with that required type as VALUESET1 for WERKS and VALUESET2 for LGORT

Set the node information for thise attributes

First time, based on the value in the PLANT/WERKS need to popupalte the VALUESET2 field and bind the table to the node.

When ever the dropdown in PLANT changes the respective VALUESET for the LGORT needs to be p[opulated and bind the table again.

The code goes likes this -

LOOP AT ITAB into WA_ITAB.

clear ls_valueset1.
LS_VALUESE1-key = 'X'.
LS_VALUESE1-value = 'X'.
append LS_VALUESET1 to WA_ITAB-VALUESET1.  "plant

clear ls_valueset1.
LS_VALUESE1-key = 'XX'.
LS_VALUESE1-value = 'XX'.
append LS_VALUESET1 to WA_ITAB-VALUESET2. "Storage loc

clear ls_valueset1.
LS_VALUESE1-key = 'XY'.
LS_VALUESE1-value = 'XY'.
append LS_VALUESET1 to WA_ITAB-VALUESET2. "Storage Loc

clear ls_valueset1.
LS_VALUESE1-key = 'Y'.
LS_VALUESE1-value = 'Y'.
append LS_VALUESET1 to WA_ITAB-VALUESET1.  "Plant


clear ls_valueset1.
LS_VALUESE1-key = 'YY'.
LS_VALUESE1-value = 'YY'.
append LS_VALUESET1 to WA_ITAB-VALUESET2. "Storage loc

clear ls_valueset1.
LS_VALUESE1-key = 'YZ'.
LS_VALUESE1-value = 'YZ'.
append LS_VALUESET1 to WA_ITAB-VALUESET2. "Storage Loc


clear ls_valueset1.
LS_VALUESE1-key = 'Z'.
LS_VALUESE1-value = 'Z'.
append LS_VALUESET1 to WA_ITAB-VALUESET.


ENDLOOP.

Youcan still modify the code as per the performance. or write the single method to use it at both the places.

Regards,

Lekha.