Skip to Content
avatar image
Former Member

how to implement a field of type Date + Time

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 21, 2010 at 05:29 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • avatar image
    Former Member
    Apr 21, 2010 at 05:32 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 21, 2010 at 04:21 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded