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 Leading Zeros with spaces

Former Member
0 Likes
3,792

Hi All,

Please help me with a functional module to remove the leading zeros and replace them with spaces.

Eg: number : 000095

output needed : 95.

I tried with the search in the sdn but couldnt find.

Regards,

Srikanth.

11 REPLIES 11
Read only

jaheer_hussain
Active Contributor
0 Likes
2,247

Hi srik,

I think there is no function module for purpose,but have a look on the simple staatement

data:p(5) value '00044'.

write:/ p no-zero.

-


output:44

with Regards,

Jaheer.

Read only

0 Likes
2,247

Hi,

I need spaces replacing those zeros.

Regards,

Srik

Read only

matt
Active Contributor
0 Likes
2,247

Look at function module CONVERSION_EXIT_ALPHA_OUTPUT This will convert "000095" to '95'. If you need to get to '<4 spaces>95' then use the WRITE INTO command with the addition "RIGHT-JUSTIFIED".

Jaheer Hussein's suggestion should also work, with some modification.

data:p(5) value '00044',
    v(5).

write p into v no-zero right justified.

matt

Edited by: Matt on Nov 9, 2008 3:45 PM

Read only

Former Member
0 Likes
2,247

Hi Srikanth,

Check out the code for your requirement.


DATA: V_MATNR TYPE MARA-MATNR VALUE '00098'.
DATA: V_OUTPUT TYPE MARA-MATNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
  EXPORTING
    input         =  V_MATNR
 IMPORTING
   OUTPUT        =   V_OUTPUT.

          .
WRITE: / V_OUTPUT.

Thanks,

Chidanand

Read only

Former Member
0 Likes
2,247

Hi,

Please use FM ''CONVERSION_EXIT_ALPHA_OUTPUT'' to have a try.

Regards,

Chris Gu

Read only

Former Member
0 Likes
2,247

hi,

try this..


BKK_DELETE_LEADING_ZERO

Arunima

Read only

Former Member
0 Likes
2,247

First move the value into a variable of type char(xx).

Then use

REPLACE ALL OCCURENCES OF '0' with SPACE.

This will help

Read only

Former Member
0 Likes
2,247

Hi,

Try below code for your requirement.

DATA:p(10) VALUE '000095'.

WRITE: p NO-ZERO RIGHT-JUSTIFIED.

Best Regards,

Deepa Kulkarni

Read only

Former Member
0 Likes
2,247

Hi,

Go for a REPLACE stmt.

Read only

Former Member
0 Likes
2,247

Hi,

Just use a SHIFT statement.

SHIFT number left deleting leading '0'.

Regards,

Suganya

Read only

Former Member
0 Likes
2,247

thanks a lot it worked with write to