美文网首页
ABAP程序实现后台JOB

ABAP程序实现后台JOB

作者: JayDragon | 来源:发表于2021-12-29 14:09 被阅读0次
      "创建后台JOB,调用ZPPR0010_C
      DATA: lv_jobname  TYPE tbtcjob-jobname,
            lv_jobcount TYPE tbtcjob-jobcount.
    
      lv_jobname = sy-datum && sy-uzeit && '_' && 'ZPPR0010' && '_' && sy-uname.
    
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname          = lv_jobname
        IMPORTING
          jobcount         = lv_jobcount
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
      IF sy-subrc = 0.
        DATA: lt_rsparams LIKE TABLE OF rsparams,
              ls_rsparams LIKE rsparams.
    
        LOOP AT s_pcode.
          MOVE-CORRESPONDING s_pcode TO ls_rsparams.
          ls_rsparams-selname = 'S_PCODE'.
          ls_rsparams-kind = 'S'.
          APPEND ls_rsparams TO lt_rsparams.
          CLEAR ls_rsparams.
        ENDLOOP.
        SUBMIT zppr0010_c WITH SELECTION-TABLE lt_rsparams
                          VIA JOB lv_jobname
                          NUMBER  lv_jobcount
                          AND RETURN.
        IF sy-subrc = 0.
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              jobcount             = lv_jobcount
              jobname              = lv_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
              OTHERS               = 8.
          IF sy-subrc EQ 0.
            MESSAGE s715(db) WITH lv_jobname.
            LEAVE TO SCREEN 0.
          ENDIF.
        ELSE.
          DATA(msg) = cl_abap_submit_handling=>get_error_message( ).
          MESSAGE ID msg-msgid
                  TYPE 'I'
                  NUMBER msg-msgno
                  WITH msg-msgv1 msg-msgv2 msg-msgv3 msg-msgv4
                  DISPLAY LIKE msg-msgty.
        ENDIF.
      ENDIF.
    

    相关文章

      网友评论

          本文标题:ABAP程序实现后台JOB

          本文链接:https://www.haomeiwen.com/subject/aumvqrtx.html