Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Job_open,job_close

Former Member
0 Kudos
760

hello

plz let me know how to use job_open,jib_sumbit,job_close,

and the function modules related to it

thanks

aafaq husain

6 REPLIES 6

Former Member
0 Kudos
314

Hi 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.

Former Member
0 Kudos
314

If you are trying to submit a program in the background at runtime, you will need --- JOB_OPEN, JOB_SUBMIT, JOB_CLOSE.

abdul_hakim
Active Contributor
0 Kudos
314

hi

u can use JOB_OPEN for opening a job that needs to submitted in the background.

JOB_CLOSE for closing the job you have opened.

Just go thru the documentation of the function module to know its complete function...

Cheers,

Abdul

Former Member
0 Kudos
314

HI

GOOD

JOB_OPEN, JOB_SUBMIT, JOB_CLOSE Create and submit background jobs.

-


BTCH Background processing GET_JOB_RUNTIME_INFO Job, Step, Event etc.

JOB_OPEN Open Job Scheduling Without Dialog (Including COMMIT WORK) Open background job and obtain the job Id (JOBCOUNT)

JOB_SUBMIT Insert Background Task in Background Request with COMMIT WORK Add step to the opened job

JOB_CLOSE Close Background Request With COMMIT WORK Release the job

-


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.

THANKS

MRUTYUN

former_member184569
Active Contributor
0 Kudos
314

Hi Aafaq,

You use these function modules when you want to execute a program in background. If it creates a spool, you can also set the print parameters in the program itself.

This documentation is a complete tutorial for scheduling of jobs.

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCDWBLIB/BCDWBLIB.pdf

I am also putting a sample code for reference.

FORM dobackground.

  • Local parameters declaration

DATA : jobname LIKE tbtcjob-jobname,

jobcount LIKE tbtcjob-jobcount.

DATA : ws_spld LIKE pri_params-pdest,

ws_lstname LIKE pri_params-plist,

ws_listext LIKE pri_params-prtxt.

DATA : params LIKE pri_params,

arparams LIKE arc_params,

days(1) TYPE n VALUE 2,

valid TYPE c.

jobname = 'ZLITWMREP'.

ws_lstname = 'ZLITWMREP'.

ws_listext = 'Shipment Literature Breakdown Report'.

  • Create a job

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = jobname

IMPORTING

jobcount = jobcount

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

  • Set print parameters

SELECT SINGLE spld INTO ws_spld FROM usr01 WHERE bname = sy-uname.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING destination = ws_spld

list_name = ws_lstname

list_text = ws_listext

immediately = ' '

line_size = 200

line_count = 65

no_dialog = c_true

IMPORTING out_parameters = params

out_archive_parameters = arparams

valid = valid.

  • Submit the report to create spool with retreived print parameters

SUBMIT zlitwmrep

WITH s_date IN s_date

TO SAP-SPOOL

SPOOL PARAMETERS params

ARCHIVE PARAMETERS arparams

WITHOUT SPOOL DYNPRO

VIA JOB jobname NUMBER jobcount

AND RETURN.

  • Close job

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.

ENDFORM.

Hope you got your required information.

Cheers,

Susmitha

Former Member
0 Kudos
314

thanks.