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

Replace: problem with zeros

Former Member
0 Likes
1,066

Hi to everybody

I have tihs values

31.800

0.300

2.100

I should to get this

31,800

00,300

02,100

I use REPLACE ALL OCCURRENCES OF '.' IN lt_itob-id1 WITH ',' it is ok

but I get an error if I use REPLACE ALL OCCURRENCES OF space IN lt_itob-id1 WITH '0' .

Could you help me?

Thanks a loto

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
994

Hi,

To Replace space with '0' use OVERLAY statement.


DATA: l_val TYPE char6 VALUE '0.300'.

REPLACE ALL OCCURRENCES OF '.' IN l_val WITH ',' .
SHIFT l_val RIGHT DELETING TRAILING space.

OVERLAY l_val WITH '000000'.
WRITE l_val.

Regards,

Farheen

6 REPLIES 6
Read only

Former Member
0 Likes
994

Hi

For pdding zeros in the begning use the following:

SHIFT RIGHT <variable> RIGHT DELETING TRAILING SPACE.

And for replacing '.' with ',', i think you will ahve to make use of IF loop and do this operation withn it.

Regards

Gaurav

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
994

Please be more clear .

Read only

Former Member
0 Likes
994

Hi,

I think you can use SHIFT statement as suggested. Press F1 on SHIFT.

Read only

Clemenss
Active Contributor
0 Likes
994

Hi Georgio,

unable to answer incomplete questions: ID1 is no field of DB view ITOB. Thus you should give the field technical settings here.

Post a few code lines on how you populate the field (Don't worry, CIA knows anyway)..

Then someone can answer your question.

Regards,

Clemens

Read only

Former Member
0 Likes
994

Hi ,

if the pattern of the variable in which u r taking value is constant,i.e if there are 3 values after decimal as shown in below code ,you can use below code.

DATA : l_local(6) TYPE c.

l_local = '0.300'.

concatenate '0' l_local into l_local.

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

Edited By

Tejaswini Khante

Read only

Former Member
0 Likes
995

Hi,

To Replace space with '0' use OVERLAY statement.


DATA: l_val TYPE char6 VALUE '0.300'.

REPLACE ALL OCCURRENCES OF '.' IN l_val WITH ',' .
SHIFT l_val RIGHT DELETING TRAILING space.

OVERLAY l_val WITH '000000'.
WRITE l_val.

Regards,

Farheen