본문 바로가기

SAP ABAP

[SAP/ABAP] 백그라운드 JOB 사용

*- 프로그램 실행용 
    CALL FUNCTION 'JOB_OPEN' " 잡Open
      EXPORTING
        jobname          lv_name "백그라운드 잡 이름
      IMPORTING
        jobcount         lv_cont "백그라운드 잡 카운터( 실행시 생성 )
      EXCEPTIONS
        cant_create_job  1
        invalid_job_data 2
        jobname_missing  3
        OTHERS           4.
    IF sy-subrc 0.
      "백그라운드 잡에서 실행할 프로그램
      SUBMIT *프로그램* USING SELECTION-SET "VARIANTS 정보*

                            VIA JOB lv_name NUMBER lv_cont

                      AND RETURN.
      IF sy-subrc EQ 0.
        CALL FUNCTION 'JOB_CLOSE' " 백그라운드 잡 종료
          EXPORTING
            jobcount             lv_cont "백그라운드 잡 시작시 받은 카운터 값
            jobname              lv_name "백그라운드 잡 시작시 입력한 이름
            strtimmed            abap_true "상태 값 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.

      ENDIF.
    ENDIF.

 

JOB CLOSE까지 끝나야 TBTCO에 스케쥴 데이타가 적재된다.

 
2. JOB STATUS 확인 Function
CALL FUNCTION 'SHOW_JOBSTATE'
EXPORTING
JOBCOUNT = SEL_JOBLIST-JOBCOUNT
JOBNAME = SEL_JOBLIST-JOBNAME
" Identify the job to be checked. Both 
" name and count are required. 
IMPORTING
" Possible statuses. The status of the 
" job is set to the value ‘X’. 
ABORTED = ABORTED
" Job terminated abnormally.
FINISHED = FINISHED
" Job completed successfully. 
PRELIMINARY = PRELIMINARY
" Job can’t be started: Job scheduled 
" but not yet released to run or job scheduled 
" with no start condition. 
READY = READY
" Job scheduled, released, start condition 
" fulfilled, but job not yet started. 
RUNNING = RUNNING
" Job in progress. 
SCHEDULED = SCHEDULED
" Job scheduled and released, waiting for start
" condition to be fulfilled. 
EXCEPTIONS
JOBCOUNT_MISSING = 1
JOBNAME_MISSING = 2
JOB_NOTEX = 3
OTHERS = 4.

IF SY-SUBRC <> 0.
<Error handling>
ENDIF.

'SAP ABAP' 카테고리의 다른 글

[ABAP] 날짜 관련 Function 모음  (0) 2024.06.28
Creating an NWBC bootstrap url  (0) 2024.06.25
SUBMIT / CALL TRANSACTION 비교  (0) 2024.05.03
ABAP Cloud Developer Trial 2022 지금 이용가능합니다.  (0) 2024.04.28
SAP JCO3 RFC 연동  (1) 2024.03.21