尝试在后台运行 abap 失败



我有一个程序,它有一个复选框,如果用户启用它,它使用以下代码在后台运行该程序:

    REPORT  zfile_creation_app2.
*&---------------------------------------------------------------------*
*& Create file on Application Server
*& if the file exist, it will be deleted and created with new content
*&---------------------------------------------------------------------*
TABLES : sflight.
TYPES: BEGIN OF ty_sflight,
         carrid TYPE sflight-carrid,
         connid TYPE sflight-connid,
         fldate TYPE sflight-fldate,
       END OF ty_sflight.
DATA: lv_file(255).
DATA: lt_sflight            TYPE TABLE OF ty_sflight.
FIELD-SYMBOLS: <fs_sflight> LIKE LINE OF lt_sflight.
"-----------------------------------------"
" Selection Screen
"-----------------------------------------"
SELECT-OPTIONS: s_carid FOR sflight-carrid,
                s_fldte FOR sflight-fldate.
" File Path on Application Server
PARAMETERS: p_path      TYPE btcxpgpar DEFAULT '/tmp',
            p_bckgrd(1) TYPE c DEFAULT 'X'.

"-----------------------------------------"
" Help Search for SAP Folder
"-----------------------------------------"
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
  DATA: c_fnh_mask TYPE dxfields-filemask VALUE '*',
        search_dir TYPE dxfields-longpath.
  CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
    EXPORTING
      directory        = search_dir
      filemask         = c_fnh_mask
    IMPORTING
      serverfile       = p_path
    EXCEPTIONS
      canceled_by_user = 1
      OTHERS           = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  "-----------------------------------------"
  " Processing
  "-----------------------------------------"
START-OF-SELECTION.
  IF p_bckgrd = 'X'.
    PERFORM start_in_background.
  ELSE.
    PERFORM get_data.
    PERFORM extract_to_file.
  ENDIF.
END-OF-SELECTION.
  WRITE: lv_file , ' is created' .

*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_data .
  SELECT carrid connid fldate FROM sflight INTO TABLE lt_sflight
  WHERE carrid IN s_carid[] AND
        fldate IN s_fldte.
  IF sy-subrc NE 0 .
    RETURN.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  EXTRACT_TO_FILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM extract_to_file .
  " Build FineName
  CONCATENATE p_path '/' 'Flight' sy-datum sy-uzeit '.txt' INTO lv_file.
  REPLACE ALL OCCURRENCES OF '//' IN lv_file WITH '/'.
  " Check if File exists
  OPEN DATASET  lv_file  FOR INPUT IN BINARY MODE.
  IF sy-subrc EQ 0.
    " If File Exists -> Delete it
    CLOSE DATASET   lv_file.
    DELETE DATASET  lv_file.
    CLOSE DATASET   lv_file.
  ENDIF.
  " Open file for Output
  OPEN DATASET  lv_file  FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc NE 0 .
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  " Transfer Data to file
  LOOP AT lt_sflight ASSIGNING <fs_sflight>.
    TRANSFER <fs_sflight> TO  lv_file .
  ENDLOOP.
  " Close File
  CLOSE DATASET  lv_file.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  START_IN_BACKGROUND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM start_in_background .
  DATA: d_jobcount LIKE tbtcjob-jobcount,
        d_jobname  LIKE tbtcjob-jobname.
  d_jobname = 'ZFILE_CREATION_APP2'.
  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname          = d_jobname
    IMPORTING
      jobcount         = d_jobcount
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.
  IF sy-subrc NE 0.
    MESSAGE s368(00) WITH 'Error Creating Job'
    sy-subrc.
    EXIT.
  ENDIF.
  SUBMIT zfile_creation_app2
    WITH s_carid = s_carid
    WITH s_fldte = s_fldte
    WITH p_bckgrd = space
    WITH p_path = p_path
      VIA JOB d_jobname
          NUMBER d_jobcount
      AND RETURN.
  CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
      jobcount          = d_jobcount
      jobname           = d_jobname
      strtimmed         = 'X' " Immediate
    EXCEPTIONS
      invalid_startdate = 1
      jobname_missing   = 2
      job_close_failed  = 3
      job_nosteps       = 4
      job_notex         = 5
      lock_failed       = 6
      OTHERS            = 7.
  IF sy-subrc > 0.
    MESSAGE s368(00) WITH 'Closing Job Failed'
    sy-subrc.
    EXIT.
  ENDIF.
ENDFORM.

不幸的是,后台作业总是取消并显示以下错误:以 __.__.____ 格式输入日期这是用户的默认设置。

谁能知道问题的原因以及如何解决它?

提前致谢伊莱亚斯

问题出在so_budat上。如果您的so_budat是选择选项,请尝试使用"in"而不是"="。见下文。

so_budat IN so_budat.

相关内容

  • 没有找到相关文章

最新更新