Skip to Content
avatar image
Former Member

substraction of 2 characters

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Sep 08, 2008 at 11:38 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 08, 2008 at 11:39 AM

    Hi

    Conversion of char into currency:

    Conversion of char into currency

    Regards,

    Sravanthi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 08, 2008 at 11:45 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 08, 2008 at 11:53 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 08, 2008 at 11:56 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded