cancel
Showing results for 
Search instead for 
Did you mean: 

Removing Trailing Zeros Not Working

Former Member
0 Kudos

I am trying to remove the trailing zeros from the parameter lbbil_it_gen-fkimg. This variable is of type P instead of a decimal or character, which is why I don't think it's working. Variable quantity is of type string and gs_it_gen is of type lbbil_it_gen in my global variables.

I have tried both SHIFT RIGHT and the FM CONVERSION_EXIT_ALPHA_OUTPUT and both have failed. I am missing a minor detail somewhere.

This is what I have tried:


quantity = gs_it_gen-fkimg.
shift quantity right deleting trailing '0'.
shift quantity right deleting trailing '.'.

and...


call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
  input = gs_it_gen-fkimg
IMPORTING
  export = quantity.

I will respond quickly and reward points for helpful/right answers.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Just move to a variable which has decimals..

Ex..

data: v_input type p decimals 3 value '10.000',
      v_output type p decimals 0.

v_output = v_input.

write: / v_output.

Thanks

Naren

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I was going to say to move it to an integar, but Narendran's solution would work too.

data: v_input type p decimals 3 value '10.000',
        v_output type i.
 
v_output = v_input.
 
write: / v_output.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

If you really want to use the SHIFT, then quantity would need to be a character based fields I think(type c, or string) and then I think there will be a space on the far right, to hold the "sign" value, so you would need to get rid of that first.

shift quantity right deleting trailing ' '.
shift quantity right deleting trailing '0'.
shift quantity right deleting trailing '.'.

Regards,

Rich Heilman

Former Member
0 Kudos

Thanks both those solutions worked.

Former Member
0 Kudos

Hi,

Check this:


data: a1 type p DECIMALS 2 value '64.54'.
data: a2 type i,
      a3 type i,
      a4 type i.

a2 = a1.

a3 = floor( a1 ).

a4 = ceil( a1 ).

write:/  'A1 = ',a1,
      /  'A2 (Direct assignment) = ',   a2,
      /  'A3 (Floor) = ', a3,
      /  'A4 (Ceil) = ', a4  .

Output:

A1 = 64.54

A2 (Direct assignment) = 65

A3 (Floor) = 64

A4 (Ceil) = 65

Regards,

Subramanian

Answers (2)

Answers (2)

0 Kudos

Hi,

have a look,

quantity = gs_it_gen-fkimg.

REPLACE ALL OCCURRENCES OF '.000' IN quantity WITH space.

regards.

sriram.

Former Member
0 Kudos

Hi,

Are you trying to round the value..by removing the decimal and the zeros..Please give me an example..of what you are trying..

Thanks

Naren

Former Member
0 Kudos

I am trying to remove the decimal place and trailing zeros. Here's an example:

20.000 -> 20