cancel
Showing results for 
Search instead for 
Did you mean: 

Filling a drop down with months

Former Member
0 Kudos

Hello All.

I want to fill a drop down by index with months and another one with years.

How to achieve this.

Regards,

SampathKumar.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks All for Your Response.

Former Member
0 Kudos

Hi,

Creating dropdownbyindex is very simple and here are the steps for the same

1. Create two context nodes MONTHS, YEARS with cardinality 0:N or 1:N

2. Create a context attribute in each node type STRING for months & type INT for years.

2. Create two DROPDOWNBYINDEX UI elements, and bind the above context nodes correspondingly

3. Now fill the context node with required values using below code.

DATA: node_months   TYPE REF TO if_wd_context_node,
      stru_months   TYPE if_main=>element_months,
      lt_months   TYPE if_main=>elements_months.

node_months = wd_context->get_child_node( name = 'MONTHS' ).

*prepare the values for dropdown
do 12 times.
   stru_months-attr =  'MONTH_NAME' "maintain month name here
   append stru_months to lt_months.
enddo.

*bind the values to dropdown.
node_months->bind_elements( it_months ).

Repeat the same steps for years too.

By default the lead selected entry(first element) will be shown as default entry in the dropdown and if you want to change this, change the lead selection index.

Regards,

Manne.

uday_gubbala2
Active Contributor
0 Kudos

As a reference you can try go through this [free sample version|http://www.sap-press.de/download/dateien/1079/sappress_web_dynpro_for_abap.pdf] of Ulli Hoffman's textbook Web Dynpro For ABAP. Go through section 3.3.1 "Using Dropdown Lists".

You can also go through the standard Web Dynpro Component DEMO_VARIABLE_DROPDOWN. Here the column URL has its cell editor as an DropDownByIndex. You can go through the coding inside the associated supply function S_TABLE_SOURCE to understand how he is filling the dropdown with values. Hope that this helps resolve your problem.

Regards,

Uday

Former Member
0 Kudos

HI,

data:
ls_valueset type WDR_CONTEXT_ATTR_VALUE,
lt_valuest type wdr_context_atrr_value_list.

*Months
do 12 times.

ls_valueset-text = sy-index.
ls_valueset-value = sy-index.

append ls_valueset to lt_valueset.
clear ls_valueset.
enddo.

Like wise fill for years and bind tthis table to node and map this node to DRPBYINDEX.

Regards,

Lekha.

uday_gubbala2
Active Contributor
0 Kudos

Hi Sampath,

I have a node by name TEXT_DESIGNS which contains 2 attributes KEY & VALUE. I am binding the texts property of my DropDownByIndex to the attribute VALUE. The attribute KEY is bound to the design property of a Label which I have on my layout. So the design of the label changes corresponding to the option I choose from my DropDownByIndex.

METHOD supply_text_designs.
DATA ls_text_design TYPE if_v_default=>element_text_designs.
DATA lt_text_designs TYPE if_v_default=>elements_text_designs.

*----- Create value key list of different text designs
ls_text_design-key = cl_wd_text_view=>e_design-emphasized.
ls_text_design-value = 'emphasized'.
APPEND ls_text_design TO lt_text_designs.

ls_text_design-key = cl_wd_text_view=>e_design-header1.
ls_text_design-value = 'header1'.
APPEND ls_text_design TO lt_text_designs.

ls_text_design-key = cl_wd_text_view=>e_design-header2.
ls_text_design-value = 'header2'.
APPEND ls_text_design TO lt_text_designs.

ls_text_design-key = cl_wd_text_view=>e_design-header3.
ls_text_design-value = 'header3'.
APPEND ls_text_design TO lt_text_designs.

*----- Fill context node TEXT_DESIGNS
node->bind_table( new_items = lt_text_designs ).
ENDMETHOD.

You can use the similar approach to fill your DropDown with values.

Regards,

Uday