12-13-2016 8:59 PM
Hello Gurus,
I am trying to use the Initialization section of a program to update the date and time fields. The issue is, when I run it in foreground, I can see the date and time fields but when I run it in background, I see the variant showing the date and time when the variant is created. Also the program is not picking up data in the background as in the foreground. Following is the logic,
gv_curtime = syst-uzeit.
gv_curdate = syst-datum.
* Last Run time
CLEAR: gs_tvarvc.
SELECT SINGLE *
FROM tvarvc
INTO gs_tvarvc
WHERE name = 'ZABC'
AND type = 'P'
AND numb = 0000.
IF syst-subrc EQ 0.
gv_lasttime = gs_tvarvc-low.
ELSE.
gv_lasttime = syst-uzeit - 3600.
ENDIF.
* Last Run Date
CLEAR: gs_tvarvc.
SELECT SINGLE *
FROM tvarvc
INTO gs_tvarvc
WHERE name = 'ZDEF'
AND type = 'P'
AND numb = 0000.
IF syst-subrc EQ 0.
gv_lastdate = gs_tvarvc-low.
ELSE.
gv_lastdate = syst-datum.
ENDIF.
LOOP AT s_time.
* Set the last run time in the field s_time-low.
s_time-sign = 'I'.
s_time-option = 'BT'.
IF gv_curtime > gv_lasttime.
s_time-low = gv_lasttime.
* Set the current time in the field s_time-high.
s_time-high = gv_curtime.
ELSE.
s_time-low = gv_lasttime.
s_time-high = '235959'.
ENDIF.
MODIFY s_time.
ENDLOOP.
LOOP AT s_date.
* Set the last rund ate in the field s_date-low.
s_date-sign = 'I'.
s_date-option = 'BT'.
IF gv_curtime > gv_lasttime..
s_date-low = gv_curdate.
* Set the current date in the field s_date-high.
s_date-high = gv_curdate.
ELSE.
s_date-low = gv_lastdate.
s_date-high = gv_lastdate.
ENDIF.
MODIFY s_date.
12-13-2016 9:35 PM
I have written the dates in the output.
For Foreground the program shows, Date :13.12.2016 to 13.12.2016 & Time 21:00:11 to 21:29:27
In background it is taking 20161118 to 20161118 and time 193103 to 195603
Any ideas appreciated...
12-13-2016 9:40 PM
The variant always takes the constant values, the Initialization logic is not working in background.
12-13-2016 9:51 PM
This is resolved now. I am not sure if this is the correct option. I gave this same logic in the START-OF-SELECTION event.
If sy-batch = 'X'.
perform setdate."Same logic as initialization section
endif.
Any better solutions of creating variant etc which can be modifiable for a background job are welcome...
Regards,
Vijay.
12-14-2016 7:05 AM
In background your report is always executed with a variant (check it with SM37), so variant values overwrite initialization values (sequence: load-of-program/default values of parameters/initialization/load variant value/selection-screen at events/start-of-selection)
As you already store data in TVARVC why don't you use this variable in the variant used in the background job definition (Variable Values in Variants)?
Regards,
Raymond