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: 

I want to remove Trailing zeros from a charecter value

Former Member
0 Kudos

Hello ,

i want to remove trailing zeros for a prticular value.Following is my code :

DATA: V_FLOAT TYPE F VALUE '4.8240000000000000E+03',

V_CHAR(25) ,

P10_4(10) TYPE P DECIMALS 4.

CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'

EXPORTING

FLOAT_IMP = V_FLOAT

FORMAT_IMP = P10_4

ROUND_IMP = ' '

IMPORTING

CHAR_EXP = V_CHAR.

SHIFT V_CHAR RIGHT DELETING TRAILING '0'.

WRITE : V_CHAR ."NO-ZERO.

<u><b>Output:</b></u>

if we pass the value '1.3000000000000000E+01' it should be 13.0

ex2: '1.3400000000000000E+01' it should be 13.4

ex3:'4.8240000000000000E+03' it should be 4824

is there any way to get the solution without functional module. If so Please tell me with code.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Vikram,

I can suggest you a method of using the FM given below.

Please use FM

CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal

CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external

Hope this resolves your query.

Reward all the helpful answers.

Regards

10 REPLIES 10

Former Member
0 Kudos

Hi Vikram,

I can suggest you a method of using the FM given below.

Please use FM

CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal

CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external

Hope this resolves your query.

Reward all the helpful answers.

Regards

Former Member
0 Kudos

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

example:

input = 00000000000123

output = 123

0 Kudos

This FM does not work. It only works on Integer types and if you want to remove the padding or leading zeros in case of vendor number etc.

Former Member
0 Kudos

hi

u can do it in number of ways.

Use TCODE SU3

Select default tab and select radio button 123467.89 in decimal notation and save it.

or u can try :

if you want to do this through ABAP program.

1. to delete trailing spaces.

SHIFT <V_VARIABLE> RIGHT DELETING TRAILING '0'.

to delete leading zeroes,

SHIFT <VARIABLE_NAME> LEFT DELETING LEADING '0'.

only for one abap program, u can use set country command

for all programs :

sap menu>system->go to user profil->own data>default --> and choose ur format.

hope this helps u.

Regards,

Prasanth

  • Reward all hepful replies

Former Member
0 Kudos

Hi Vikram,

This code will meet your requirement

data:

w_char(45) type c ,

w_float type f ,

w_int type i .

w_char = '4.8240000000000000E+03'.

w_float = w_char .

w_int = w_float .

write :

w_float ,

/ w_int .

Former Member
0 Kudos

TAKE TRHIS FLOAT VALUE TO TYPE P DECIMALS 1 VARIABLE...

DATA : VARP TYPE P DECIMALS 1.

VARP = <YOUR FLOAT>.

WRITE : / VARP.

REGARDS

SHIBA DUTTA

Former Member
0 Kudos

Hi,

You can use as below.

WRITE: V_FLOAT EXPONENT 0 DECIMALS 0 TO V_FLOAT.

It will get you the desired output.

Regards,

Ram

Pls reward points if helpful

Former Member
0 Kudos

hi vikram,

try this..

REPORT YCHATEST.

DATA: V_FLOAT TYPE F VALUE '4.8240000000000000E+03',
      V_CHAR type p decimals 2
      .

V_CHAR = V_FLOAT.

WRITE : V_CHAR.

Former Member
0 Kudos

DATA: V_FLOAT TYPE F VALUE '1.3400000000000000E+01',
V_CHAR(25) ,
P10_4(10) TYPE P DECIMALS 1.
CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'
EXPORTING
FLOAT_IMP = V_FLOAT
FORMAT_IMP = P10_4
ROUND_IMP = ' '
IMPORTING
CHAR_EXP = V_CHAR.


shift V_CHAR right deleting trailing ' '.
shift V_CHAR right deleting trailing '0'.
shift V_CHAR right deleting trailing ','.

WRITE : V_CHAR ."NO-ZERO.

stefansoyka
Explorer
0 Kudos

This will do:

SHIFT text RIGHT DELETING TRAILING '0 ,'.