Application Development 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: 

How to convert string format ?

1190_5939_439
Active Participant
0 Kudos

Hi Experts

The code is following


 erdat LIKE vbrp-erdat, 
 erzet LIKE vbrk-erzet, 

 send_date  type string,

 CONCATENATE gw_vbrk-erdat  gw_vbrk-erzet  into gw_send-send_date.

Now the string format is follwing
20211006094324

I hope I get following string format.
2021-10-06 10:00:00
Can you help me ? Thanks.

7 REPLIES 7

sergey_muratov
Participant
0 Kudos

Hi!

Take a look at WRITE statement

FredericGirod
Active Contributor

my_field = |{ my_date DATE = USER }{ my_time TIME=USER }|

something like that ?

Instead of DATE = USER, your String Template could use XSD = YES to always format in YYYY-MM-DD format, and it could be the same for the time format to avoid 12-hours formats.

DATA(date) = CONV d( '20211023' ).
DATA(time) = CONV t( '114800' ).
DATA(my_field) = |{ date XSD = YES } { time XSD = YES }|.
ASSERT my_field = '2021-10-23 11:48:00'.

nice trick sandra.rossi

Sandra_Rossi
Active Contributor
0 Kudos

It seems you frequently write blog posts in your own Web site to explain what you finally did, and you just post a link to refer to it. You did it repeatedly in your recent questions, I think you shouldn't, as per Engagement Rules "unacceptable content":

  • Content or comments primarily designed to drive traffic to, increase the search rankings of, generating revenue from, or gain any other personal benefit from a non-SAP site, product, or service.

Instead, include your answer here. Anyway, note that the answer in your blog post is using a non-released function module, and that's not the way to do it in SAP. Frederic answer is the way to do it, with String Templates (as per Horst link), by taking the user's date and time formats. Or you may choose specific date formats so that to always use the YYYY-MM-DD format (like COUNTRY or XSD option).

0 Kudos

useful information.