‎2007 Jul 17 8:24 AM
Hi Friends,
I would like to know as to how to schedule a job (genearting a report). ie., I want to generate a report everyday at a particular time.
Could anyone pls guide me.
TIA.
Regards,
Mark K
‎2007 Jul 17 8:26 AM
Hi,
To create a job, u need to use transaction SM36.
Use Job wizard button in the application toolbar which will guide u step by step.
Regards,
Himanshu
‎2007 Jul 17 8:29 AM
Hi,
If you are using Call transaction method then you have the programe, just schedule that programe in background in sm36.
If you are using Session method then your program generates a session. You can process this session using rsbdcsub program. Just schedule this program in the background and you can process the session at desired time.
Pls reward points.
Regards,
Ameet
‎2007 Jul 17 8:41 AM
Execute transaction SM36
Define Job name, Job class, Target server
Click on 'START CONDITION' button
Click on 'Date/Time' button
Enter Scheduled start DATE & TIME. Check mark 'Periodic Job' field. Click on 'Period values' button and select 'Hourly' or 'Dialy' or 'Weekly' or 'Monthly' or Other period and SAVE. Go back to main screen.
Click on 'STEPS' button and enter Program name and Variant under box 'ABAP Program'. Click on 'Print Specification' button and enter Printer name under 'Output device' and SAVE
Click on SAVE button until you get message on bottom of the screen that describes 'Job XYZ saved with status: Scheduled'.
Click on 'Job overview' button or execute SM37 transaction.
Select the appropriate 'Job name', 'User name', 'Job Status' & Schedule date under 'Job start condition' and click on 'Execute' button or press F8.
You will now see all your scheduled JOBS.
Scheduling Background Jobs:
1. Background jobs are scheduled by Basis administrators using transaction SM36.
2. To run a report in a background, a job needs to be created with a step using the report name
and a variant for selection parameters. It is recommended to create a separate variant for each
scheduled job to produce results for specific dates (e.g. previous month) or organizational units (e.g.
company codes).
3. While defining the step, the spool parameters needs to be specified
(Step-> Print Specifications->Properties) to secure the output of the report and help authorized users
to find the spool request. The following parameters needs to be maintained:
a. Time of printing: set to Send to SAP spooler Only for now
b. Name abbreviated name to identify the job output
c. Title free form description for the report output
d. Authorization a value defined by Security in user profiles to allow those users to access
this spool request (authorization object S_SPO_ACT, value SPOAUTH). Only users with matching
authorization value in their profiles will be able to see the output.
e. Department set to appropriate department/functional area name. This field can be used in
a search later.
f. Retention period set to Do not delete if the report output needs to be retained for more
than 8 days. Once the archiving/document repository solution is in place the spool requests could
be automatically moved to the archive/repository. Storage Mode parameter on the same screen
could be used to immediately send the output to archive instead of creating a spool request.
Configuring user access:
1. To access a report output created by a background job, a user must have at
least access to SP01 (Spool requests) transaction without restriction on the user
name (however by itself it will not let the user to see all spool requests). To have
that access the user must have S_ADMI_FCD authorization object in the profile with
SPOR (or SP01) value of S_ADMI_FCD parameter (maintained by Security).
2. To access a particular jobs output in the spool, the user must have
S_SPO_ACT object in the profile with SPOAUTH parameter matching the value used
in the Print Specifications of the job (see p. 3.d above).
3. Levels of access to the spool (display, print once, reprint, download, etc) are
controlled by SPOACTION parameter of S_SPO_ACT. The user must have at least
BASE access (display).
On-line reports:
1. Exactly the same configuration can be maintained for any output produced
from R/3. If a user clicks Parameters button on a SAP Printer selection dialog, it
allows to specify all the parameters as described in p. 3 of
Scheduling background jobs section. Thus any output created by an online report
can be saved and accessed by any user authorized to access that spool request
(access restriction provided by the Authorization field of the spool request
attributes, see p. 3.d of Scheduling background jobs section).
Access to reports output:
1. A user that had proper access (see Configuring user access above) can
retrieve a job/report output through transaction SP01.
2. The selection screen can be configured by clicking Further selection
criteria button (e.g. to bring Spool request name (suffix 2) field or hide other
fields).
3. The following fields can be used to search for a specific output (Note that
Created By must be blank when searching for scheduled jobs outputs)
a. Spool request name (suffix 2) corresponds to a spool name in p. 3.b in
Scheduling background jobs section above).
b. Date created to find an output of a job that ran within a certain date range.
c. Title corresponds to spool Title in p. 3.c in Scheduling background jobs
section above).
d. Department - corresponds to spool Department in p. 3.e in Scheduling
background jobs section above).
4. Upon entering selection criteria, the user clicks the Execute button to
retrieve the list of matching spool requests.
5. From the spool list the user can use several function such as view the
content of a spool request, print the spool request, view attributed of the spool
request, etc. (some functions may need special authorization, see p.3 in
Configuring user access)
a. Click the Print button to print the spool request with the default attributes
(usually defined with the job definition). It will print it on a printer that was
specified when a job was created.
b. Click the Print with changed attributed button to print the spool request
with the different attributes (e.g. changing the printer name).
c. Click the Display contents button to preview the spool request contents. A
Print and Download functions are available from the preview mode.
Using JOB_OPEN,JOB_SUBMIT,JOB_CLOSE
REPORT YJob .
DATA : v_jobhead LIKE tbtcjob.
DATA : v_jobcount LIKE tbtcjob-jobcount.
DATA : v_eventparm LIKE tbtcjob-eventparm.
DATA : v_flg_released TYPE c.
DATA: e_error.
DATA: running LIKE tbtcv-run.
TYPES: esp1_boolean LIKE boole-boole.
CONSTANTS: esp1_false TYPE esp1_boolean VALUE ' ',
esp1_true TYPE esp1_boolean VALUE 'X'.
CONSTANTS: true TYPE boolean VALUE esp1_true,
false TYPE boolean VALUE esp1_false.
PARAMETERS: v_jobnam LIKE tbtcjob-jobname,
v_report LIKE sy-repid,
v_varian LIKE raldb-variant,
v_uname LIKE sy-uname.
START-OF-SELECTION.
add the new job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
delanfrep = 'X'
jobname = v_jobnam
IMPORTING
jobcount = v_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
e_error = true.
ELSE.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = v_uname
jobcount = v_jobcount
jobname = v_jobnam
report = v_report
variant = v_varian
EXCEPTIONS
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
OTHERS = 10.
IF sy-subrc <> 0.
e_error = true.
ELSE.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
EVENT_ID = IC_WWI_WORKPROCESS_EVENT
EVENT_PARAM = V_EVENTPARM
EVENT_PERIODIC = 'X'
jobcount = v_jobcount
jobname = v_jobnam
strtimmed = 'X'
IMPORTING
job_was_released = v_flg_released
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
e_error = true.
ELSE.
DO.
CALL FUNCTION 'SHOW_JOBSTATE'
EXPORTING
jobcount = v_jobcount
jobname = v_jobnam
IMPORTING
ABORTED =
FINISHED =
PRELIMINARY =
READY =
running =
SCHEDULED =
EXCEPTIONS
jobcount_missing = 1
jobname_missing = 2
job_notex = 3
OTHERS = 4.
IF sy-subrc <> 0.
e_error = true.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF running = space.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
ENDIF.
We all might have seen the code "IF 1=2. ....do this...EndIF" and we also know that this code never turns true. The main purpose of such code is for "Maintainability" of the program. Confused?? Read the following:
Depending upon the scenario, we would either issue the messages in the program using MESSAGE statement or sometimes might have to call the standard function module MESSAGE_PREPARE to prepare the whole message and use it wherever required.
CALL FUNCTION 'MESSAGE_PREPARE'
EXPORTING
msg_id = msg_id
msg_no = msg_no
MSG_VAR1 = sy-msgv1
MSG_VAR2 = sy-msgv2
MSG_VAR3 = sy-msgv3
MSG_VAR4 = sy-msgv4
IMPORTING
MSG_TEXT = tdoc-text
EXCEPTIONS
FUNCTION_NOT_COMPLETED = 1
MESSAGE_NOT_FOUND = 2
OTHERS = 3.
Assume that we have defined custom message class for issuing the messages. If we have to modify certain message in this message class, we first need to check for the where-used list of the message to study the impact of the message change. If the message is issued using the MESSAGE statement in any program, then that program would appear in the where-used list. But if the message is used in the program using the FM MESSAGE_PREPARE or any similar function module, then this program would not appear in the where-used list. So in order to have this program include in the where-used list, we would code the following after the call to the function module MESSAGE_PREPARE.
IF 1=2.
Message E003(xx).
ENDIF.
Since the check "IF 1=2" never gets true, the message would never trigger in the program and this program would appear in the where-used list of that message.
‎2007 Jul 17 8:44 AM
Hi MArk,
Through SM36 -> Press F6 -> Give name of your program -> Save it
Then Press F5 -> Click on Date/Time , Give parameters and
Save it .
Reward if useful!