Submit Report
Submit Report
Submit Report
The SUBMIT ABAP statement is use to execute a report or program from within your
ABAP code.
For example from within an ALV output report a user may be able to click on a
button or press a specific key. This action could then execute a second report to
display further details or perform some additional functionality. Please note you
can only execute reports of type '1' (i.e. executable).
seltab_wa-selname = 'PNPPERNR'.
seltab_wa-sign = 'I'.
seltab_wa-option = 'EQ'.
IF sy-subrc NE '0'.
WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.
ENDIF.
Submit report as job(i.e. in background)
data: jobname like tbtcjob-jobname value
'TRANSFER DATA'.
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 value 'X'.
* 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.
* 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.
Submit report as background job, handle spool output(write commands) and run as
different user
data: jobname type tbtcjob-jobname value 'JOBNAME'.
data: jobcount type tbtcjob-jobcount,
host type msxxlist-host.
seltab_wa-selname = 'SO_PERNR'.
seltab_wa-sign = 'I'.
seltab_wa-option = 'EQ'.
seltab_wa-low = ld_pernr.
append seltab_wa to seltab.
* 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.
*Execute abap program ZTESTREP in background job storing any output to spool
submit ZTESTREP to sap-spool and return
with selection-table seltab
user 'ADMIN' "user name with correct/additional authorisation
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
via job jobname
number jobcount.
* Close job
call function 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
strtimmed = starttimeimmediate
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.