‎2007 Apr 16 8:05 AM
Dear all,
I want to know how to execute a program automatically in background.
FYIP.
i am using the code
case sy-ucomm.
WHEN 'OPEN'.
SUBMIT ZVE_OPEN_ORDER AND RETURN. (it don't have a selection screen)
when clicking the push button the program should be executed in background only.
‎2007 Apr 16 8:09 AM
Hi
declare a paramter on selctionscreen like:
PARAMETERS: p_bjob TYPE c DEFAULT 'X' NO-DISPLAY.
write the code in End-of-selection:
END-OF-SELECTION.
IF p_bjob = 'X'.
CONCATENATE sy-cprog sy-datum sy-uzeit
INTO jobname SEPARATED BY '_'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = jobname
IMPORTING
jobcount = jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING
out_archive_parameters = arc_params
out_parameters = print_params
valid = valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF valid = chk.
SUBMIT <Report> with parameters
AND RETURN
USER sy-uname
VIA JOB jobname
NUMBER jobcount
TO SAP-SPOOL
SPOOL PARAMETERS print_params
ARCHIVE PARAMETERS arc_params
WITHOUT SPOOL DYNPRO.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MESSAGE i029 WITH jobname.
ENDIF.
ELSE.
MESSAGE s000 WITH text-003.
STOP.
ENDIF.
ENDIF.
reward if useful
regards,
Anji
‎2007 Apr 16 8:14 AM
Hi Balaji,
Here is the detailed way of doing the process and for more below is the link to go:
To have an idea about the background scheduling let us take an example of a long report. Suppose we execute this report in interactive mode, it takes several minutes and during time the SAP System is blocked for any further input. As a result, you will not be able to interact with SAP sessions anymore.
However, when you run the report non-interactively, you can interact with the SAP sessions while processing the report in the background. For executing jobs in non-interactive mode, schedule the job for background processing. To create a background processing job you should specify:
· The name of the report
· The name of any variant it needs
· What to do with output
· When to start it
After this, the SAP system does not require users intervention and can proceed with the job even without you. It executes the report and prints the output using printer or output controller. While scheduling a job in background process, three parameters should be specified. These parameters are:
· Definition of programs
· Its start time
· The printing specification for getting the prints as required
After this, you can check whether your job was executed successfully and display a log of any system messages.
For scheduling background processing, you have to direct the system to process an ABAP/4 or external program in the background. This is a two-step process:
· Scheduling the program
· Releasing the job
This needs to have a special authorization for releasing and scheduling the job. Generally, the system administrator, who organizes and monitors background processing, supervises the release of these jobs. Many users are also authorized to schedule background processing of reports. You cannot schedule a job unless and until you have a release authorization. If a user is authorized and has specified a start date or selected "start immediately," he or she can release the job.
Authorized users can change start time. A program can be scheduled as a separate job or you can append it to an existing job, which has not yet been processed. Background process can be run while doing some other online work. However, this can adversely affect online operation and should be avoided. For example, if you run a program that locks the database, the work of online users will be hampered or stopped. Often, long-running reports are scheduled automatically or semi-automatically for background processing.
First Step
Initiate the job scheduling function. Standard job scheduling must be used in case of scheduling of an external command or external program as a background job and ABAP job scheduling function can be used to schedule ABAP programs. For starting a standard job scheduling function choose the following:
Administration menu bar option à CCMS option à Jobs option à Definition option.
For starting ABAP job scheduling function, navigate to ABAP Editor and choose Program menu bar option à Execute option à Background option.
Second Step
Now define a job. Using the Job Wizard you can define your job. From the Application toolbar, choose the wizard button. After this, the initial screen of the SAP Job Wizard appears. The Job Wizard is available only from the standard job scheduling function.
Third Step
Now, you have to save the job. When it displays the message "Job saved" it means the job has been successfully scheduled. We know that a job must be released before it is scheduled. Only authorized users can release the job, otherwise your system administrator will release your job.
Fourth Step
This is the last step of scheduling. In this step you have to check the status of your job. For this you need to choose System menu bar option à Own jobs option.
In SAP System, the background processing runs according to your instructions. In case a list is generated by the report, the report either prints directly or waits for you in the SAP output controller. The status of background processing can be checked for its correctness.
http://aspalliance.com/1129_Background_Processing_SAP_R3_System
If this is help full dont forget to award points.
Thanks and regards
Vipin Das