cancel
Showing results for 
Search instead for 
Did you mean: 

Display Date and Time in Dropdown

Former Member
0 Kudos

Hi All,

I need to display date and time in a dropdown. Can someone help me with this ?

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

saket_abhyankar
Active Participant
0 Kudos

Hi

1) If you want to display date & time in dropdown, insert 2 DropDownByKey UI elements on the screen

2) Map them with Context aatribute

3) write following code in the wdinit method of the view

DATA NODE_INFO type ref to IF_WD_CONTEXT_NODE_INFO.

NODE_INFO = WD_CONTEXT->GET_NODE_INFO( ).

NODE_INFO = NODE_INFO->GET_CHILD_NODE( name = `NODE WHICH CONTAILS ATTRIBUTE` ).

DATA: t_valueset type WDR_CONTEXT_ATTR_VALUE_LIST,

t_value type WDR_CONTEXT_ATTR_VALUE.

  • INSERT THE VALUES YOU WANT TO DISPLAY IN THE TABLE t_valueset USING LOOP-ENDLOOP * OR DO-ENDDO

  • eg. -

loop at stru_it_rake_dtls.

t_value-VALUE = "VALUE TO BE DISPLAYED.

t_value-TEXT = "TEXT OF THE VALUE.

INSERT t_value into table t_valueset.

endloop.

NODE_INFO->SET_ATTRIBUTE_VALUE_SET(

NAME = `NAME OF THE ATTRIBUTE YOU WANT TO DISPLAY`

VALUE_SET = t_valueset ).

*Repeat the same procedure for both UI elements

Former Member
0 Kudos

I need to display both time and date in the same dropdown.

I have found that Date can be displayed by specifying a context attribute of type dats and binding the UI element to it.

Is there any way to extend this dropdown to include time as well ?

Thanks

pranav_nagpal2
Contributor
0 Kudos

Hi,

you wont be able to display both time and date in different format in same drop down....

you have to keep the type of the attribute to string and you have to convert both time and date to string type before appending it to internal table which you will bind with your drop down...

regards

pranav

Former Member
0 Kudos

Can you give a detailed explanation of how to do this ?

Will the user be able to select a date and time from the dropdown ?

pranav_nagpal2
Contributor
0 Kudos

Hi,

The method to fill drop down has been given by Saket what you have to do is...

first convert date to string type using below code..

DATA : v_date type dats, 
           output_date_string(10) type c . 
 
v_date = sy-datum . 
 
write v_date to output_date_string .

now similarly convert time in string format....

DATA: node_info TYPE REF TO if_wd_context_node_info,
        value     TYPE wdy_key_value,
        value_set TYPE wdy_key_value_table.


  CLEAR value_set.
  node_info = wd_context->get_node_info( ).
  node_info = node_info->get_child_node( `CN_TABLE` ).
.

    value-key   = "date_key". " give key for date here
    value-value = output_date_string  .
    INSERT value INTO TABLE value_set.

similarly insert for time
    value-key   = "time_key". " give key for time here
    value-value = output_time_string  .
    INSERT value INTO TABLE value_set.

* Setting the corresponding attribute value

  node_info->set_attribute_value_set( name      = `CA_attr`
                                      value_set = value_set ).

above code is for drop down by key....

regards

Pranav

pranav_nagpal2
Contributor
0 Kudos

Hi,

yes you can display date and time in a drop down... it is simple like displaying any thing in drop down....

regards

Pranav