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

String operation

Former Member
0 Likes
542

Hi experts,

Here is my question.

Consider i have a variable

data : a(15).

and

a = '24.000.000,00'.

i want to make it like

000024000000,00

deleting '.' and adding '0' completing 15 characters. The number has 2 decimal places o it is stable. But it can be any number. like 240,00 or 24.000,00 or lot more than that.

Thanks in advance

Full points will be rewarded

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
523

hi,

you can code like this:

TRANSLATE string USING '. '.
CONDENSE string NO-GAPS.
SHIFT string RIGHT DELETING TRAILING space.
TRANSLATE string USING ' 0'.

hope this helps

ec

5 REPLIES 5
Read only

Former Member
0 Likes
523

you ca use

REPLACE ALL OCCURENCES OF '.' IN a WITH space.

CONDENSE a.

CALL FUINCTION 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = a

importing

output = a.

Read only

JozsefSzikszai
Active Contributor
0 Likes
524

hi,

you can code like this:

TRANSLATE string USING '. '.
CONDENSE string NO-GAPS.
SHIFT string RIGHT DELETING TRAILING space.
TRANSLATE string USING ' 0'.

hope this helps

ec

Read only

Former Member
0 Likes
523

hiiii

i think for adding leading zeros you can use folllowing FM.Try using this.use proper length that you want for target variable & its data type should be I.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = w_matnr
          IMPORTING
            output = w_matnr.

regards

twinkal

Read only

Former Member
0 Likes
523

hi,

You may try.

Replace ALL occurances of '.' with SAPCE into w_string.

Condense w_string no-gaps.

shift Right w_string.

replace ALL occurance of SPACE with '0' into w_string.

Regards

Sumit Agarwal

Read only

0 Likes
523

Hi,

have a look.

replace all occurences of '.' IN a with space

condence a no-gaps.

regards.

sriram.