ABAP 在程序中启动后台JOB
生活随笔
收集整理的這篇文章主要介紹了
ABAP 在程序中启动后台JOB
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
DATA:?lv_job_name?????????LIKE?tbtco-jobname,?????"作業名
??lv_job_nr???????????LIKE?tbtco-jobcount,??????????"作業號
??lv_job_released?????TYPE?c,
??lv_job_start_sofort?TYPE?c,
??lv_print_parameters?TYPE?pri_params.
??DATA:lt_rspar??TYPE?TABLE?OF?rsparams,
???????lw_line?LIKE?LINE?OF?lt_rspar.
??"如果是要傳給PARAMETER ?根據需求設置屏幕參數
??lw_line-selname?=?'P_MONAT'.
??lw_line-kind????=?'P'.
??lw_line-sign????=?'I'.
??lw_line-option??=?'EQ'.
??lw_line-low?????=?p_monat.
??APPEND?lw_line?TO?lt_rspar.
??"傳值給?SELECT-OPTION
??lw_line-selname?=?'S_WERKS'.
??lw_line-kind????=?'S'.
??lw_line-sign????=?'I'.
??lw_line-option??=?'EQ'.
??lw_line-low?????=?'1000'.
??APPEND?lw_line?TO?lt_rspar.
??APPEND?lw_line?TO?lt_rspar.
??"JOB?名稱
??lv_job_name?=?job_name?.
??"打開JOB?通過JOB?name?獲得JOB號
??CALL?FUNCTION?'JOB_OPEN'
????EXPORTING
??????jobname??????????=?lv_job_name
????IMPORTING
??????jobcount?????????=?lv_job_nr
????EXCEPTIONS
??????cant_create_job??=?1
??????invalid_job_data?=?2
??????jobname_missing??=?3
??????OTHERS???????????=?4.
??IF?syst-subrc?=?0.
????"調用需要跑JOB的程序
????SUBMIT?(lv_job_name)
????????WITH?SELECTION-TABLE??lt_rspar?
????????USER?syst-uname??????????"?mandatory
???????VIA?JOB?lv_job_name?NUMBER?lv_job_nr?AND?RETURN.
????"運行結束??關閉JOB
????IF?sy-subrc?=?0.
??????CALL?FUNCTION?'JOB_CLOSE'
????????EXPORTING
??????????jobcount?????????????=?lv_job_nr
??????????jobname??????????????=?lv_job_name
??????????strtimmed????????????=?'X'
????????IMPORTING
??????????job_was_released?????=?lv_job_released
????????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?syst-subrc?<>?0.
????????MESSAGE?'關閉后臺作業出錯'?TYPE?'I'.
??????ELSE.
????????MESSAGE?'后臺JOB開始運行'?TYPE?'I'.
??????ENDIF.
????ENDIF.
??ENDIF.
??lv_job_nr???????????LIKE?tbtco-jobcount,??????????"作業號
??lv_job_released?????TYPE?c,
??lv_job_start_sofort?TYPE?c,
??lv_print_parameters?TYPE?pri_params.
??DATA:lt_rspar??TYPE?TABLE?OF?rsparams,
???????lw_line?LIKE?LINE?OF?lt_rspar.
??"如果是要傳給PARAMETER ?根據需求設置屏幕參數
??lw_line-selname?=?'P_MONAT'.
??lw_line-kind????=?'P'.
??lw_line-sign????=?'I'.
??lw_line-option??=?'EQ'.
??lw_line-low?????=?p_monat.
??APPEND?lw_line?TO?lt_rspar.
??"傳值給?SELECT-OPTION
??lw_line-selname?=?'S_WERKS'.
??lw_line-kind????=?'S'.
??lw_line-sign????=?'I'.
??lw_line-option??=?'EQ'.
??lw_line-low?????=?'1000'.
??APPEND?lw_line?TO?lt_rspar.
??APPEND?lw_line?TO?lt_rspar.
??"JOB?名稱
??lv_job_name?=?job_name?.
??"打開JOB?通過JOB?name?獲得JOB號
??CALL?FUNCTION?'JOB_OPEN'
????EXPORTING
??????jobname??????????=?lv_job_name
????IMPORTING
??????jobcount?????????=?lv_job_nr
????EXCEPTIONS
??????cant_create_job??=?1
??????invalid_job_data?=?2
??????jobname_missing??=?3
??????OTHERS???????????=?4.
??IF?syst-subrc?=?0.
????"調用需要跑JOB的程序
????SUBMIT?(lv_job_name)
????????WITH?SELECTION-TABLE??lt_rspar?
????????USER?syst-uname??????????"?mandatory
???????VIA?JOB?lv_job_name?NUMBER?lv_job_nr?AND?RETURN.
????"運行結束??關閉JOB
????IF?sy-subrc?=?0.
??????CALL?FUNCTION?'JOB_CLOSE'
????????EXPORTING
??????????jobcount?????????????=?lv_job_nr
??????????jobname??????????????=?lv_job_name
??????????strtimmed????????????=?'X'
????????IMPORTING
??????????job_was_released?????=?lv_job_released
????????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?syst-subrc?<>?0.
????????MESSAGE?'關閉后臺作業出錯'?TYPE?'I'.
??????ELSE.
????????MESSAGE?'后臺JOB開始運行'?TYPE?'I'.
??????ENDIF.
????ENDIF.
??ENDIF.
總結
以上是生活随笔為你收集整理的ABAP 在程序中启动后台JOB的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Web Dynpro公开课学习
- 下一篇: SM37job状态意义