09-20-2007 4:58 PM
Hi all, I need to create a user exit to get a date value based on another variable. Basically, 100 days minus the first variable.
var2 = var1 - 100
How can I write this?
Thanks.
09-20-2007 5:03 PM
Just the way you coded it.
REPORT ztest MESSAGE-ID 00 LINE-SIZE 80.
DATA: var1 TYPE sy-datum,
var2 TYPE sy-datum.
var1 = sy-datum.
var2 = var1 - 100.
WRITE: /001 var1, var2.
rob
Message was edited by:
Rob Burbank
09-20-2007 5:03 PM
Just the way you coded it.
REPORT ztest MESSAGE-ID 00 LINE-SIZE 80.
DATA: var1 TYPE sy-datum,
var2 TYPE sy-datum.
var1 = sy-datum.
var2 = var1 - 100.
WRITE: /001 var1, var2.
rob
Message was edited by:
Rob Burbank
09-20-2007 6:09 PM
That did not work. Here is my code:
LOOP AT I_T_var_range
INTO loc_var_range WHERE
VNAM = 'ZENDT' or
VNAM = 'ZENDATE'.
l_S_range-low = loc_var_range-low - 275.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO E_T_range.
ENDLOOP.
When I tried to debug, loc_var_range-low showed a value of 20070401 which is var2 value. When I run the query, it returns me an error saying value for val1 cannot be calculated.
09-20-2007 6:12 PM
09-20-2007 6:14 PM
09-20-2007 6:21 PM
I'm afraid I don't understand what you're asking; however, date arithmetic is simple. The solution I provided does do the subtraction correctly, so your problem appears to be ain applying it to your situation. Maybe if you posted more code showing just where the problems lies, it would help.
Rob
09-20-2007 6:23 PM
ok, here is the full code. hope it makes sense.
IF i_step = 2.
*****Loops for Quarter Variable.*****************************************
LOOP AT I_T_var_range
INTO loc_var_range WHERE
VNAM = 'ZENDT' or
VNAM = 'ZENDATE'.
l_S_range-low = loc_var_range-low - 275.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO E_T_range.
ENDLOOP.
EXIT.
ENDIF.
09-20-2007 6:25 PM
09-20-2007 6:27 PM
Ok, I figured it out. I had to declare variables of type d and then assign it.
IF i_step = 2.
data:zday type d,
zday1 type d.
*****Loops for Variable.*****************************************
LOOP AT I_T_var_range
INTO loc_var_range WHERE
VNAM = 'ZENDT' or
VNAM = 'ZENDATE'.
zday = loc_var_range-low.
zday1 = zday - 275.
* l_S_range-low = loc_var_range-low - 275.
l_S_range-low = zday1.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO E_T_range.
ENDLOOP.
EXIT.
ENDIF.
09-20-2007 6:30 PM
Yes - you can only do date arithmetic on fields declared as dates.
Rob