‎2006 Jun 19 11:06 AM
Hi Guys,
i want to create a program wants to run in background ie batch job/ program that is scheduled periodically ? can u give some ideas on it ?
points for sure for good answers
regards
Srini
‎2006 Jun 19 11:09 AM
Execute transaction <b>SM36</b>
Click Steps
Click ABAP/4 and type in the program name
Click Save
Finally fill in the Start date
In 4.6x, SAP provide a friendly GUI transaction code <b>SM36WIZ</b> for users to submit jobs in the background.
<b>Schedule Manager</b>
Automate your routinue task with Schedule Manager. It facilitate the definition, scheduling, execution, and review of tasks that are executed on a regular basis, such as period-end closing.
<b>SCMA</b> - Schedule Manager
<b>Checking your program Background Job Status</b>
Checking your job status with <b>SM50</b> (processor type BTC) is more accurate then <b>SM37</b>. SAP updates the tables TBTCO wheneveryour background jobs status change. If SAP is shutdown, the currentjobs might not be update ontime to the table. ( e.g. a background job wasshown as Active (SM37), in fact it real status should be Cancelled.
The type of work process:
DIA - work process for executing dialog steps in user transactions
UPD - update process for executing U1 (time-critical) database changes
UP2 - update process for executing U2 (non-critical) database changes
ENQ - for setting and releasing locks on SAP lock objects
BTC - for executing background jobs
SPO - for spool formatting processes
PID: Process ID of the work process.
<b>Change the variants or SAP Printers of scheduled background jobs</b>
SM37 - At the Job Overview screen, position your cursor at the scheduled jobs you want to changed (the jobs status must still be Released)
Click Job -> Change
Click the Steps button -> here you can move, add or delete addition programs steps to be run
Double click the program name you want to change
Click the Print specifications button if you want to change the SAP printers
regards
vinod
‎2006 Jun 19 11:10 AM
Hi srini,
1. Any program (se38) program,
having a saved variant,
can be run in background.
2. Its only matter of scheduling this
program to run in background,
using SM36.
regards,
amit m.
‎2006 Jun 19 11:45 AM
i dont want using tcode SM36 but i want to write a program using job_open ? can u help me in this regard ?
‎2006 Jun 19 11:49 AM
Hi again,
1. sample code.
2. Note (we can either use SUBMIT statement,
or JOB_SUBMIT to submit our program in background.
3.
report abc.
DATA : JN(32) TYPE C.
JN = 'JOB001'.
BREAK-POINT.
DATA : J(8) TYPE C.
*----
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = JN
JOBCLASS =
IMPORTING
JOBCOUNT = J
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4
.
*----
DATA : P TYPE PRI_PARAMS.
P-PDEST = 'PRINTER'.
P-PDEST = 'LOCL'.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING NO_DIALOG = 'X'
MODE = 'CURRENT'
NEW_LIST_ID = $PRNEW
IMPORTING OUT_PARAMETERS = P.
*----
submit HINCF160 using selection-set '2102'
VIA JOB JN NUMBER J
AND RETURN
.
*----
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = J
jobname = JN
STRTIMMED = 'X'
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
INVALID_TARGET = 8
OTHERS = 9.
*----
BREAK-POINT.
regards,
amit m.
‎2006 Jun 19 12:11 PM
‎2006 Jun 19 11:11 AM
1. Create ZPROGRAM
2. SM36 -> start condition -> Date/Time -> Save
3. Step -> Specify zprogram and variant
4. Save
‎2006 Jun 19 4:16 PM
Hi,
You need to create two programs say Zreport1 and zreport2. From zreport1, you are passing selection parameters to zreport2.
In ZREPORT1.
Export it_tab
to database db(idx) index indx.
Use FM : JOB_OPEN
Pass Job name & import Jobcount. Jobcount is unique id.
If you want to set print parameters then use FM 'GET_PRINT_PARAMETERS'. If spool size is not important then this FM is not required.
Use FM : JOB_SUBMIT. pass report name as 'ZREPORT2'. This is the program which you want to call in background.
Instead of JOB_SUBMIT, you can also use SUBMIT <report>.
Use FM : JOB_CLOSE.
In ZREPORT2.
Import it_tab
from database db(idx) index indx.
loop at it_tab into wa_tab.
write 😕 wa_tab-matnr.
endloop.
Best regards,
Prashant