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: 

Replace Leading Zeros with spaces

Former Member
0 Kudos
1,909

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

jaheer_hussain
Active Contributor
0 Kudos
364

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.

0 Kudos
364

Hi,

I need spaces replacing those zeros.

Regards,

Srik

matt
Active Contributor
0 Kudos
364

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

former_member598013
Active Contributor
0 Kudos
364

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

Former Member
0 Kudos
364

Hi,

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

Regards,

Chris Gu

Former Member
0 Kudos
364

hi,

try this..


BKK_DELETE_LEADING_ZERO

Arunima

Former Member
0 Kudos
364

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

Then use

REPLACE ALL OCCURENCES OF '0' with SPACE.

This will help

Former Member
0 Kudos
364

Hi,

Try below code for your requirement.

DATA:p(10) VALUE '000095'.

WRITE: p NO-ZERO RIGHT-JUSTIFIED.

Best Regards,

Deepa Kulkarni

Former Member
0 Kudos
364

Hi,

Go for a REPLACE stmt.

Former Member
0 Kudos
364

Hi,

Just use a SHIFT statement.

SHIFT number left deleting leading '0'.

Regards,

Suganya

Former Member
0 Kudos
364

thanks a lot it worked with write to