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: 

How can i delete the leading space of a character variable

Former Member
0 Kudos

The first question as the title,and the second one is that,for example ,there is a value like 6.00,how can i delete the zeros and only leave the value 6,when i pass the value to a character variable?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check the code

DATA:

lv_decimal TYPE f DECIMALS 3,

lv_string TYPE string.

lv_decimal = '22.010'.

WRITE lv_decimal TO lv_string.

SHIFT lv_string RIGHT DELETING TRAILING '0'.

  • also delete trailing '.', if possible

SHIFT lv_string RIGHT DELETING TRAILING'.'.

CONDENSE lv_string NO-GAPS.

  • now no trailing zeros are in the decimal stored in LV_STRING

Regards,

Raj.

7 REPLIES 7

Former Member
0 Kudos

Hi,

Use the following function module.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input =

  • IMPORTING

  • OUTPUT =

.

Provide the appropriate parameters.

Reward if helpful.

Jagadish

harikrishnan_m
Active Participant
0 Kudos

Hi,

Pass the value to an integer variable and then to a character varaible..

DATA : integer TYPE I,

character TYPE C or STRING.....

integer = 6.00.

after this integer value will be '6'.

now pass this to character varaible..

Rewards if usefull

Regards,

ABAPer 007.

Former Member
0 Kudos

Hi,

Check the code

DATA:

lv_decimal TYPE f DECIMALS 3,

lv_string TYPE string.

lv_decimal = '22.010'.

WRITE lv_decimal TO lv_string.

SHIFT lv_string RIGHT DELETING TRAILING '0'.

  • also delete trailing '.', if possible

SHIFT lv_string RIGHT DELETING TRAILING'.'.

CONDENSE lv_string NO-GAPS.

  • now no trailing zeros are in the decimal stored in LV_STRING

Regards,

Raj.

Former Member
0 Kudos

Hi,

the leading and trailing space of a character variable can be deleted using CONDENSE command.

CONDENSE variablename.

Former Member
0 Kudos

Hi,

1.shift <char> left deleting leading space.

2. write <num> to <char> decimals 0.

Regards,

Vidya Chowdhary A.

Former Member
0 Kudos

Hi,

DATA : v_num1 TYPE N value '6.00',

v_num2 TYPE I,

v_char1(10).

v_num2 = v_num1.

v_char1 = v_num2.

write char1.

Pls. reward if useful...

Former Member
0 Kudos

Hi,

DATA : v_num1 TYPE F value '6.00',

v_num2 TYPE I,

v_char1(10).

v_num2 = v_num1.

v_char1 = v_num2.

write char1.

Pls. reward if useful...