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

Hi expert. replace . with space

Former Member
0 Likes
842

HI expert.

I want to replace '.' with space . so I proceed below.

itab is composed to two feilds.

date1 type char10

date2 type char10

the field's values are '2011.01.01'.

REPLACE ALL OCCURRENCES OF REGEX '\b(.)\b'

IN TABLE ITAB WITH SPACE

RESPECTING CASE.

result.

date1 : '2011010120'

date2 : '110101'

but I want the result below.

date1 : '20110101'

date2 : '20110101'

what should i do?

please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
802

Hi,

As u mention ur date is 2011.01.01 u want to make it as 20110101 as use the FM CONVERT_DATE_TO_INTERNAL.

REGARDS,

ZAFAR

HI expert.

I want to replace '.' with space . so I proceed below.

itab is composed to two feilds.

date1 type char10

date2 type char10

the field's values are '2011.01.01'.

REPLACE ALL OCCURRENCES OF REGEX '\b(.)\b'

IN TABLE ITAB WITH SPACE

RESPECTING CASE.

result.

date1 : '2011010120'

date2 : '110101'

but I want the result below.

date1 : '20110101'

date2 : '20110101'

what should i do?

please help.

5 REPLIES 5
Read only

Former Member
0 Likes
803

Hi,

As u mention ur date is 2011.01.01 u want to make it as 20110101 as use the FM CONVERT_DATE_TO_INTERNAL.

REGARDS,

ZAFAR

Read only

0 Likes
802

BUT there are so many data in the table.

Read only

0 Likes
802

Check with separted by word

Read only

0 Likes
802

Hi Jake,

Using convert date to internal as mentioned by Zafar is a good idea, i don't see how this concerns the no of records, do update the post if you have a special requirement/concerns about using that FM.

Anyways the other way to do it using the offsets,


data: l_data type char10 value '2011.01.01',
l_date2 type char10.

concatenate l_data+0(4)  l_data+5(2) l_data+8(2) into l_date2.

or 

l_date2+0(4) = l_data+0(4).
l_date2+8(2) = l_data++5(2).
l_date2+8(2) = l_data+8(2).

Regards,

Chen

Read only

ravi_lanjewar
Contributor
0 Likes
802

Try this.


data: l_data type char10 value '2011.01.01',
l_date2 type char10.

concatenate l_data+0(4)  l_data+5(2) l_data+8(2) into l_date2 sepArated by space.

write l_date2.