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

How to subtract two NUMC values.

Former Member
0 Likes
2,611

Hi all,

Could any one of you please tell me how to subtract Two NUMC values.

I have situation here is that

CASE counter.

WHEN '2'.

MOVE i_etxt-statxt TO wa_gtab-statxt1.

WHEN '3'.

MOVE i_etxt-statxt TO wa_gtab-statxt2.

WHEN '4'.

MOVE i_etxt-statxt TO wa_gtab-statxt3.

WHEN '5'.

MOVE i_etxt-statxt TO wa_gtab-statxt4.

WHEN '6'.

MOVE i_etxt-statxt TO wa_gtab-statxt5.

ENDCASE.

ENDLOOP.

In the above code counter is of numeric data type and i need subtract like the below code

WHEN counter - '2'.

MOVE i_etxt-statxt TO wa_gtab-statxt1.

Is it possible if so .. your views please

thanks in advance

regards

Vardhan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,321

hi,

do this way ..


data : v_value(10) type n.
loop.

if counter co '0123456789'.
  v_value = counter - 2.
endif. 

WHEN v_value.
MOVE i_etxt-statxt TO wa_gtab-statxt1.
......
endloop.
 

hi,

do this way ..


data : v_value(10) type n.
loop.

if counter co '0123456789'.
  v_value = counter - 2.
endif. 

WHEN v_value.
MOVE i_etxt-statxt TO wa_gtab-statxt1.
......
endloop.
 

4 REPLIES 4
Read only

Former Member
0 Likes
1,322

hi,

do this way ..


data : v_value(10) type n.
loop.

if counter co '0123456789'.
  v_value = counter - 2.
endif. 

WHEN v_value.
MOVE i_etxt-statxt TO wa_gtab-statxt1.
......
endloop.
 

Read only

Former Member
0 Likes
1,321
WHEN counter - '2'."this is wrong

try this:

WHEN counter - 2.

Amit.

Read only

Former Member
0 Likes
1,321

Hi,

Check this sample code,

DATA:
  w_temp(2) TYPE n.

  w_temp = counter - 2.

LOOP AT <itab>.

  CASE w_temp.
    WHEN '2'.
      MOVE i_etxt-statxt TO wa_gtab-statxt1.
    WHEN '3'.
      MOVE i_etxt-statxt TO wa_gtab-statxt2.
    WHEN '4'.
      MOVE i_etxt-statxt TO wa_gtab-statxt3.
    WHEN '5'.
      MOVE i_etxt-statxt TO wa_gtab-statxt4.
    WHEN '6'.
      MOVE i_etxt-statxt TO wa_gtab-statxt5.
  ENDCASE.

ENDLOOP.

Regards

Adil

Read only

Former Member
0 Likes
1,321

Hi,,

We can subtract two numeric values directly...

that is the concept of Auotmatic type conversion..

data:
  w_numc1(3)   type n value '100',
  w_numc2(3)   type n value '084'.

* then u can directly subtract these two like this
 
  w_numc1 = w_numc1 - w_numvc2.

  or 

w_numc1 = w_numc2 - 30.

Regards,

Sunil Kumar Mutyala.