程序中设置后台作业(background job)

  DATA: lt_valutab   TYPE STANDARD TABLE OF rsparams,
         lv_jobname   TYPE tbtcjob-jobname,
         lv_jobcount  TYPE tbtcjob-jobcount,
         lv_jobstatus TYPE tbtco-status,
         ls_tbtcv     TYPE tbtcv,
         lv_count     TYPE i.

CONCATENATE 'ZBJ_' sy-datum '_' sy-uzeit INTO lv_jobname.

  CALL FUNCTION 'JOB_OPEN'
     EXPORTING
       jobname          = lv_jobname
       sdlstrtdt        = sy-datum
       sdlstrttm        = sy-uzeit
     IMPORTING
       jobcount         = lv_jobcount
     EXCEPTIONS
       cant_create_job  = 1
       invalid_job_data = 2
       jobname_missing  = 3
       OTHERS           = 4.
   IF sy-subrc <> 0.
     MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE 'E'.
     STOP.
   ENDIF.

   CALL FUNCTION 'JOB_SUBMIT'
     EXPORTING
       authcknam               = sy-uname
       jobcount                = lv_jobcount
       jobname                 = lv_jobname
       report                  = p_pgmna
       variant                 = p_bs
     EXCEPTIONS
       bad_priparams           = 1
       bad_xpgflags            = 2
       invalid_jobdata         = 3
       jobname_missing         = 4
       job_notex               = 5
       job_submit_failed       = 6
       lock_failed             = 7
       program_missing         = 8
       prog_abap_and_extpg_set = 9
       OTHERS                  = 10.
   IF sy-subrc <> 0.
     MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE 'E'.
     STOP.
   ENDIF.

   CALL FUNCTION 'JOB_CLOSE'
     EXPORTING
       jobcount             = lv_jobcount
       jobname              = lv_jobname
       laststrtdt           = sy-datum
       laststrttm           = sy-uzeit
       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
       invalid_target       = 8
       invalid_time_zone    = 9
       OTHERS               = 10.
   IF sy-subrc <> 0.
     MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE 'E'.
     STOP.
   ENDIF.

你可能感兴趣的:(BACKGROUND,JOB)