当前位置: 代码迷 >> 综合 >> ABAP 后台JOB自动执行
  详细解决方案

ABAP 后台JOB自动执行

热度:92   发布时间:2023-12-11 22:02:15.0
    "启用后台JOBPERFORM FRM_SET_JOB .*&---------------------------------------------------------------------*
*& Form frm_set_job
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM FRM_SET_JOB .DATA: LS_PROG_LOCK LIKE ZDST_PROG_LOCK .DATA: LV_PROG_NAME TYPE C LENGTH 20,LV_JOB_NAME  LIKE TBTCO-JOBNAME,     "作业名LV_JOB_NR    LIKE TBTCO-JOBCOUNT.    "作业号LV_PROG_NAME = '程序名' .SELECT SINGLE * INTO LS_PROG_LOCK FROM ZDST_PROG_LOCK WHEREPROGNAME = LV_PROG_NAME AND ZJOB_FLG = 'X'.
*------------------------------------------------------启用JOBIF SY-SUBRC = 0.WAIT UP TO LS_PROG_LOCK-WTIME SECONDS.LV_JOB_NAME = `程序名及描述` && SY-DATUM  &&  SY-UZEIT .CALL FUNCTION 'JOB_OPEN'EXPORTINGJOBNAME          = LV_JOB_NAMEIMPORTINGJOBCOUNT         = LV_JOB_NREXCEPTIONSCANT_CREATE_JOB  = 1INVALID_JOB_DATA = 2JOBNAME_MISSING  = 3OTHERS           = 4.IF SY-SUBRC = 0."调用需要跑JOB的程序SUBMIT 程序名USER SY-UNAME          " mandatoryVIA JOB LV_JOB_NAME NUMBER LV_JOB_NRTO SAP-SPOOLDESTINATION   'LP01'IMMEDIATELY   ''KEEP IN SPOOL 'X'WITHOUT SPOOL DYNPROAND RETURN.IF SY-SUBRC = 0.CALL FUNCTION 'JOB_CLOSE'EXPORTINGJOBCOUNT  = LV_JOB_NRJOBNAME   = LV_JOB_NAMESTRTIMMED = 'X'.ENDIF.ENDIF.ENDIF.
*---------------------------------------------------关闭JOB
ENDFORM.