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

Removing Zeros

Former Member
0 Likes
854

I have the following numbers say for eg.

66.66666667

68.72000000

80.00000000

80.00000000

75.19055000

I want to output them like

66.66666667

68.72

80

80

75.19055

Is there a way to achieve this.

Kind help is much appreciated.

Thanks & regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
822

first take the no to a char field..here i am taking text as an example.

data : bef(7),

aft(7),

text(14) type c value '66.66666667'.

split text at '.' into bef aft.

shift aft right deleting trailing '0'.

shift aft left deleting leading space.

clear text.

concatenate bef aft into text separated by '.'.

regards

shiba dutta

6 REPLIES 6
Read only

Former Member
0 Likes
822

Hello ,

Try the following funtion modules provided by SAP

BKK_DELETE_LEADING_ZERO

FTR_CORR_SWIFT_DELETE_ENDZERO

Or make use of the following code :

SHIFT <Variable name> RIGHT DELETING TRAILING '00'.

Regards,

Sowmya.

Read only

Former Member
0 Likes
822

There is a number of ways to do this.

report zrich_0001.

data: matnr type mara-matnr value '000000000000001111'.

  • This is one way

shift matnr left deleting leading '0'.

  • Here is another

matnr = '000000000000001111'.

call function 'CONVERSION_EXIT_MATN1_OUTPUT'

exporting

input = matnr

importing

output = matnr.

check sy-subrc = 0.

Read only

Former Member
0 Likes
822

Hi Sam,

To remove leading zeros and leading blanks

Please use FM

CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal

CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external

For ex :

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = wf_version

IMPORTING

output = wf_version.

Example:

input = 123

output = 0000000000000...000000000000123

Hope this resolves your query.

Reward all the helpful answers.

Regards

Read only

Former Member
0 Likes
822

hi

<b>WRITE <variable having value with zeros> DECIMALS 0.</b>

hope this will solve ur problem

regards

ravish

<b>plz reward points if helpful</b>

Read only

Former Member
0 Likes
823

first take the no to a char field..here i am taking text as an example.

data : bef(7),

aft(7),

text(14) type c value '66.66666667'.

split text at '.' into bef aft.

shift aft right deleting trailing '0'.

shift aft left deleting leading space.

clear text.

concatenate bef aft into text separated by '.'.

regards

shiba dutta

Read only

Former Member
0 Likes
822

Thanks all for your support.

I want to share my experience.

there are two ways to achieve the above.

1.

data mipcnt1(12).

mipcnt1 = 75.19055000

CONDENSE mipcnt1.

CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'

CHANGING

c_value = mipcnt1.

CLEAR: f1, f2.

SPLIT mipcnt1 AT '.' INTO f1 f2.

IF f2 IS INITIAL.

mipcnt1 = f1.

ENDIF.

2.

mipcnt1 = 75.19055000

mipcnt1 = abs( mipcnt1 ).

hope it helps others.