Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Date & Time

zayidu
Participant
0 Likes
1,520

Hi experts,

I need to Print the current date and time in this format:

DD-MMM-YYYY -- HH:MM

DD = day

MMM = three character month abbreviation

YYYY = four digit year

HH = hour

MM = minute

8 REPLIES 8
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,472

Which print technology? Word, Excel, PDF, ink printing?

Read only

0 Likes
1,472

Smartforms

Read only

loyd_enochs3
Participant
0 Likes
1,472

You could use function module MONTH_NAMES_GET to decode the 2-digit month to 3-character month and just concatenate the date/time string together.

Loyd

Read only

0 Likes
1,472

Hi loyd,

Final output should be in smartforms.... Can you please explain for this case....

Thanks

Read only

0 Likes
1,472

Texts are based on SAPscript technology, so you may use Formatting Date Fields: SET DATE MASK - BC Style and Form Maintenance - SAP Library

Read only

raghug
Active Contributor
0 Likes
1,472

cl_abap_datfm and cl_abap_timfm will help with the rest of the formatting. Then use the MONTH_NAMES_GET and replace the month portion.

Read only

loyd_enochs3
Participant
0 Likes
1,472

Or you could go crazy and do something like this:

DATA: BEGIN OF o_date,
        dd     TYPE numc2,
        dash1  TYPE char01 VALUE '-',
        mon    TYPE char03,
        dash2  TYPE char01 VALUE '-',
        year   TYPE char04,
        fill01 TYPE char02 VALUE ' -',
        fill02 type char02 value '- ',
        hh     TYPE char02,
        colon  TYPE char01 VALUE ':',
        mm     TYPE char02,
      END OF o_date.

DATA: BEGIN OF my_datum,
        year TYPE char04,
        mm   TYPE char02,
        dd   TYPE char02,
      END OF my_datum.

DATA: BEGIN OF my_timlo,
        hh TYPE char02,
        mm TYPE char02,
        ss TYPE char02,
      END OF my_timlo.

MOVE:               sy-datum   TO my_datum,
                    sy-timlo   TO my_timlo.
MOVE-CORRESPONDING: my_datum   TO o_date,
                    my_timlo   to o_date.

SELECT SINGLE ktx FROM t247
  INTO o_date-mon
  WHERE mnr = my_datum-mm.

WRITE: / o_date.

Read only

former_member196331
Active Contributor
0 Likes
1,472

Use below function module .

CONVERSION_EXIT_SDATE_OUTPUT

Input is sy-datum present date  '20160920'.

Save it in String.

Next get Hours and minutes from  sy-uzeit Then concatenate into the Sams string.

then display it into the Text of the Smart form