cancel
Showing results for 
Search instead for 
Did you mean: 

how to implement a field of type Date + Time

Former Member
0 Kudos

Hi all :

I want to implement a field of type Date + time , for example 2008-12-12 12:30:00. for field of type Dats, we can select date via the standard function provided by sap, is there a similiar standard function for type Date + time?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

It would be good if you can create 2 different UI Input element one each for date and time.

For time you can bind it to data element of type TIMS.

Regards

Manas Dua

Former Member
0 Kudos

thank you very much for your reply, for the field of type DATS or TIMS, there would be cute button beside the input field for us to select the date or time.

Is there a similiar way for the type of date plus time , for example , 2008-12-12 12:00:00.

Former Member
0 Kudos

Hi Sony,

You can use the below code to get the output like this 2010:04:21 12:53:03

DATA: type TYPE STRING,

type1 TYPE STRING,

type2 TYPE STRING,

type3 TYPE STRING,

type4 TYPE STRING,

type5 TYPE STRING,

type6 TYPE STRING,

tims type sy-uzeit,

dats type sy-datum.

CALL FUNCTION 'OIL_GET_CURRENT_DATE_TIME'

EXPORTING

I_TZONE = 'INDIA'

IMPORTING

E_DATE = dats

E_TIME = tims.

CONCATENATE dats tims into type SEPARATED BY space.

type1 = type+0(4).

type2 = type+4(2).

type3 = type+6(2).

type4 = type+9(2).

type5 = type+11(2).

type6 = type+13(2).

clear type.

CONCATENATE type1 ':' type2 ':' type3 space

type4 ':' type5 ':' type6

into type.

data:

Elem_Context type ref to If_Wd_Context_Element,

Stru_Context type If_Test=>Element_Context ,

Item_TYPE like Stru_Context-TYPE.

  • get element via lead selection

Elem_Context = wd_Context->get_Element( ).

  • Set single attribute

Elem_Context->set_Attribute(

exporting

Name = `TYPE`

Value = Type ).

Hope it solves your problem.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Has you ever tried with the FM

CONVERSION_EXIT_PDATE_INPUT Conversion Exit for Domain GBDAT: DD/MM/YYYY -> YYYYMMDD

CONVERSION_EXIT_PDATE_OUTPUT Conversion Exit for Domain GBDAT: YYYYMMDD -> DD/MM/YYYY

CONVERT_DATE_FORMAT Convert date from yyyymmdd to ddmmyyyy format

and after concatenate this.

Former Member
0 Kudos

Hi,

You can create a input field of type char or string and set the date and time by using these FM's provided by SAP:

1) MSS_GET_SY_DATE_TIME

2) OIL_GET_CURRENT_DATE_TIME

There are many FM's provided by SAP to get the data and time.

or use below code to set the value in input field:

DATA type TYPE STRING.

CONCATENATE sy-datum sy-uzeit into type SEPARATED BY space.

WRITE TYPE.

Hope it helps you.