‎2008 May 26 8:58 AM
Hello,
I would like to create a batch-job from within my abap code.
Therefore I want to determine a abap-report to be executed every X-Hours.
Do you have some sample code for creating a batch job?
I need to do it in abap because I want to create a TN to trigger the code creating the job.
So the user interaction will be minimal to start a periodic batch job.
thanks.
‎2008 May 26 9:12 AM
use FM job_open and job_close (job_submit or SUBMIT). for examples do a where used on job_open FM,
‎2008 May 26 9:32 AM
REPORT Z_DG_CREATE_BATCH_JOB.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = 'Dynamic'
IMPORTING
JOBCOUNT =
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.thank you.
Can you tell me what that job count is?
The Jobname is be be set my me, isn't it, but where does jobcount come from?
‎2008 May 26 9:57 AM
Hi micky,
I implemented the code but the debugger says that the jobname has a wrong type. I gave him a c(7). what type do I need to use?
‎2008 May 26 9:58 AM
Hi,
take the structure BTCEVTJOB. there 2 fields jobname & jobcount.
Reward if helpful.
Thanks.
‎2008 May 26 10:00 AM
‎2008 May 26 10:18 AM
thank you. that works.
I cannot find the fitting type for JOB_WAS_RELEASED.
Can you tell me?
‎2008 May 26 10:32 AM
Hi,
job_was_released = 'x' ......if it gets successful....
This parameter is returned with the value X, if the job was automatically released for execution at the scheduled start time.
A job is automatically released if the user has release authorizaton (authorization Background Processing: Operations on Background Jobs), RELE authorization or object Background Processing: Background Administrator.
no need to provide i think...u can proceed in dat way....
Thanks.
Edited by: Sagar@MM on May 26, 2008 5:34 PM
‎2008 May 26 10:40 AM
hi,
but it is at IMPORTING which means the FM will give me that value, my problem is that I don't know where I can save it in. And that part will give me debug errors.
‎2008 May 26 10:42 AM
‎2008 May 26 10:48 AM
great the errors are gone. thank you guys.
Now there are neither syntax errors nor debug errors.
Once I start it now I get an announcement saying: "Printer for Jobsteps inappliably. No autmatic ouput available"
Could the problem be that the programms I use in the background job write something to screen?
Should I delete the code writing to screen?
Where do I specify the intervalls the job is called?
Edited by: Daniel Gerne on May 26, 2008 11:53 AM
‎2008 May 26 10:56 AM
this is probably due to the printer you have defined. Try and use the default frontend printer (LOCL).
‎2008 May 26 10:58 AM
‎2008 May 26 11:14 AM
Still 2 Questions:
Where is the intervall for the jobs defined?
How do I set the starttime of the first run?
‎2008 May 26 9:36 AM
Hi,
- define user event by sm62
- create the required job event periodic with your new event
- create a very small report with only call of function BP_EVENT_RAISE with your new event
- make a transaction for your new small start report
regards
Walter Habich
‎2008 May 26 9:39 AM
Hi walter,
that's what I tried first. But the problem is that once a job is event-periodic i can't define the intervalls anymore. Therefore I need to create the job in abap.
edit: OK I think the fm will get me that jobcount after executing.
Edited by: Daniel Gerne on May 26, 2008 10:46 AM
‎2008 May 26 9:49 AM
Hi
U need to indicate all chararcteristics of the job while closing it by fm JOB_CLOSE
Max
‎2008 May 26 9:56 AM
job count will show you the "ID Number of Background Job", you should declare it of type Char length 8, any variable will do.
This method is called as "Full Control Method".
Use JOB_OPEN to create a background job. The function module returns the unique ID number which, together with the job name, is required for identifying the job.
Once you have "opened" a job, you can add job steps to it with JOB_SUBMIT and submit the job for processing with JOB_CLOSE.
Use JOB_SUBMIT to add a job step to a background job that you have opened with JOB_OPEN.
A job step is an independent unit of work in a job, the execution of an ABAP or external program. Each job step can have its own authorizations user and printer/optical archiving specifications.
Hope this helps, reward points it useful.
Vishal.
‎2008 May 26 9:59 AM
Hi Daniel,
select options could be stored by export/import to/from database:
...
...
...
DESCRIBE TABLE t_vkpos LINES n.
READ TABLE t_vkpos INDEX n.
lastmaxvbeln = t_vkpos-vbeln.
PERFORM get_varimemkey USING p_vari CHANGING vkposmemkey.
EXPORT lastmaxvbeln TO DATABASE indx(zk) ID vkposmemkey.
IF NOT sy-subrc IS INITIAL.
...
...
...
PERFORM get_varimemkey USING p_vari CHANGING vkposmemkey.
IMPORT lastmaxvbeln FROM DATABASE indx(zk) ID vkposmemkey.
IF sy-subrc IS INITIAL.
ls_vbeln-sign = 'I'.
ls_vbeln-option = 'GT'.
ls_vbeln-low = lastmaxvbeln.
APPEND ls_vbeln.
ENDIF
...
...
...
FORM get_varimemkey USING vari TYPE raldb_vari
CHANGING memkey TYPE char22.
IF vari IS INITIAL.
RAISE get_varimemkey_unexepected.
ENDIF.
CONCATENATE 'Z_VKPOS_' vari INTO memkey.
ENDFORM. "
regards
Walter Habich