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

How to convert string format ?

1190_5939_439
Active Participant
0 Likes
2,381

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
Read only

sergey_muratov
Participant
0 Likes
2,181

Hi!

Take a look at WRITE statement

Read only

Read only

FredericGirod
Active Contributor
2,181

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

something like that ?

Read only

2,181

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'.
Read only

2,181

nice trick sandra.rossi

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,181

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).

Read only

0 Likes
2,181

useful information.