Function Job_Close
Hi,
I try to use following function:
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = u_f_jobcount
jobname = u_f_jobname
predjob_checkstat = 'X'
pred_jobcount = pred_jobcount
pred_jobname = pred_jobname
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.
But I alway get the exception invalid startdate although I want to start the job after the first job (pred_jobcount and red_jobname) is finished. Is there more parameters which I have to use when I want to start the second job after the first job?
I have found the solutions, thank you raymond for the link:
Important: If you specify a predecessor job directly in your
program (not interactively chosen), then be sure that the
predecessor job has the status Scheduled or Released when
you schedule the successor job. Otherwise, the successor
scheduling will fail. That is, a job that is active or
already completed cannot be specified as a predecessor job.
you have to be sure that the pred_job is not already completed.
Similar Messages
-
Function module JOB_CLOSE throwing exception
Hello,
We have a batch job which has 2 steps:
1) Step 1 uses job_open, job_submit and job_close and immediately schedules batch job A/P_ACCOUNTS which in turn creates batch input sessions A/P_ACCOUNTS.
2) Step 2 Processes A/P_ACCOUNTS sessions created yesterday or today.
In few cases, job_close is throwing exception job_close_failed. I believe that error is coming due to non availability of work processes. Job A/P_Accounts is defined as a class C batch job. There is a check in the FM job_close which does the following check:
- if the class of a batch job is B or C, it calculates the number of free work processes. If there are no work processes available then JOB_CLOSE throws JOB_CLOSE_FAILED exception.
- If the class is u2018Au2019, it skips this check.
We have an option of changing the class of batch job to A but there are some system critical jobs that are running as class A.
My question is:
In the code, JOB_CLOSE has been called for scheduling the job A/P_ACCOUNTS with parameter start immediately. Can anyone please let me know what will happen if function JOB_CLOSE is not called with start immediately option? Will the batch job A/P_ACCOUNTS wait till the time work processes are available?
Or, can anything else be done to solve the issue?
Regards,
SiddharthHI,
This is my experience with job_close..
when i was working in zprograms then i was able to scedule it any time i wanted..
but in my standard program when i tried it didn't worked....
so i have to use that option of starting it immediately..
and then it is working fine..
now if i schedule 5 jobs... one after another..
its get queued up...and once the processor is free...its working..
my code of job close
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = job_count
jobname = job_name
strtimmed = yes " yes = 'X'
IMPORTING
job_was_released = job_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
invalid_target = 8
OTHERS = 9.
regards,
Yadesh -
How can I erase a job in SM35 using the job_open and job_close functions?
Hi!
I call and execute a job in the SM35 transaction with the functions below, but how can I erase the job from SM35. Because when the functions are executed in the JOB_CLOSE the variable jobrele return me an 'X' that means that the job is executed but I see that the job is not erased from the transaction.
Thanks for the help.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobgroup = bi
jobname = jname
IMPORTING
jobcount = jnumb
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 99.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = sy-uname
jobcount = jnumb
jobname = jname
REPORT = sy-repid
IMPORTING
STEP_NUMBER = v_step_number.
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jnumb
jobname = jname
strtimmed = 'X'
targetsystem = batchsys
IMPORTING
job_was_released = jobrele
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
no_release_privilege_given = 7
OTHERS = 99.hi
try this FM
<b>BP_JOB_DELETE</b>
the same FM is also called in
<b>
SCMA_DELETE_JOB</b>
plz reward if useful -
JOB_CLOSE function module
Hi Experts,
I am calling the function module 'JOB_CLOSE' as follows passing 3 (job name, job count, start immediately) parameters.But it is failing and the sy-subrc value is 4 (job_close_failed = 4). Please tell me how to correct this.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = v_jobcount
jobname = v_jobname
strtimmed = 'X'
IMPORTING
job_was_released = v_ok
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 .
Thanks,
neethu.Hi,
Please refer the sample code
ATA: 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.
Hope it helps
Regards
Sumana -
Direct Print smartform to printer via JOB_OPEN function and using SUBMIT
Hello,
I can not able to printout from forms . I can able to get spool number but it is not printing directly to printer (printer Output should come automatic). I am getting error message in SP02 as Status ->Waiting when i check is showing as "Frontend unavailable".
please find sample code below to test same:
REPORT ZTEST_1 .
constants : wc_x type c value 'X'.
DATA: wv_val(1) TYPE c,
wv_pripar TYPE pri_params,
wv_arcpar TYPE arc_params,
wv_lay TYPE pri_params-paart value 'DINA4',
wv_lines TYPE pri_params-linct,
wv_rows TYPE pri_params-linsz.
data: wv_jobname like tbtcjob-jobname.
data: wv_jobcount like tbtcjob-jobcount,
wv_host like msxxlist-host.
data: begin of ws_starttime.
include structure tbtcstrt.
data: end of ws_starttime.
data: wv_starttimeimmediate like btch0000-char1 value 'X',
wv_flag(1),
WV_DO_PRINT type i.
concatenate sy-tcode+0(4) ' ' 'sample test - print'
into wv_jobname.
*Job open
call function 'JOB_OPEN'
exporting
delanfrep = 'X'
jobname = wv_jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
importing
jobcount = wv_jobcount
if sy-subrc eq 0.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters = wv_arcpar
in_parameters = wv_pripar
LIST_NAME = 'JOB NAME'
LIST_TEXT = 'test_text'
RECEIVER = sy-uname
IMMEDIATELY = wc_x
RELEASE = wc_x
USER = sy-uname
layout = wv_lay
no_dialog = wc_x
IMPORTING
out_archive_parameters = wv_arcpar
out_parameters = wv_pripar
valid = wv_val
break-point.
wv_pripar-PRSAP = space.
wv_pripar-PRIOT = 1.
wv_pripar-prrec = sy-uname.
if not wv_val is initial.
*call external program and pass data
submit SF_EXAMPLE_01
USER sy-uname
via job wv_jobname
number wv_jobcount
TO SAP-SPOOL
SPOOL PARAMETERS wv_pripar
ARCHIVE PARAMETERS wv_arcpar
WITHOUT SPOOL DYNPRO
AND RETURN.
endif.
*Close job
ws_starttime-sdlstrtdt = sy-datum .
ws_starttime-sdlstrttm = sy-UZEIT.
ws_starttime-IMSTRTPOS = WC_X .
call function 'JOB_CLOSE'
exporting
event_id = ws_starttime-eventid
event_param = ws_starttime-eventparm
EVENT_PERIODIC = space
jobcount = wv_jobcount
jobname = wv_jobname
laststrtdt = ws_starttime-laststrtdt
laststrttm = ws_starttime-laststrttm
prddays = 0 "set to 0 not repeat
prdhours = 0
prdmins = 0
prdmonths = 0
prdweeks = 0
sdlstrtdt = ws_starttime-sdlstrtdt
sdlstrttm = ws_starttime-sdlstrttm
strtimmed = wv_starttimeimmediate
endif.Hi,
As far as printing to devices not all devices support Bluetooth. Many devices support Bonjour protocal, IPP. The main print port is 9100. Additionally you can see what IO protocols are supported on a product by looking at the EWS (Embedded WebServer) there should be a networking page with that information. Port 9100 is your basic print port and different devices will support different formats (PDF, JPEG, PCL5, PCL6). If there is an API you can find (i am not familiar with J2ME availible calls, then you can use those and send the data to port 9100. Again that is the basic path most printers will accept. not all devices support bonjour not all device support bluetooth etc... Hope that helps and good luck.
I am an HP Employee. -
How we will use these Job_open and Job_submit job_close??
Hi Experts,
i am new in Developement, i need one help here my problem is
I have one issue which is a report here i am getting the data into internal table, that data fetching i want to schedule it in background job..
can any body tell me how can i use the JOB_OPEN and JOB_SUBMIT function modules....
plz provide any example..
Thanks in Advance,
Venkat NHi,
Here is the sample program
*Submit report as job(i.e. in background)
data: jobname like tbtcjob-jobname value
' TRANSFER TRANSLATION'.
data: jobcount like tbtcjob-jobcount,
host like msxxlist-host.
data: begin of starttime.
include structure tbtcstrt.
data: end of starttime.
data: starttimeimmediate like btch0000-char1.
Job open
call function 'JOB_OPEN'
exporting
delanfrep = ' '
jobgroup = ' '
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
importing
jobcount = jobcount
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
if sy-subrc ne 0.
"error processing
endif.
Insert process into job
SUBMIT zreport and return
with p_param1 = 'value'
with p_param2 = 'value'
user sy-uname
via job jobname
number jobcount.
if sy-subrc > 0.
"error processing
endif.
Close job
starttime-sdlstrtdt = sy-datum + 1.
starttime-sdlstrttm = '220000'.
call function 'JOB_CLOSE'
exporting
event_id = starttime-eventid
event_param = starttime-eventparm
event_periodic = starttime-periodic
jobcount = jobcount
jobname = jobname
laststrtdt = starttime-laststrtdt
laststrttm = starttime-laststrttm
prddays = 1
prdhours = 0
prdmins = 0
prdmonths = 0
prdweeks = 0
sdlstrtdt = starttime-sdlstrtdt
sdlstrttm = starttime-sdlstrttm
strtimmed = starttimeimmediate
targetsystem = host
exceptions
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07
others = 99.
if sy-subrc eq 0.
"error processing
endif.
Regards
Sudheer -
How to send spool to Distribution List using JOB_CLOSE
Please help on sending Distribution list when job defined using JOB_OPEN, JOB_Submit and JOB_CLOSE
Thanks.Hi, this is code:
DATA WA_RECIPIENT LIKE swotobjid.
CONSTANTS: gc_objname TYPE oj_name VALUE 'RECIPIENT'.
PERFORM get_distribucion_list USING 'NAME_LIST' " name of List of distribution
CHANGING WA_RECIPIENT.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = l_jobcount
jobname = l_jobname
strtimmed = 'X'
recipient_obj = wa_recipient
IMPORTING
job_was_released = l_libero
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.
FORM get_distribucion_list USING p_objnam TYPE so_obj_nam
CHANGING p_wa_recipient LIKE swotobjid.
DATA: it_tab LIKE STANDARD TABLE OF soxdl
INITIAL SIZE 0 WITH HEADER LINE.
CHECK NOT p_objnam IS INITIAL.
CALL FUNCTION 'SO_DLI_LIST_READ_XDL'
EXPORTING
dli_generic_name = p_objnam
public = 'X'
subscript = 'X'
TABLES
dli_display_tab = it_tab
EXCEPTIONS
communication_failure = 1
dl_list_no_entries = 2
owner_not_exist = 3
system_failure = 4
x_error = 5
parameter_error = 6
OTHERS = 7
IF sy-subrc = 0.
READ TABLE it_tab INDEX 1.
IF sy-subrc = 0.
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = p_wa_recipient-logsys
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
MOVE gc_objname TO p_wa_recipient-objtype.
CONCATENATE it_tab-dlitp it_tab-dliyr it_tab-dlino
INTO p_wa_recipient-objkey.
ENDIF.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. -
How to register the recipient when create job by function
I am now use JOB_OPEN , JOB_SUBMIT and JOB_CLOSE to create a job in the program. And need to post the result of the report to the person by email.
Can you tell me how to register the recipient when create the job.
( in sm36, it is easily to do but how to do in coding? )
regards,
slamHi
I think in Back ground using the above fun modules you can't send a mail to the receipient.
see the use of the above fun modules;
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 ybrep
WITH < sel Screen>
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 points if useful
Regards
Anji -
Problem in using JOB_OPEN, JOB_SUBMIT & JOB_CLOSE
Hi,
I using following code to submit the Job. But Job which is created is getting canceled in SM37 can anybody let me where the error is ?
I used GET_PRINT_PARAMETERS function module too but same results.
Thanks in advance.
DATA: TBTCJOB TYPE TBTCJOB,
NUMBER1 LIKE TBTCJOB-JOBCOUNT,
authcknam TYPE tbtcjob-authcknam,
JOBCOUNT LIKE TBTCJOB-JOBCOUNT,
JOBNAME LIKE TBTCJOB-JOBNAME,
ARC_PARAMS LIKE ARC_PARAMS,
OUT_PARAMS LIKE PRI_PARAMS,
VALID,
VALID_FOR_SPOOL.
jobname = '634_1155'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = jobname
jobclass = 'A'
IMPORTING
jobcount = jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF SY-SUBRC EQ 0.
authcknam = sy-uname.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = authcknam
jobcount = jobcount
jobname = jobname
* PRIPARAMS = OUT_PARAMS
report = 'RMDATIND'
variant = 'TEST2'
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.
data lv_time like sy-uzeit.
lv_time = sy-uzeit + 10.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = jobcount
JOBNAME = jobname
sdlstrtdt = sy-datum
sdlstrttm = lv_time
STRTIMMED = 'X'
EXCEPTIONS
OTHERS = 01.
ENDIF.
ENDIF.
Edited by: Thomas Zloch on Jun 15, 2010 6:28 PMHi,
Thanks for looking in this issue Job log is showing this
2010/06/15 12:31:00 Job started 00 516 S
2010/06/15 12:31:00 Step 001 started (program RMDATIND, variant TEST2, user ID VANNAM) 00 550 S
2010/06/15 12:31:00 634_1155: This job was started periodically or directly from SM36/SM37 BD 076 I
2010/06/15 12:31:00 Job 634_1155: Data does not match the job definition; job terminated BD 078 E
2010/06/15 12:31:00 Job cancelled after system exception ERROR_MESSAGE 00 564 A -
JOB_OPEN - SUBMIT - JOB_CLOSE - User Name for the Job
Hi,
I have a code like that:
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = lv_jobname
IMPORTING
jobcount = lv_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
* Call Update PO from Sales Order
SUBMIT zpcc_mm_upo3
WITH p_vbeln = puv_vbeln
USER lc_uname
VIA JOB lv_jobname NUMBER lv_jobcount
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
strtimmed = lc_true
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.
In this code as you see I can run the SUBMIT program with a specified user. But the creator of the job always becomes SY-UNAME. So is there a way to specify the user name for a job creator? I don't want to use SY-UNAME.
Thanks,Hio try this way...
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = lv_jobname
IMPORTING
jobcount = lv_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
"Comment this
* Call Update PO from Sales Order
SUBMIT zpcc_mm_upo3
WITH p_vbeln = puv_vbeln
USER lc_uname
VIA JOB lv_jobname NUMBER lv_jobcount
AND RETURN.
"Comment end
* Call function to submit the job
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = wa_authchknam "Pass the Other User name you want
jobcount = lv_jobcount
jobname = lv_jobname
REPORT = 'zpcc_mm_upo3'
VARIANT = jobs-variant "Create Varaqint
PRIPARAMS = wa_PRI_PARAMS
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
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
strtimmed = lc_true
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.
Prabhudas -
Job_open,job_close
hello
plz let me know how to use job_open,jib_sumbit,job_close,
and the function modules related to it
thanks
aafaq husainHi aafaqhusain,
1. we can use like this
2.
report abc.
BREAK-POINT.
DATA : JN(32) TYPE C.
JN = 'JOB001'.
BREAK-POINT.
DATA : J(8) TYPE C.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = JN
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
JOBCLASS =
IMPORTING
JOBCOUNT = J
CHANGING
RET =
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.
DATA : P TYPE PRI_PARAMS.
P-PDEST = 'PRINTER'.
P-PDEST = 'LOCL'.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING NO_DIALOG = 'X'
MODE = 'CURRENT'
NEW_LIST_ID = $PRNEW
IMPORTING OUT_PARAMETERS = P.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
ARCPARAMS =
authcknam = 'MAMIT'
COMMANDNAME = ' '
OPERATINGSYSTEM = ' '
EXTPGM_NAME = ' '
EXTPGM_PARAM = ' '
EXTPGM_SET_TRACE_ON = ' '
EXTPGM_STDERR_IN_JOBLOG = 'X'
EXTPGM_STDOUT_IN_JOBLOG = 'X'
EXTPGM_SYSTEM = ' '
EXTPGM_RFCDEST = ' '
EXTPGM_WAIT_FOR_TERMINATION = 'X'
jobcount = J
jobname = JN
LANGUAGE = SY-LANGU
PRIPARAMS = P
REPORT = 'HINCF160'
VARIANT = 'A'
IMPORTING
STEP_NUMBER =
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
AT_OPMODE = ' '
AT_OPMODE_PERIODIC = ' '
CALENDAR_ID = ' '
EVENT_ID = ' '
EVENT_PARAM = ' '
EVENT_PERIODIC = ' '
jobcount = J
jobname = JN
LASTSTRTDT = NO_DATE
LASTSTRTTM = NO_TIME
PRDDAYS = 0
PRDHOURS = 0
PRDMINS = 0
PRDMONTHS = 0
PRDWEEKS = 0
PREDJOB_CHECKSTAT = ' '
PRED_JOBCOUNT = ' '
PRED_JOBNAME = ' '
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
STRTIMMED = 'X'
TARGETSYSTEM = ' '
START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
START_ON_WORKDAY_NR = 0
WORKDAY_COUNT_DIRECTION = 0
RECIPIENT_OBJ =
TARGETSERVER = ' '
DONT_RELEASE = ' '
TARGETGROUP = ' '
DIRECT_START =
IMPORTING
JOB_WAS_RELEASED =
CHANGING
RET =
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.
BREAK-POINT.
regards,
amit m. -
JOB_OPEN JOB_SUBMIT JOB_CLOSE
Hello Experts,
I have a requirement where I want to execute a portion of my code in the background inorder to reduce the performance issue.
This can be done through JOB_OPEN JOB_SUBMIT JOB_CLOSE command which generates a new JOB in the background mode.
JOB_OPEN
JOB_SUBMIT
JOB_CLOSE
Question : How can I pass the internal table with the values through JOB_SUBMIT??
Thanking you all in advance,
Warm Regards,
gayatri.Hi,
* Get Print Parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
no_dialog = 'X'
IMPORTING
valid = g_valid
out_parameters = gs_params.
* Open Job
* g_stim = '185800'.
CONDENSE g_var6.
CONCATENATE g_var8+6(2)
g_var8+3(2)
g_var8(2)
INTO g_stim.
g_sdat = sy-datum .
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = g_job
sdlstrtdt = sy-datum
sdlstrttm = g_stim
IMPORTING
jobcount = g_jobcount
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.
CONDENSE : g_var1,
g_var2,
g_var3,
g_var4,
g_var5,
g_var6,
g_var7,
g_var8.
gs_rspar-selname = 'P_USER'.
gs_rspar-kind = 'P'.
gs_rspar-low = g_var1.
APPEND gs_rspar TO gt_rspar.
gs_rspar-selname = 'P_PWD'.
gs_rspar-kind = 'P'.
gs_rspar-low = g_var2.
APPEND gs_rspar TO gt_rspar.
gs_rspar-selname = 'P_HOST'.
gs_rspar-kind = 'P'.
gs_rspar-low = g_var3.
APPEND gs_rspar TO gt_rspar.
gs_rspar-selname = 'P_FILE'.
gs_rspar-kind = 'P'.
gs_rspar-low = g_var4+2.
APPEND gs_rspar TO gt_rspar.
gs_rspar-selname = 'P_FNAME'.
gs_rspar-kind = 'P'.
gs_rspar-low = g_var5.
APPEND gs_rspar TO gt_rspar.
gs_rspar-selname = 'P_FILE1'.
gs_rspar-kind = 'P'.
gs_rspar-low = g_var6.
APPEND gs_rspar TO gt_rspar.
gs_rspar-selname = 'P_FILE2'.
gs_rspar-kind = 'P'.
gs_rspar-low = g_var7.
APPEND gs_rspar TO gt_rspar.
gs_rspar-selname = 'P_DEST'.
gs_rspar-kind = 'P'.
gs_rspar-low = 'SAPFTPA'.
APPEND gs_rspar TO gt_rspar.
gs_rspar-selname = 'P_COMP'. <----- This are Parameter value to be passed in background Program
gs_rspar-kind = 'P'.
gs_rspar-low = 'N'.
APPEND gs_rspar TO gt_rspar.
SUBMIT ztest123 VIA JOB g_job
NUMBER g_jobcount
* USING SELECTION-SCREEN
WITH SELECTION-TABLE gt_rspar
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS gs_params
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = g_jobcount
jobname = g_job
sdlstrtdt = g_sdat
sdlstrttm = g_stim
* 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 -
Job Scheduling using job_close
Hi gurus,
im trying to scheduke several jobs using the FM Job close, but the jobs are running paralel..
The first job its' schedule with a start date or imediate, and the letf ones are schedule to start after his precessor finish, but once i run the programa 4 jobs start running ...
Can any one help me on this?
Below goes my code...
DO njobs TIMES.
**Nome de Job
CLEAR: jobname, jobcount, job_release.
CLEAR: job_imediate, str_job.
ADD 1 TO ind_job.
WRITE ind_job TO str_job.
CONCATENATE 'EXECORC' sy-uname sy-uzeit str_job
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.
IF sy-subrc <> 0.
MESSAGE i003(zmapas).
EXIT.
ENDIF.
IF gv_global EQ 'X'.
**Submit job
SUBMIT z_mapa_execucao_orcamental
VIA JOB jobname NUMBER jobcount
WITH ano EQ ano
WITH so_perio IN so_perio
WITH so_date IN so_date
WITH so_org EQ so_org
WITH so_num IN so_num
AND RETURN.
ELSE.
***Limites
CLEAR: upper_bound, lower_bound.
upper_bound = njobs * ind_job.
lower_bound = upper_bound - njobs + 1.
CLEAR so_num.
REFRESH so_num.
LOOP AT tab_prog FROM lower_bound TO upper_bound.
so_num-sign = 'I'.
so_num-option = 'EQ'.
so_num-low = tab_prog-zlinha.
APPEND so_num.
ENDLOOP.
SUBMIT z_mapa_execucao_orcamental
VIA JOB jobname NUMBER jobcount
WITH ano EQ ano
WITH so_perio IN so_perio
WITH so_date IN so_date
WITH so_org EQ so_org
WITH so_num IN so_num
AND RETURN.
ENDIF.
IF ind_job EQ 1.
IF stdt_output-startdttyp EQ 'I'.
job_imediate = 'X'.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
sdlstrtdt = stdt_output-sdlstrtdt
sdlstrttm = stdt_output-sdlstrttm
strtimmed = job_imediate
IMPORTING
job_was_released = job_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
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE i003(zmapas).
EXIT.
ELSE.
CLEAR: predjob, predjobcount, stdt_output.
predjob = jobname.
predjobcount = jobcount.
MESSAGE s004(zmapas) WITH jobname.
ENDIF.
ELSE.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
* predjob_checkstat = 'X'
pred_jobcount = predjobcount
pred_jobname = predjob
* strtimmed = 'X'
IMPORTING
job_was_released = job_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
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE i003(zmapas).
EXIT.
ELSE.
CLEAR: predjob, predjobcount, stdt_output.
predjob = jobname.
predjobcount = jobcount.
MESSAGE s004(zmapas) WITH jobname.
ENDIF.
ENDIF.
Thanks in Advance,
Best Regards,
João MartinsHello.
First of all, parameter predjob_checkstat makes the second job to start only if the previous one ends without error. Probably this solves your problem at all ... the second waits to the end of the first to see if it ended with error or not.
I was analysing your problem. Parameter strtimmed can only be set in the first JOB_CLOSE. All the others cannot have this parameter set to 'X' if you want them to wait for the end of the previous ones.
So, try predjob_checkstat = 'X' and strtimmed = space.
Also, I have one example that is working:
*** Escalona um JOB para cada ficheiro encontrado.
LOOP AT t_processar.
CLEAR: w_jobcount, w_jobname, l_liberado.
ADD 1 TO l_conta.
MOVE l_conta TO l_conta2.
CONDENSE l_conta2.
CONCATENATE t_jobs-jobname l_conta2 INTO w_jobname.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = w_jobname
IMPORTING
jobcount = w_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
*** Criou-se o JOB com sucesso
IF sy-subrc = 0.
CLEAR seltab_wa.
*** Monta o parâmetro
MOVE: t_jobs-param TO seltab_wa-selname,
t_processar-line+34 TO seltab_wa-low.
APPEND seltab_wa TO seltab.
seltab_wa-selname = 'P_LOJA'.
seltab_wa-low = t_processar-ficheiro+7(4).
APPEND seltab_wa TO seltab.
*** Submete o programa para o JOB
SUBMIT (t_jobs-repid)
WITH SELECTION-TABLE seltab
USER sy-uname
VIA JOB w_jobname NUMBER w_jobcount
AND RETURN.
*** Encerra o JOB
IF l_conta EQ 1.
l_hora = sy-uzeit.
ADD 120 TO l_hora.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobcount
jobname = w_jobname
sdlstrtdt = sy-datum
sdlstrttm = l_hora
targetserver = w_servidor
IMPORTING
job_was_released = l_liberado
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.
ELSE.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_jobcount
jobname = w_jobname
predjob_checkstat = 'X'
pred_jobcount = w_jobcount2
pred_jobname = w_jobname2
targetserver = w_servidor
IMPORTING
job_was_released = l_liberado
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.
ENDIF. "l_conta eq ...
ENDIF. "sy-subrc = 0 do JOB-OPEN
w_jobname2 = w_jobname.
w_jobcount2 = w_jobcount.
PERFORM f_limpa_param.
ENDLOOP. "at t_processar
Regards.
Valter Oliveira. -
Job not released in the given specified time(Job_close)
Hi,
I need to run a program through job.I created a job using JOB_OPEN
And submitted the job name and job count to the required program
And closed the job using JOB_CLOSE.
My problem is the job getting scheduled but not released/ processed automatically by the specified time I need to release it manually through SM37.
My code.
JOB_OPEN
SUBMIT VIA job_name and job count
l_time = sy-uzeit + 60.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = l_jobcount
jobname = l_jobname
SDLSTRTDT = sy-datum
SDLSTRTTM = l_time
STRTIMMED = 'X'
IMPORTING
job_was_released = l_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.
After the above code execution SY-SUBRC is 8 and And the L_released is having balnk.If I pass start immediately the the job processed immediately. And the L_released is having X.
Please help me .If you are trying to set up the job to start at some point in the future - use the SDLSTRTDT and SDLSTRTTM, but do not set the STRTIMMED to 'X'. You can either schedule it for the future (with the sy-datum and sy-uzeit+60 you desginated) or you can set it to begin immediately. But I don't believe you can do both.
In your code example, your are setting both the "start immediately" plus giving it a future date and time.
Give that a try and see if it helps.
-Mark -
Schedule Job with Job_close after successful job doesn't work
Hi guys,
I'm using FM CLOSE_JOB with parameters :
JOBCOUNT = w_JobId
JOBNAME = w_JobName
PREDJOB_CHECKSTAT = 'X'
PRED_JOBCOUNT = w_oldJobId
PRED_JOBNAME = w_oldJobName
I have about 9 jobs wich must run the one after the others. The first start without PRED* parameters, but the 8 others one are filled with CHECKSTAT, and previous job name and id.
It works fine for the side "the one after the others", BUT, wathever the previous job give as result (cancelled or finished), the next one starts whereas I pass the parameter CHECKSTAT to X.
Any ideas of the problem and how to solve it?
Thanks in advance for your answers.Here my code with explanation :
REPORT YCOMJ023.
start-of-selection.
"Initialization of my vars
w_StepCount = 0. >> number of steps maxi in a job
w_jobCount = 1. >> number to see easier in SM37 the job order
CONCATENATE pe_name '_STEPS' w_jobCountC INTO w_JobName. (example : TOTO_STEP1)
CONDENSE w_JobName NO-GAPS.
"I open my first job
CALL FUNCTION 'JOB_OPEN' (OPEN job TOTO_STEP1)
EXPORTING
jobname = w_JobName
IMPORTING
jobcount = w_JobID
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
"We keep in memory first job IDs to close it at the end of the prg
w_firstjobName = w_JobName.
w_firstjobID = w_JobID.
"imagine you do the bellow code in a loop and it makes several jobs TOTO_STEP2 TOTO_STEP3 TOTO_STEP4...
ADD 1 TO w_StepCount.
IF w_StepCount GT 250.
"I call close job eatch time I reach 250 steps
PERFORM fx_jobclose.
ENDIF.
submit RKGALKEUB to sap-spool and return
without spool dynpro
spool parameters print_parameters
VIA JOB w_JobName NUMBER w_JobID
"End of the programmI close the current Job and the first one :
"Current
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = w_JobId
JOBNAME = w_JobName
PREDJOB_CHECKSTAT = 'X'
PRED_JOBCOUNT = w_oldJobId
PRED_JOBNAME = w_oldJobName.
"First one + launch with STRIMMED
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = w_firstjobId
JOBNAME = w_firstjobName
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
OTHERS = 8.
*& Form fx_jobclose
* text
FORM fx_jobclose.
"Step to zero to do a new loop after this form
w_StepCount = 0.
DATA : w_job_released TYPE CHAR1.
"If the flag IsFirst, we don't do nothing, because it's the first JOb, and it should not be closed
IF w_IsFirst = 'X'.
"Flag is set to blank
w_IsFirst = ''.
ELSE.
"Else it mean we are closing a job with predecessor :
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = w_JobId
JOBNAME = w_JobName
PREDJOB_CHECKSTAT = 'X'
PRED_JOBCOUNT = w_oldJobId
PRED_JOBNAME = w_oldJobName
"SDLSTRTDT = sy-datum
"SDLSTRTTM = sy-timlo
IMPORTING
JOB_WAS_RELEASED = w_job_released.
ENDIF.
"Vars get the value of current job, witch will become the older one
w_oldJobId = w_jobID.
w_oldJobName = w_JobName.
"I make the new TOTO_STEPX job name
ADD 1 TO w_jobCount.
w_jobCountC = w_jobCount.
CONCATENATE pe_name '_STEPS' w_jobCountC INTO w_JobName.
CONDENSE w_JobName NO-GAPS.
"I open the new job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = w_JobName
IMPORTING
jobcount = w_JobId
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
ENDFORM. "fx_jobclose
I hope my code is clear enought, I tried to delete the superfluities code.
Maybe you are looking for
-
Hi Friends, Req : We need to push data from XML to BW System - 3.5 BW I went through all steps of "HOW to Push data to XML" document. I kept my XML file on Desktop When I perform "Send Recordset" no response from system my data is not seen in delta
-
Help with installation for adobe flash player
When I try to download the flash player it states: The installer will automatically continue when these conflicting applications are closed : Internet Explorer. What should I do? Thank you.
-
How well does final cut pro 7 run on the new iMac i7?
I have the Mac Pro 1,1 - 2x3 GHz Dual-Core Xeon and I'm wondering if I would notice a better performance upgrading the computer. I do have the AJA Kona 2 for video output to HD screen but am willing to lose it for the nice 27" screen and a faster sys
-
OK, Anyone else think the service should just work...
I've been reading through the forums for some time now. I have been a BT customer (this time around) for about 2 years. Previously for many more years. Seems to me that BT customers have to put up with what our American cousins would find totally u
-
Does DFS Use A Lot Of Resources?
Hello, I have set up a test environment in which I have a single server with 4gb RAM currently running Active Directory Domain Services with only 2 clients and it runs fine (only using 990MB). I am intending to install SQL Server on it and limit it t