Conteúdo

Submit via job

Maneira simples de submit (executar um outro programa) via job.
REPORT ZSAPeiros.

DATA: lv_number           TYPE tbtcjob-jobcount,
      lv_name             TYPE tbtcjob-jobname VALUE 'JOB_SAPEIROS',
      lv_print_parameters TYPE pri_params.

CALL FUNCTION 'JOB_OPEN'
  EXPORTING
    jobname          = lv_name
  IMPORTING
    jobcount         = lv_number
  EXCEPTIONS
    cant_create_job  = 1
    invalid_job_data = 2
    jobname_missing  = 3
    OTHERS           = 4.

IF sy-subrc IS INITIAL.

  WRITE: / 'Job criado'.

  SUBMIT ZSAPeiros VIA JOB lv_name NUMBER lv_number AND RETURN.

  IF sy-subrc IS INITIAL.

    WRITE: / 'Job escalonado para execucao do programa ZSAPeiros'.

    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = lv_number
        jobname              = lv_name
        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 IS INITIAL.

      WRITE: / 'Job encerrado'.

    ENDIF.

  ENDIF.

ENDIF.