Application Development 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: 

to replace leading zeroes with space

Former Member
0 Kudos

I want to replace leading zeroes with space.

e.g. if input is "000020" output should be " 20" and not "20".

4 REPLIES 4

Former Member
0 Kudos

HI,

Try this

data: C(10) type n value '000020',

offest type i value 1.

WHILE c(offest) = '0'.

REPLACE '0' WITH SPACE INTO C.

ADD 1 TO offest.

ENDWHILE.

Regards

piyush_mathur
Active Participant
0 Kudos

Hi Priti...

Refer below piece of code for solution:

NUMBER = '000020'

SHIFT NUMBER LEFT DELETING LEADING '0'.

CONCATENATE SPACE NUMBER INTO NUMBER.

Regards,

Piyush

Edited by: Piyush Mathur on Jan 16, 2008 7:57 AM

Former Member
0 Kudos

Hi Priti,

EXECUTE BELOW CODE THIS WILL WORKS FINE 4 UR PROBLEM CHECK IT ONCE..

data: str type string value '000100',

str1 type c value space.

shift str left deleting leading '0'.

concatenate str1 str into str.

write:/ str.

Reward points if helpful.

Kiran Kumar.G.A

Have a Nice Day..

Former Member
0 Kudos

Hello Priti,

Try this and it will certainly work for all conditions.

data: str type string value '000200'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

INPUT = str

IMPORTING

OUTPUT = str

.

write:/ str.

Happy Coding.

Cheers,

Tej.

OOOPS!!! , I need to modify the code to work as per your requirement. May I know what field are you trying to modify as per your requirement. I need to know the maximum length of the field to work the way you want it to.

Edited by: Shree Tejus on Jan 16, 2008 8:52 AM