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

a dot matter

Former Member
0 Likes
653

hi experts

i have a number like xx.xx or x.xx or xxx.xx how do i get rid of the dot and the digits that after the dot

thanks

amit

Edited by: amit walden on Feb 6, 2008 8:29 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
632

hi

try this

REPLACE ALL OCCURRENCES OF '.' IN f1 WITH ' '.

5 REPLIES 5
Read only

Former Member
0 Likes
633

hi

try this

REPLACE ALL OCCURRENCES OF '.' IN f1 WITH ' '.

Read only

former_member188829
Active Contributor
0 Likes
632

Hi,

DATA:X_NUM(10) TYPE C VALUE '123.23'.

REPLACE ALL OCCURRENCES OF '.' IN X_NUM WITH ''.

WRITE:X_NUM.

Read only

Former Member
0 Likes
632

Hi,

Use this stmt.

Replace all occurences of '.' with ' '.

i hope it may work,

regards,

ravi shankar reddy

Read only

matt
Active Contributor
0 Likes
632

Don't use character operations. There's no need.

As you present the query, it seems you have a decimal number and you want it to become an integer. You don't say how the decimal number is stored - it could be string, character, floating point or packed decimal. In any case, use the inbuilt function "trunc". Here's a sample program to show how it works.


DATA: my_pd  TYPE p LENGTH 8 DECIMALS 2,
      my_fp  TYPE f,
      my_char TYPE c LENGTH 8,
      my_str TYPE string.

my_pd = '12.34'.
my_fp = '12.34567'.
my_char = '12.34567'.
my_str = `12.34567`.

PERFORM to_int USING: 'PD' my_pd,
                      'FP' my_fp,
                      'CHAR' my_char,
                      'STR' my_str.


FORM to_int USING desc TYPE clike
                  valu TYPE any.

  DATA: my_int TYPE i.

  my_int = TRUNC( valu ).

  WRITE: / desc, valu, my_int.

ENDFORM.                    "to_int

Regards

matt

Edited by: Matthew Billingham on Feb 6, 2008 10:09 AM

Read only

Former Member
0 Likes
632

Hi,

Please refer to the below code:


data : num1 type p decimals 2 value '10.20'.
data : num2 type i.

num2 = num1.

write : num2.

Thanks,

Sriram Ponna.