0% found this document useful (0 votes)
51 views

Background Job

This document defines variables and data types used for job processing. It calls functions to open a job, submit a report to the job, read the job status, and delete the job. If the job finishes successfully, it converts the spool output to HTML.

Uploaded by

Ajay Nikte
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Background Job

This document defines variables and data types used for job processing. It calls functions to open a job, submit a report to the job, read the job status, and delete the job. If the job finishes successfully, it converts the spool output to HTML.

Uploaded by

Ajay Nikte
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

DATA: l_jobname TYPE btcjob,

l_jobnumber TYPE btcjobcnt,


l_valid TYPE c.
DATA:
l_wa_jobhead TYPE tbtcjob,
l_wa_spool_attrib TYPE bapixmspoolid.
DATA: lt_spool_attrib TYPE STANDARD TABLE OF bapixmspoolid.
CLEAR: l_jobname, l_jobnumber, l_valid, ex_subrc.
CLEAR: l_wa_jobhead, l_wa_spool_attrib.
REFRESH lt_spool_attrib.
CONCATENATE sy-uname sy-datum sy-uzeit INTO l_jobname.
* Create Job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = l_jobname
IMPORTING
jobcount = l_jobnumber
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
MOVE 4 TO ex_subrc.
EXIT.
ENDIF.
lv_curr_report = sy-repid.
* Function module to capture the selection screen values
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = lv_curr_report
* IMPORTING
* SP =
TABLES
selection_table = lt_rsparams
EXCEPTIONS
not_found = 1
no_report = 2
OTHERS = 3
.
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 zprogram WITH SELECTION-TABLE lt_rsparams
VIA JOB v_jobname NUMBER v_jobcount
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
DESTINATION c_lp01 IMMEDIATELY lc_space
KEEP IN SPOOL c_x AND RETURN.
* Release Job.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = l_jobnumber
jobname = l_jobname
strtimmed = c_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
OTHERS = 8.
IF sy-subrc <> 0.
MOVE 4 TO ex_subrc.
EXIT.
ENDIF.
DO.
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobname = l_jobname
job_read_jobcount = l_jobnumber
job_read_opcode = btc_xbp_all_jobdata
IMPORTING
job_read_jobhead = l_wa_jobhead
TABLES
spool_attributes = lt_spool_attrib
EXCEPTIONS
job_doesnt_exist = 1
job_doesnt_have_steps = 2
OTHERS = 99.
IF sy-subrc NE 0.
MOVE 4 TO ex_subrc.
EXIT.
ELSE.
IF l_wa_jobhead-status = btc_aborted OR
l_wa_jobhead-status = btc_unknown_state.
MOVE 4 TO ex_subrc.
EXIT.
ELSEIF l_wa_jobhead-status = btc_finished.
EXIT.
ENDIF.
ENDIF.
ENDDO.
CHECK ex_subrc IS INITIAL.
READ TABLE lt_spool_attrib INTO l_wa_spool_attrib INDEX 1.
IF sy-subrc = 0.
ex_spono = l_wa_spool_attrib-spoolid.
current_spool = l_wa_spool_attrib-spoolid.
ENDIF.
CALL FUNCTION 'BP_JOB_DELETE'
EXPORTING
jobname = l_jobname
jobcount = l_jobnumber
forcedmode = 'X'
EXCEPTIONS
OTHERS = 04.
CALL METHOD convert_spool
IMPORTING
ex_subrc = ex_subrc.
IF ex_subrc = 0.
ex_html_tab[] = html_contents[].
ENDIF.

You might also like