直接上代码
代码语言:javascript复制*&---------------------------------------------------------------------*
*& Form FRM_SUBMITJOB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SUBMITJOB .
DATA : JOBNAME LIKE TBTCJOB-JOBNAME,
JOBNUMBER LIKE TBTCJOB-JOBCOUNT,
STABLE TYPE TABLE OF RSPARAMS.
JOBNAME = SY-REPID.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
* DELANFREP = ' '
* JOBGROUP = ' '
JOBNAME = JOBNAME
* SDLSTRTDT = NO_DATE
* SDLSTRTTM = NO_TIME
* JOBCLASS =
* CHECK_JOBCLASS =
IMPORTING
JOBCOUNT = JOBNUMBER
* INFO =
* 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 'E' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
CURR_REPORT = SY-REPID
* IMPORTING
* SP =
TABLES
SELECTION_TABLE = STABLE
* SELECTION_TABLE_255 =
EXCEPTIONS
NOT_FOUND = 1
NO_REPORT = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
SUBMIT (SY-REPID)
WITH SELECTION-TABLE STABLE
VIA JOB JOBNAME
NUMBER JOBNUMBER
AND RETURN.
IF SY-SUBRC = 0 .
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
* AT_OPMODE = ' '
* AT_OPMODE_PERIODIC = ' '
* CALENDAR_ID = ' '
* EVENT_ID = ' '
* EVENT_PARAM = ' '
* EVENT_PERIODIC = ' '
JOBCOUNT = JOBNUMBER
JOBNAME = JOBNAME
* 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.
ELSE.
WRITE : / 'JOB名称:',JOBNAME.
WRITE : / 'JOB Number:',JOBNUMBER.
ENDIF.
ENDIF.
ENDFORM.