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: 

substraction of 2 characters

Former Member
0 Kudos

Hi,

i have 2 variables consisting of type character.

i have to substract those two variables.

though their type is character they have the numbers.

i have to substract them or convert them into currency and substract them.

can any one tell me the procedure.

7 REPLIES 7

bpawanchand
Active Contributor
0 Kudos

Hi

DATA :
   w_n(3) type c VALUE '4.1',
   w_n1(3) TYPE c VALUE '3.4',
   w_c TYPE p DECIMALS 2.


w_c  = w_n - w_n1.


WRITE :
  w_c.

regards

Pavan

0 Kudos

Thank for the reply.

its going to dump if we do as you suggested.

we tried it.

0 Kudos

Hi

Its working fine in my system check whether you have checked UNICODE CHECKS ACTIVE and FIXED POINT ARITHMETIC in program attributes

regards

pavan

Former Member
0 Kudos

Hi

Conversion of char into currency:

Regards,

Sravanthi

Former Member
0 Kudos

hii

you can use following code too

DATA :
   w_val1(3) type c VALUE '40',
   w_val2(3) TYPE c VALUE '10',
   w_val11 type p decimals 2,
    w_val22 type p decimals 2,
   w_result(10) TYPE c.

w_val11 = w_val1.
w_val22 = w_val2.
w_result  = w_val11 - w_val22.


WRITE :
  w_result.

regards

twinkal

Former Member
0 Kudos

As also said by others it should work this way:

Data:

char1(5),

char2(5),

char3(5).

char1 = '30.60'.

char2 = '25.40'.

char3 = char1 - char2.

Write:

char3.

With luck,

Pritam.

Former Member
0 Kudos

Hi,

Check the code below.

It is working fine.

DATA :

w_n(3) type c VALUE '4.1',

w_n1(3) TYPE c VALUE '3.4',

w_c TYPE p DECIMALS 2.

w_c = w_n - w_n1.

WRITE :

w_c.