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

how to remove preceeding zeros?

Former Member
0 Likes
1,477

Hi,

Any function to remove the preceeding zeros from a number type.

I cannot be using integers because i need to append it to a string.

Thanks and regards,

Ronita

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,433

DATA : v TYPE maktx.

START-OF-SELECTION.

v = '000000material desc'.

SHIFT v LEFT DELETING LEADING '0'.

WRITE : v.

reward if helpful

10 REPLIES 10
Read only

Former Member
0 Likes
1,433

Hi,

USE FM CONVERSION_EXIT_ALPHA_OUTPUT.

Regards

Raju Chitale

Edited by: Raju Chitale on May 6, 2008 8:01 AM

Read only

Former Member
0 Likes
1,433

Hi,

do like this.


DATA:num(4) value '0020'.

WRITE:/ num.
SHIFT num LEFT DELETING LEADING '0'.
WRITE:/ num.

rgds,

bharat.

Read only

Former Member
0 Likes
1,434

DATA : v TYPE maktx.

START-OF-SELECTION.

v = '000000material desc'.

SHIFT v LEFT DELETING LEADING '0'.

WRITE : v.

reward if helpful

Read only

former_member784222
Active Participant
0 Likes
1,433

Hi,

You have the following options:

1. write integer left-justified no-grouping to charvariable.

2. charvariable = integer. shift left charvariable deleting leading '0'.

3. CONVERSION_EXIT_ALPHA_OUTPUT.

Thanks and regards,

S. Chandramouli.

Read only

Former Member
0 Likes
1,433

Hi,

Use the following statement.

SHIFT num LEFT DELETING LEADING ZEROS..

Regrads,

madan.

Read only

Former Member
0 Likes
1,433

do this way ..


call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = it_sales-matnr
importing
output = it_sales-matnr.

Read only

Former Member
0 Likes
1,433

hi,

conversion exitalpha_output is used to remove leading zeros.

example.

DATA : num(5) TYPE n VALUE '0002'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

input = v_num

IMPORTING

output = v_num.

reward if useful.

thanks and regards.

Read only

Former Member
0 Likes
1,433

Hi Ronita,

Use the below Function to remove the preceeding zeroes.

CONVERSION_EXIT_ALPHA_OUTPUT: converts any number with zeroes right into a simple integer

Example:

input = 00000000000123

output = 123

pls reward if useful.

Thanks,

Sirisha.

Read only

Former Member
0 Likes
1,433

Hi,

Try this simple code.

data : num type i value '0000098'.

pack num to num.

write num.

Output : 98

Reward pts if helpful

Read only

Former Member
0 Likes
1,433

Hi Ranita,

U can use anyone of the following options.

DATA:num(10) value '0000000100'.

SHIFT num LEFT DELETING LEADING '0'.

WRITE:/ num.

Or

DATA : num(10) TYPE n VALUE '0000000100'.

DATA : l_num type n.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

input = num

IMPORTING

output = l_num.

write: l_num.

If it is helpfull pls reward pts.

Regards

Srimanta