01-28-2008 10:39 AM
Hi experts,
I want to download data from mara into flat file and also i want to schedule this job in background...
How can i schedule the jobs in background..
01-28-2008 10:46 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.
********************************************
You can use SM36 and use the "Job Wizard" to define a background job in simple step by step procedure
Or
Goto SM37 and specify a job name.
Next specify the ABAP Program Name of the report you want to execute under Job Step.
Then click on "Extended Job Selection" and goto the Period Tab.
There select "Only Periodic Jobs" and then specify the frequency of execution based on Months, Weeks, Days, Hours or Minutes.
2)you can execute the report in background in SM37 , there are two options , one is as said using f9 or you can make SY-BATCH eq 'X'.
if x run the report or exit from the program.
so this way you can execute the report in background and check the spool in sm37
In order to restrict the user to run it only in background , you can as well check for SY-BATCH condition.
The other way is try to remove "execute in foreground" option from the menu and this can be done with the function module .
data: begin of int_exc occurs 0,
code like sy-ucomm,
end of int_exc.
data wf_repid .
initialization.
clear int_exc.
int_exc-code = 'ONLI'.
append int_exc.
int_exc-code = 'PRIN'.
append int_exc.
move: sy-repid to wf_repid .
call function 'RS_SET_SELSCREEN_STATUS'
exporting
p_status = '%_00'
p_program = 'wf_repid'
tables
p_exclude = int_exc
****************************************
SAP background processing automates routine tasks and helps you optimize your organizations SAP computing resources. Using background processing, you tell the SAP System to run programs for you. Background processing lets you move long-running or resource-intensive program runs to times when the system load is low. It also lets you delegate to the system the task of running reports or programs. Your dialog sessions are not tied up, and reports that run in the background are not subject to the dialog-step run-time limit that applies to interactive sessions.
yes we can run a call transaction program in background by using mode N.
Create a Variant for your interface program and Schedule it using SM36 Tcode.
SM37 tells you the status of the program, whether it is running normally or not.
For further help you can check these links..which i find good.
http://help.sap.com/saphelp_nw2004s/helpdata/en/c4/3a7ed1505211d189550000e829fbbd/frameset.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/ed/a9bb3f8e236d3fe10000000a114084/content.htm
http://aspalliance.com/1129_Background_Processing_SAP_R3_System
Reward Points if found helpfull..
Cheers,
Chandra Sekhar.
01-28-2008 10:50 AM
U can't schedule download jobs in background.
If u do so, it goes to dump.
U have to run the download jobs only in foreground
01-28-2008 10:51 AM
Hi Manjula,
You cannot schedule any job that involves UPLOAD or DOWNLOAD data from/to Presentation Server. You cannot schedule the job.
Regards,
Mukesh Kumar
01-28-2008 10:56 AM
Hi,
Create a program which creates a file on to application server. This is because your background job will not work if you are trying to download the flat file onto presentation server. You can schedule this program to run in background and check the file on the path in application server.
Once the file is downloaded to application server you can download this file to presentation server through utilities like T-code CG3Y or Create a small sample program which downloads data from application server to presentation server.
Lots of sample code is available on different sites for both the things mentioned.
Regards,
Mayank
01-28-2008 10:57 AM
hi
good
1- Write the report using GUI _DOWNLOAD function module and upload the data from MARA table to flat file.
2-Use sm36 tcode to schedule the job in background.
thanks
mrutyun^
01-28-2008 11:04 AM
GUI_* and WS_* function modules do not work in background
When scheduling a job in the background the appropriate statement to read in your file is OPEN DATASET, and the file must be on the file system that the SAP server can see.
At anytime, a user can switch of the Personal Computers even though the job is still running in the background. Therefore GUI_* and WS_* function modules are not designed to work in that way, as they need to access your personal computer file.