获取文件名称的两个函数

获取文件名称的两个函数

FORM f4_filename  changing c_file.

  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      mask      = '*.XLS'
      static    = 'X'
    CHANGING
      file_name = c_file.
ENDFORM.                    " F4_FILENAME

*&---------------------------------------------------------------------*
*&      Form  zfrom_get_filename
*&---------------------------------------------------------------------*
*       text 获取文件名称
*----------------------------------------------------------------------*
FORM zfrom_get_filename  CHANGING filename.
  "选择文件
  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_filename     = ' '
      def_path         = ' '
      mask             = '*.*,*.*. '
      mode             = 'O'
      title            = 'Choose Inpute file '
    IMPORTING
      filename         = filename
    EXCEPTIONS
      inv_winsys       = 1
      no_batch         = 2
      selection_cancel = 3
      selection_error  = 4
      OTHERS           = 5.

  CASE sy-subrc.
        WHEN 0.
        WHEN 3.
      RETURN.
        WHEN OTHERS.
      MESSAGE '文件打开失败' TYPE 'I'.
      RETURN.
  ENDCASE.
ENDFORM.   

使用的时候用

at selection-screen on value-request for p_file.
  perform zfrom_get_filename changing p_file.
at selection-screen on p_file.

或者
at selection-screen on value-request for p_file.
perform f4_filename changing p_file.
at selection-screen on p_file.

都行,也可以用F4直接打开,主要是用在
at selection-screen on value-request for p_file.
  perform zfrom_get_filename changing p_file.
at selection-screen on p_file.
这个位置就行


另外下载的时候,也可以用这两个去确定地址
posted @ 2014-01-22 09:20  胡来  阅读(165)  评论(0编辑  收藏  举报