‎2008 May 13 3:20 PM
Hi
can anybody tell me if i want to subtract one thing from another(subtracting) how can I write the code?
can I use minus symbol for subtractions.
‎2008 May 13 3:22 PM
‎2008 May 13 3:22 PM
data: v_test type i value 10,
v_test1 type i value 4,
output type i .
output = v_test - v_test1 .
write:/ output.
regards,
venkat
‎2008 May 13 3:23 PM
hi,
Yes you can very well use that ...
data : p_var1 type i value '10',
P_var2 type i value '2',
p_out type i.
p_out = p_var1 - p_var2.
write : p_out.
‎2008 May 13 3:24 PM
Hi,
data: v_num type i value 12.
v_num = v_num - 3.
write:/ v_num.
‎2008 May 13 3:26 PM
Hi sandeep,
You can use the subtraction operator i.e ' - ' sign.
But while using it be careul to give spaces in between operator sign and the variables you want to subtraction i.e.
var1 = var3 - var4.
I hope this may solve ur queris.
‎2008 May 13 4:01 PM
Hi,
You can go ahead with the above solutions.
Thanks,
Sriram Ponna.
‎2008 May 13 4:51 PM
Ya i was trying to write like
wa_output-duedate = wa_vendor-base - wa_vendor-terms.
here it is saying relational operator '-' is not supported
‎2008 May 13 4:53 PM
Are you doing it inside an if or other control structure?
Post your code, is probably a syntax error
‎2008 May 13 5:28 PM
LOOP AT lt_vendor INTO wa_vendor.
wa_output-name1 = wa_vendor-name1.
wa_output-duedate = wa_vendor-zfbdt + wa_vendor-zterm.
IF ( wa_output-duedate - p_audat ) LE 30.
wa_output-days30 = 'X'.
ENDIF.
endloop.
here is the piece of code
‎2008 May 13 5:31 PM
Yes, that's the problem, you can't do that in abap.
Just put the value of
wa_output-duedate - p_audat
in another variable and compare that variable in the if
‎2008 May 13 5:32 PM
hi this can be done like this also...
LOOP AT lt_vendor INTO wa_vendor.
v_diff = wa_output-duedate - p_audat .
wa_output-name1 = wa_vendor-name1.
wa_output-duedate = wa_vendor-zfbdt + wa_vendor-zterm.
IF v_diff LE 30.
wa_output-days30 = 'X'.
ENDIF.
endloop.
regards,
venkat
‎2008 May 13 5:42 PM
Ok. i got it thanks for the solution.
but why it wont work the other way.?
‎2008 May 13 7:07 PM
>
> Ok. i got it thanks for the solution.
>
> but why it wont work the other way.?
Because the ABAP interpreter doesn't work like that.
Interestingly, if you write a static method, say DIFFERENCE, of a class, say my_class, that finds the difference, you can write something like:
IF my_class=>difference( i_val1 = wa_out-duedata i_val2 = p_audat) LE 30.
But it would be pretty pointless!
matt
‎2008 May 13 5:37 PM
hi,
do this way ..
data : lv_differ type i.
LOOP AT lt_vendor INTO wa_vendor.
wa_output-name1 = wa_vendor-name1.
wa_output-duedate = wa_vendor-zfbdt + wa_vendor-zterm.
lv_differ = wa_output-duedate - p_audat.
IF lv_differ LE 30.
wa_output-days30 = 'X'.
ENDIF.
endloop.
‎2008 May 13 6:22 PM
Can I write expression like
IF 30 GE delay LE 60.
wa_output-days60 = 'X'.
ENDIF.
‎2008 May 13 6:30 PM
no, you need to join them using the operand AND.
but is way better to use
IF delay between 30 and 60.
wa_output-days60 = 'X'.
ENDIF.
‎2008 May 13 6:31 PM
yes.. but in this syntax
DATA: delay TYPE i.
IF delay BETWEEN 30 AND 60.
ENDIF.