cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the default date behavior

Former Member
0 Kudos
310

Hi,

I am using type date in inputfield.In F4 help i am getting thecalender.Now my calender is behaving based on the SAP user date settings.How can i override the user setting date to my F4 calender.Is there any options to specify the date format as mm/dd/yyyy to calender attributes.

Regards

USman

Accepted Solutions (1)

Accepted Solutions (1)

lisa_miller3
Participant
0 Kudos

USman,

Have you tried converting the date to your mm/dd/yyyy format before it is

sent back to the screen?

HTML:

<htmlb:inputField id       = "startDate"
            type           = "date"
            required       = "false"
            size           = "7"
            maxlength      = "10"
            firstDayOfWeek = "0"
            showHelp       = "X"
            value          = "<%= model-sdate %>" />

-


DO_HANDLE_EVENT:

....

inputfield ?= CL_HTMLB_MANAGER=>GET_DATA(
        request = runtime->server->request
        name    = 'inputfield'
        id      = 'startDate' ).

    IF inputfield->value IS NOT INITIAL.
      call method model->convert_to_sap_date
        EXPORTING
          in_date  = inputfield->value
        IMPORTING
          out_date = model->sdate.
        IF model->sdate IS INITIAL.
           me->messages->add_message(
               condition = 'start'
               message   = 'Start Date is invalid'
               severity  = me->messages->CO_SEVERITY_ERROR ).
        ENDIF.
    ELSE.
      me->messages->add_message(
           condition = 'start'
           message   = 'Start Date is required'
           severity  = me->messages->CO_SEVERITY_ERROR ).
    ENDIF.
    ....

-


method CONVERT_TO_SAP_DATE .

  CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
    EXPORTING
      DATE_EXTERNAL            = in_date
    IMPORTING
      DATE_INTERNAL            = out_date
    EXCEPTIONS
      DATE_EXTERNAL_IS_INVALID = 1
      OTHERS                   = 2.

endmethod.

Former Member
0 Kudos

Hi Lisa,

thanks for your reply

I am already convering into internal date format.But here my question is not converting.when i am selecting the date in calendar it is showing the date in SAP suer setting date format.But i want whenever the user selects the date in calendar it has to come in mm/dd/yyyy format whatever the SAP user setting.How can i set the behavior at htmlb controller level.

Regards

Usman

lisa_miller3
Participant
0 Kudos

Usman,

I assume you are referring to clicking the calendar icon, then selecting a date from the pop-up calendar, at which point the selected date is pulled back into the date input field for display. My test date already comes back in the format MM/DD/YYYY - so I am guessing that there is a default date format defined somewhere in SAP which is being used. My date field is defined as DATS length 8 in the Data Dictionary. Hope this helps.

Lisa

Former Member
0 Kudos

Hi Usman,

Even my date setting is mm/dd/yyyy. So i am not aware of your date format id.

Right click on your application and goto View Source.

In the HTML code search for 'dateformat:'.

Let us assume you get dateformat:1 for dd/mm/yyyy

Add the following code in your application to change the format id to 2

<bsp:findAndReplace find="dateformat:1"

replace="dateformat:2"

>

<htmlb:content design="DESIGN2003" >

.

.

.

.

.

</htmlb:content>

</bsp:findAndReplace>

Regards,

Alwyn

Former Member
0 Kudos

Hi lisa

Exactly this is the problem.Now i want to keep date format in BSP application end as it is mm/dd/yyyy format, whatever be the user sap date format settings.Is there anyway to do.

regrards

Usman

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Usman,

Then u can use a javascript date picker if u dont like the sap date picker.

The are lots of datepickers available, select the one u like.

refer the one @

http://javascript.internet.com/calendars/date-picker.html

http://www.javascriptkit.com/script/script2/timestamp.shtml

regards,

Venkatesh

Message was edited by: venkateshwarlu yelagandula

Former Member
0 Kudos

Hi venkatesh,

But i don't want to go for javascript.By using HTMLB controls only using type date ,how can i set the default behavior at every time in mm/dd/yyyy format in input field.

here is code how i am using calender

<b><htmlb:inputField id = "DFCREATED"

type = "DATE"

showHelp = "TRUE"

design = "standard"

size = "10" /></b> regards

Usman