ABAP之程序相互调用–SUBMIT 实例详解编程语言

目录

【一】调用程序和被调用程序

【二】跳转到被调用程序选择屏幕

【三】跳转到被调用程序执行结果页面

【四】将被调用程序设置为后台作业模式运行


【一】调用程序和被调用程序

调用程序:ZLXF001

ABAP之程序相互调用--SUBMIT 实例详解编程语言

ABAP之程序相互调用--SUBMIT 实例详解编程语言

被调用程序:ZLXF003

ABAP之程序相互调用--SUBMIT 实例详解编程语言

【二】跳转到被调用程序选择屏幕

  SUBMIT zlxf003 VIA SELECTION-SCREEN 
                   WITH p_date = p_date 
                   WITH s_bukrs IN s_bukrs 
                   WITH s_hkont IN s_hkont 
                   WITH p_rd1 = p_rd1 
                   WITH p_rd2 = p_rd2 
                   WITH p_rd3 = p_rd3 
                   AND RETURN.

ABAP之程序相互调用--SUBMIT 实例详解编程语言

ABAP之程序相互调用--SUBMIT 实例详解编程语言

【三】跳转到被调用程序执行结果页面

  SUBMIT lxf003 "VIA SELECTION-SCREEN 
                   WITH p_date = p_date 
                   WITH s_bukrs IN s_bukrs 
                   WITH s_hkont IN s_hkont 
                   WITH p_rd1 = p_rd1 
                   WITH p_rd2 = p_rd2 
                   WITH p_rd3 = p_rd3 
                   AND RETURN.

ABAP之程序相互调用--SUBMIT 实例详解编程语言

ABAP之程序相互调用--SUBMIT 实例详解编程语言

【四】将被调用程序设置为后台作业模式运行

FORM frm_bajob_data . 
 
  DATA: lv_jobname  TYPE tbtcjob-jobname, 
        lv_jobcount TYPE tbtcjob-jobcount. 
 
  CONCATENATE 'ZLXF003_' 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'. 
    RETURN. 
  ENDIF. 
 
********************************************************************** 
*  submit 程序 
  SUBMIT zlxf003 AND RETURN 
                   WITH p_date = p_date 
                   WITH s_bukrs IN s_bukrs 
                   WITH s_hkont IN s_hkont 
                   WITH p_rd1 = p_rd1 
                   WITH p_rd2 = p_rd2 
                   WITH p_rd3 = p_rd3 
                   USER sy-uname 
                   VIA JOB lv_jobname 
                   NUMBER lv_jobcount. 
 
********************************************************************** 
*   关闭后台 
  "参数cant_start_immediate设置后天作业启动优先级,如果不设置的话,可能导致作业挂起,不能实时执行 
  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'. 
    RETURN. 
  ENDIF. 
 
ENDFORM.

ABAP之程序相互调用--SUBMIT 实例详解编程语言

ABAP之程序相互调用--SUBMIT 实例详解编程语言

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/17886.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论