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

getting error in REPLACE ALL OCCURRENCES

Former Member
0 Likes
2,510

HI Gurus,     I need to change full stop with comma and i have used REPLACE ALL OCCURRENCES OF wa_overview-CATSHOURS '.' IN TEXT with ','. but its showing an error for '.'. Please let me know where i am doing wrong. Thanks Sankil

12 REPLIES 12
Read only

Arun_Prabhu_K
Active Contributor
0 Likes
2,033

Hi Sankil,

REPLACE ALL OCCURRENCES OF '.' in wa_overview-CATSHOURS with ','.

Regards.

Read only

andrewdiaz2000
Active Participant
0 Likes
2,033

Hi sankil,

wa_overview-CATSHOURS may is of type date. so it is not stored in db with , or . but you can go to SU01 and into default tab try to alter the date to display as in your desired format.

Hope it helps,

Andrew

Read only

chinni_adapa
Participant
0 Likes
2,033

Hi sankil,

whatever you write the syntax for REPLACE ALL OCCURRENCES is correct, but the problem is your field CATSHOURS is having the type as 'QUAN'. we can't use the type qunatity(QUAN) in the REPLACE ALL OCCUREANCES (Only use C,N, D, T, STRING).

for that store that value wa_overview-CATSHOURS into another variable of type string, and use the following syntax.

REPLACE ALL OCCURRENCES OF '.' IN lv_temp WITH ','.

The following simple code will gives you more explanation:

DATA lv_hours TYPE catshours VALUE '12.03'.

DATA lv_temp TYPE string.

lv_temp = lv_hours.

REPLACE ALL OCCURRENCES OF '.' IN lv_temp WITH ','.

WRITE lv_temp.

Regards,

Chinni

Read only

0 Likes
2,033

Thanks Chini Thanks for ur response...

Read only

0 Likes
2,033

Hi,   If I am going to set the country like   set country = 'DE', so the changes will done automatically or not means inplace of "." i will get "," or not in the output. Regards Sankil

Read only

Former Member
0 Likes
2,033

Hi,

you read documentation of REPLACE ALL statement by pressing F4, Or

refer below link

http://help.sap.com/abapdocu_70/en/ABAPREPLACE_IN_PATTERN.htm

Or

you can try below statement..

TRANSLATE wa_overview-CATSHOURS USING '.,'

i.e in above statement after 'using' first is full stop and second is comma.

Regards

Tejas

Read only

former_member209120
Active Contributor
0 Likes
2,033

Hi Sankil Pandya,

change you statement like this

REPLACE ALL OCCURRENCES OF  '.'  IN  wa_overview-CATSHOURS with ','.

For example see this...

DATA : var TYPE char20 VALUE 'R.a.m.e.s.h'.

REPLACE ALL OCCURRENCES OF '.' IN var WITH ','.

WRITE : / var.


Read only

0 Likes
2,033

Hello

What i understood from your question

is converting a date like 01.02.2013 into 01,02,2013?

am i right?

First the wa_overview-CATSHOURS will be like 20130201

so first convert that to 01.02.2013

then use the replace all occurences

to convert 01022013 into 01.02.2013

use onvert_date_to_external fm

Hope it helps

Read only

Former Member
0 Likes
2,033

Hi San,

"What ever you have the value just pass to the
"string variable then do the operation it will work fine.

DATA str type string VALUE 'akd.dfj.....'.

REPLACE ALL OCCURRENCES OF '.' in str WITH ','.

WRITE str.

Warm & Regards,

John.

Read only

venkateswaran_k
Active Contributor
0 Likes
2,033

Hi

Can you please show the value of wa_overview-CATSHOURS also your code.  And also show the exact error message.  Is it a dump? 

Read only

Former Member
0 Likes
2,033

This message was moderated.

Read only

Former Member
0 Likes
2,033

Hi Sankil,

If you are trying to do a format change, then I suggest not to use a replace statement. Instead you try to find a conversion function module, or use 'WRITE TO' statement with mask/currency/country passed according to your requirement.

Thanks.