01-16-2006 9:02 AM
Hallo !
I'm calling a 'Z' function module from a class method.
I want the calling will start immediately a new job.
(That I will see in SM37)
(Like we can do with submit statement)
Is there a way to this ?
(I need the function will start a job - because
I want to save the function log in the Job list.)
Thanks in advance,
N.S.
01-16-2006 9:29 AM
Thanks you all for your answers.
I still have a problem -
My problem is that I have a function and
not a report (!!!).
I do not know how to include it in a new job.
I do not want to call the function from a report
because the function get in it's import parameters
a very large table that I don't want to send
to the report using the memory ...
Thanks ,
N.S.
01-16-2006 9:04 AM
01-16-2006 9:11 AM
Hi
You shouls use fm JOB_OPEN to open the job and JOB_CLOSE to schedule the job:
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = <MY_JOB>
IMPORTING
JOBCOUNT = JOBCOUNT.
SUBMIT <MY_REPORT>
USER SY-UNAME VIA JOB <MY_JOB> NUMBER JOBCOUNT
WITH ..... AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOBCOUNT
JOBNAME = <MY_JOB>
STRTIMMED = 'X'.
Max
Max
01-16-2006 9:13 AM
step : 1
Sample Program: Creating a Job with JOB_OPEN
<b>explanation :</b>
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.
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.
step 2;
Sample Program: Adding an ABAP Job Step
<b>explanation :</b>
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.
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.
step 3
Sample Program: Immediate Start with JOB_CLOSE
<b>explanation :</b>
Use JOB_CLOSE to pass a background job to the background processing system to be run. Once you have "closed" a job, you can no longer add job steps to it or change job/job step specifications.
The function module returns an indicator as to whether the job was automatically released or not. A job is automatically released to run only if the user who scheduled the job has RELE release authorization for the authorization object Operations on background jobs.
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.
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.
in step 1 we will create a job with name etc..
in step 2 we will assign work to this job
step 3 : we will close the job inorder make it scheduled .
Regards
srikanth
added descriptions to each steps
01-16-2006 9:29 AM
Thanks you all for your answers.
I still have a problem -
My problem is that I have a function and
not a report (!!!).
I do not know how to include it in a new job.
I do not want to call the function from a report
because the function get in it's import parameters
a very large table that I don't want to send
to the report using the memory ...
Thanks ,
N.S.
01-16-2006 9:39 AM
01-16-2006 9:41 AM
hi
call <fn> starting new task.
this statement calls fn module parallelly
01-16-2006 9:54 AM
Hi !
Unfortunately It doesn't work -
The function is executed in New task ,
but a new job Isn't created.
Thanks ,
N.S.
01-16-2006 10:08 AM
01-16-2006 1:10 PM
Hi !
after I added a "commit work"
statement - the function is called ,
but unfortunately no job is created ...
Maybe It's not possible ? ....
Thanks ,
N.S.
01-16-2006 1:12 PM
01-16-2006 1:19 PM
Hi !
We have a 'Z' class.
In It we have a method.
at the end of the method I call a 'Z' RFC
function module (in the same system and client).
I call it like this :
CALL FUNCTION 'ZHRF_TM_IN'
IN BACKGROUND TASK
EXPORTING
IV_DATE = SY-DATUM
IR_PERNR =
TABLES
IT_TM = LT_TM
.
I<u> want that the function will be called in a new JOB.</u>(because in the function there are "write" statements,
and I want to see them in the list attached to job).
Thanks.
01-16-2006 5:43 PM
To my knowledge you cannot schedule a function module with sm37 (and the functions JOB_OPEN does nothing else) But you could create a report which does nothing else but calling the function module.
Then you create a new function which does the jop_open
part like Max explainded. There you call your newly created report which does the function call.
And within your method you call the new function.
Christian
01-17-2006 11:14 AM
Hi Christian !
Thank you very much for your answer.
I have got the same conclusion -
Apparently ,There is no way to schedule
a function module in SM37.
So I did something very similar to what you suggest.
(and I send the tables parameters of the function to the
report by an 'export TO DATABASE' statement.
Thanks ,
N.S.