cancel
Showing results for 
Search instead for 
Did you mean: 

Date Field

Former Member
0 Kudos

Hello All.

I am designing a page where the date should be made available in a selection drop down which has a calendar from where the user could select the date. Right now I am able to get the whole calendar.

regards,

SampathKumar G.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

In order to show the dates in dropdown first you need to have clear requriement as Howmany months/dates can be shown. Do you want to show dates of 1particular year/current year...

Showing the calendar values in the dropdown is not a good design as the dropdown values can be too long. To select a value from dropdown looks cumbersome, not feasible to select the values.

You need to restirct the dates to be shown in the dropdown depending on the requirment.

How about using a date navigator UI element.

Regards,

Lekha.

Former Member
0 Kudos

Hello Lekha.

Thanks for the help.

I got it done using UI elements.

What is the best option in order to get the selected value ?

regards,

SampathKumar G

Former Member
0 Kudos

Hello Lekha.

If the user selects a date in the UI then a grid which below that has to be filled with data pertaining to the date selected.

How can I achieve this?

Regards,

SampathKumar.

Former Member
0 Kudos

Hi,

Can you be more clear.

What UI elment you have used.

Regards,

Lekha.

Former Member
0 Kudos

Hi.

I have used a Input Field. In the value property of the field I have assigned an attribute of dats type.

Now if I select a date, values pertaining to that particular date alone has to be made visible in a grid which is in the same page.

Regards,

SampathKumar G.

Former Member
0 Kudos

Hi,

You can use the WDCONTEXT->get_attribute( 'DATE' )-if attribute is bound directly to root node) so that you can get the value or use the code wizard and read the attribute.

Based on this value disbale the fields/values as per your requirement.

Are you showing data based on this given date. What are the other UI elements are you using .

Regards,

Lekha.

Former Member
0 Kudos

Hi.

I am using a grid.

The grid holds the data that are related to a particular date.

Regards,

SampathKumar G.

Former Member
0 Kudos

Hi,

Is this grid a Table or ALV table.

what you want to show in the grid. I mean based on the Input date you want to show entries related to that date only. Is that right.

Are you using the select statement or any FM to get the data into gird.

Regards,

Lekha.

Former Member
0 Kudos

Hi.

The grid is a table.

Yeah i am just showing data related to the date in the table.

I am using select statement.

Can I have your ID if you dont mind.

Regards,

SampathKumar.

uday_gubbala2
Active Contributor
0 Kudos

Hi Sampath,

This seems to be a simple task. Let me try to say what I understood about your task. You have an input field on your screen which accepts a date from the user. You want to read the date entered by the user and displayed the corresponding data in the table below. Right?

Something like the user enters FLDATE in the input field and you want to display all SFLIGHT information where FLDATE = <your input> Is this the case?

If yes then you just bind your input field to an context attribute of type date. Place a button up on pressing which you want the value in the input field to be read & the table to be populated.

ex: I have 2 context nodes INPUT & SFLIGHT. INPUT has a cardinality of 1..1 and has just 1 context attribute DATE of type SYDATUM under it. The node SFLIGHT has a cardinality of 0..n and has CARRID, CONNID, FLDATE & PRICE as attributes under it.

Now I placed an input field on my layout and bound its "value" property to the context attribute DATE. I place a table and create a data binding with the context node SFLIGHT. I have a push button up on pressing which I want to read the date entered by the user & populate my table. I associate an eventhandler FETCH_DATA with the onAction event of my table. Below is the coding within my event handler:

METHOD onactionfetch_data .
  DATA: wd_node TYPE REF TO if_wd_context_node,
        lt_sflight TYPE wd_this->elements_sflight,
        lv_date TYPE wd_this->element_input-date.
  wd_node = wd_context->get_child_node( name = 'INPUT' ).
  wd_node->get_attribute( EXPORTING name  = 'DATE'
                          IMPORTING value = lv_date ).

  wd_node = wd_context->get_child_node( name = 'SFLIGHT' ).
  SELECT carrid
         connid
         fldate
         price FROM sflight INTO TABLE lt_sflight WHERE fldate = lv_date.
  wd_node->bind_table( new_items = lt_sflight ).
ENDMETHOD.

Now when the user enters a date and presses on the push button the SELECT gets executed & fill the table with any rows that it might match. Please note that in order to keep the example simple I am not handling any special cases like the user pressing the push button without entering any date, the user entering an invalid date format, no flights existing in SFLIGHT with the date entered by the user...

You would have to consider all such cases and use throw out relevant messages to the user.

Regards,

Uday

Former Member
0 Kudos

Hi,

Check the UDAY's reply it meets your requirement.

One more thing, SELECT statements should not be written directly in the UI coding. For practice you can do it but it is against the MVC pattern.

Regards,

Lekha.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi All.

Thanks for the response.