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

CONCATENATE date and time into a text variable

Former Member
0 Likes
15,884

Hi ABAP Gurus,

I would like to retrieve current system date and time and concatenate into a variable. I would really appreciate if someone could help me. I have the following code and i seem to get some kind of error.

I would like my output to be like:

"22.JUN.2006 Some Text 12:30:22"

Code:

data: emtext like TEMSG-EMTEXT.

data: date_output(50) TYPE C.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'

EXPORTING

INPUT = SY-DATUM

IMPORTING

OUTPUT = date_output.

SHIFT date_output RIGHT DELETING TRAILING SPACE.

CONCATENATE date_output ': Some Custom Message '

INTO emtext.

Also, is there a function to convert time to text or conversion is not necessary?

Thanks.

Regards,

bw_newbie

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
5,087

Here is something a little closer to your requirement.



report zrich_0001 .

data: date(20) type c,
      time(10) type c,
      str type string.

data: xT247 type T247.

select Single * into xt247 from t247
          where MNR = sy-datum+4(2).

concatenate  sy-datum+6(2) xt247-ktx sy-datum(4)
          INTO date separated by '.'.

write sy-uzeit to time.

concatenate date 'SomeText' time into str separated by space.

write:/ str.

Regards,

Rich Heilman

Hi ABAP Gurus,

I would like to retrieve current system date and time and concatenate into a variable. I would really appreciate if someone could help me. I have the following code and i seem to get some kind of error.

I would like my output to be like:

"22.JUN.2006 Some Text 12:30:22"

Code:

data: emtext like TEMSG-EMTEXT.

data: date_output(50) TYPE C.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'

EXPORTING

INPUT = SY-DATUM

IMPORTING

OUTPUT = date_output.

SHIFT date_output RIGHT DELETING TRAILING SPACE.

CONCATENATE date_output ': Some Custom Message '

INTO emtext.

Also, is there a function to convert time to text or conversion is not necessary?

Thanks.

Regards,

bw_newbie

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
5,087

You can do something like this.




report zrich_0001 .

data: date(10) type c,
      time(10) type c,
      str type string.


write sy-datum to date.
write sy-uzeit to time.

concatenate date time into str separated by space.

write:/ str.

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
5,088

Here is something a little closer to your requirement.



report zrich_0001 .

data: date(20) type c,
      time(10) type c,
      str type string.

data: xT247 type T247.

select Single * into xt247 from t247
          where MNR = sy-datum+4(2).

concatenate  sy-datum+6(2) xt247-ktx sy-datum(4)
          INTO date separated by '.'.

write sy-uzeit to time.

concatenate date 'SomeText' time into str separated by space.

write:/ str.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
5,087

Hi Rich,

Thanks for the solution. I have assigned points.

Regards,

bw_newbie