2007 Feb 24 9:29 AM
Hi ,
How to submit an ABAP report as background job . How to test it
2007 Feb 24 9:31 AM
You can define and schedule background jobs in two ways from the Job Overview:
II method
There are two ways to schedule a job from a program:
1. the "express" method using the BP_JOBVARIANT_SCHEDULE function module
2. the "full-control" method using the JOB_OPEN, JOB_SUBMIT, and JOB_CLOSE function modules.
With this method, you have full control over such job options as printing, start time options, and so on.
To schedule a job from within a program using the express method, you need only call the BP_JOBVARIANT_SCHEDULE function module.
With BP_JOBVARIANT_OVERVIEW, you can offer your users a simplified display and management function for their "express-method" jobs.
call function 'BP_JOBVARIANT_SCHEDULE'
exporting
title_name = 'Documentation Check' " Displayed as title of
" of scheduling screens
job_name = 'DocuCheck' " Name of background
" processing job
prog_name = 'RSTWGZS2' " Name of ABAP
" report that is to be
" run -- used also to
" select variants
exceptions
no_such_report = 01. " PROG_NAME program
" not found.
call function 'BP_JOBVARIANT_OVERVIEW' " List the jobs that
exporting " have been scheduled
title_name = 'Documentation Check' " Displayed as title
" of overview screen
job_name = 'DokuCheck' " Jobs with this name
" are listed
prog_name = 'RSTWGZS2'
exceptions
no_such_job = 01.
For further information check the link below
http://help.sap.com/saphelp_nw2004s/helpdata/en/c4/3a80eb505211d189550000e829fbbd/frameset.htm
2007 Feb 24 9:30 AM
2007 Feb 24 9:30 AM
2007 Feb 24 9:31 AM
You can define and schedule background jobs in two ways from the Job Overview:
II method
There are two ways to schedule a job from a program:
1. the "express" method using the BP_JOBVARIANT_SCHEDULE function module
2. the "full-control" method using the JOB_OPEN, JOB_SUBMIT, and JOB_CLOSE function modules.
With this method, you have full control over such job options as printing, start time options, and so on.
To schedule a job from within a program using the express method, you need only call the BP_JOBVARIANT_SCHEDULE function module.
With BP_JOBVARIANT_OVERVIEW, you can offer your users a simplified display and management function for their "express-method" jobs.
call function 'BP_JOBVARIANT_SCHEDULE'
exporting
title_name = 'Documentation Check' " Displayed as title of
" of scheduling screens
job_name = 'DocuCheck' " Name of background
" processing job
prog_name = 'RSTWGZS2' " Name of ABAP
" report that is to be
" run -- used also to
" select variants
exceptions
no_such_report = 01. " PROG_NAME program
" not found.
call function 'BP_JOBVARIANT_OVERVIEW' " List the jobs that
exporting " have been scheduled
title_name = 'Documentation Check' " Displayed as title
" of overview screen
job_name = 'DokuCheck' " Jobs with this name
" are listed
prog_name = 'RSTWGZS2'
exceptions
no_such_job = 01.
For further information check the link below
http://help.sap.com/saphelp_nw2004s/helpdata/en/c4/3a80eb505211d189550000e829fbbd/frameset.htm
2007 Feb 24 9:31 AM
Hi,
There are two ways for you to handle,
one manually setting up the job through SM36 which is better and convinient,
secondly through program using FM's JOB_OPEN, SUBMIT, JOB_CLOSE.
Find below steps in doing both:
Procedure 1:
1. Goto Trans -> SM36
2. Define a job with the program and variant if any
3. Click on start condition in application tool bar
4. In the pop-up window, click on Date/Time
5. Below you can see a check box "Periodic Job"
6. Next click on Period Values
7. Select "Other Period"
8. Now give '15' for Minutes
9. Save the job
Procedure 2 via Program:
Below is a sample code for the same. Note the ZTEMP2 is the program i am scheduling with 15mins frequency.
DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
L_RELEASE(1) TYPE c.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = 'ZTEMP2'
IMPORTING
JOBCOUNT = P_JOBCNT
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SUBMIT ZTEMP2 VIA JOB 'ZTEMP2' NUMBER P_JOBCNT
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
WITH DESTINATION = 'HPMISPRT'
WITH IMMEDIATELY = SPACE
WITH KEEP_IN_SPOOL = 'X' AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = P_JOBCNT
JOBNAME = 'ZTEMP2'
STRTIMMED = 'X'
PRDMINS = 15
IMPORTING
JOB_WAS_RELEASED = L_RELEASE
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.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Hope the above helps you.
Regards
Anver
2007 Feb 24 9:33 AM
Hi kumar,
testing thru:Goto sm37-> select active job , tcode jdbg with out /n or / .
or goto sm50-> select job program/mode-> program-> debuging.
2007 Feb 24 9:34 AM
Hi ,
Goto to SE38 enter the program name and goto the menu program execute in background.
create a job name and execute with or without the variant .
To debug a background use transaction JDBG.
Use transaction SM36 create a job and scheduled particular time.
Please reward if useful.
2007 Feb 24 10:07 AM
Hi Kumar,
We can submit a job in background using SM36 that is one way.
Progamaticcaly ,which is the "full-control" method using the JOB_OPEN, JOB_SUBMIT, and JOB_CLOSE function modules.
With this method, you have full control over such job options as printing, start time options, and so on.
Sample code for how to use these function modules.
Create your job with JOB_OPEN. The module returns a unique job
number. Together with the jobname, this number identifies the
job. Other parameters are available, but are not required.
JOBNAME = 'Freely selectable name for the job(s) you create'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = JOBNAME
IMPORTING
JOBCOUNT = JOBNUMBER
EXCEPTIONS
CANT_CREATE_JOB = 01
INVALID_JOB_DATA = 02
JOBNAME_MISSING = 03
OTHERS = 99.
IF SY-SUBRC > 0.
<Error processing>
ENDIF.
Add a job step: ABAP program
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
AUTHCKNAM = SY-UNAME " Runtime authorizations
" user
JOBCOUNT = JOBNUMBER " Value from JOB_OPEN
JOBNAME = JOBNAME " Value from JOB_OPEN
REPORT = 'REPORT' " Report to be run
VARIANT = 'VARIANT' " Variant to use with
" report
PRIPARAMS = USER_PRINT_PARAMS " User printing options
ARCPARAMS = USER_ARC_PARAMS " User archiving options
" Both sets of options
" come from
" GET_PRINT_PARAMETERS
EXCEPTIONS
BAD_PRIPARAMS = 01
INVALID_JOBDATA = 02
JOBNAME_MISSING = 03
JOB_NOTEX = 04
JOB_SUBMIT_FAILED = 05
LOCK_FAILED = 06
PROGRAM_MISSING = 07
PROG_ABAP_AND_EXTPG_SET = 08
OTHERS = 99.
IF SY-SUBRC > 0.
<Error processing>
ENDIF.
Submit job for processing: immediate start
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOBNUMBER " Job identification: number
JOBNAME = JOBNAME " and name.
STRTIMMED = 'X' " Schedules the job for
" immediate start. The job
" is started immediately
" only if the user has the
" RELE authorization to
" release a job to run.
IMPORTING
JOB_WAS_RELEASED = JOB_RELEASED " If user has authorization
" to release jobs to run, job
" is automatically released
" when it is scheduled. This
" field is set to 'x' if the
" job has been released.
" Otherwise, the job is sche-
" duled but must be released
" by an administrator before
" it can be started.
EXCEPTIONS
CANT_START_IMMEDIATE No longer used. Replaced by IMPORTING
parameter JOB_WAS_RELEASED.
INVALID_STARTDATE = 01
JOBNAME_MISSING = 02
JOB_CLOSE_FAILED = 03
JOB_NOSTEPS = 04
JOB_NOTEX = 05
LOCK_FAILED = 06
OTHERS = 99.
IF SY-SUBRC > 0.
<Error processing>
ENDIF.
Check the job status through SM37 transaction.
Hope this helps you.
Regards,
Saumya
2007 Feb 24 11:26 AM
Kumar,
why go easy way when complicated alternatives are shown?
start report.
On selection screem, press F9 (execute in background) instaed of F8 (execute). Assign printer if you have no default. Click Immediate. Save.
Regards,
Clemens