用接口CL_GUI_FRONTEND_SERVICES弹出选择文件对话框

转载http://hi.baidu.com/cnlmjer/blog/item/5bcbec7f9598681e28388a88.html

 

因为WS_FILENAME_GET已经被废弃所以使用接口CL_GUI_FRONTEND_SERVICES来实现本地文件的选择.

用接口类CL_GUI_FRONTEND_SERVICES实现的方法

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

  EXPORTING

    WINDOW_TITLE            = '选择'

    DEFAULT_EXTENSION       = 'XLS'

    DEFAULT_FILENAME        = 'defaultfilename'

    FILE_FILTER             = 'Excel文件(*.XLS)|*.XLS|全部文件 (*.*)|*.*|'

*    INITIAL_DIRECTORY       =

*    MULTISELECTION          =

*    WITH_ENCODING           =

  CHANGING

    FILE_TABLE              = g_text

    RC                      = rc

*    USER_ACTION             =

*    FILE_ENCODING           =

*  EXCEPTIONS

*    FILE_OPEN_DIALOG_FAILED = 1

*    CNTL_ERROR              = 2

*    ERROR_NO_GUI            = 3

*    NOT_SUPPORTED_BY_GUI    = 4

*    others                  = 5

        .

如图


接口CL_GUI_FRONTEND_SERVICES 的其他几个常用方法:

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

    EXPORTING

      FILE                 = LW_FILE

    RECEIVING

      RESULT               = LW_RESULT

    EXCEPTIONS

      CNTL_ERROR           = 1

      ERROR_NO_GUI         = 2

      WRONG_PARAMETER      = 3

      NOT_SUPPORTED_BY_GUI = 4

      OTHERS               = 5.

方法描述:检查文件是否存在

FILE为文件名

RESULT为返回结果:‘’不存在,X’存在

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST

    EXPORTING

      DIRECTORY            = LW_PATH

    RECEIVING

      RESULT               = LW_RESULT

    EXCEPTIONS

      CNTL_ERROR           = 1

      ERROR_NO_GUI         = 2

      WRONG_PARAMETER      = 3

      NOT_SUPPORTED_BY_GUI = 4

      OTHERS               = 5.

方法描述:检查目录是否存在

DIRECTORY为目录名

RESULT为返回结果:‘’不存在,X’存在

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG

    EXPORTING

      WINDOW_TITLE         = LW_TITLE

    CHANGING

      FILENAME             = LW_FILENAME

      PATH                 = LW_PATH

      FULLPATH             = LW_FULLPATH

      USER_ACTION          = LW_ACTION

    EXCEPTIONS

      CNTL_ERROR           = 1

      ERROR_NO_GUI         = 2

      NOT_SUPPORTED_BY_GUI = 3

      OTHERS               = 4.

方法描述:

弹出保存文件对话框

FILENAME为文件名

PATH为文件路径

FULLPATH为文件路径加上文件名

USER_ACTION为用户操作:0 点击保存,9点击取消

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE

  EXPORTING

    WINDOW_TITLE         = '选择一个路径'

    INITIAL_FOLDER       = 'Z:\'

  CHANGING

    SELECTED_FOLDER      = lw_folder

EXCEPTIONS

   CNTL_ERROR           = 1

    ERROR_NO_GUI         = 2

    NOT_SUPPORTED_BY_GUI = 3

    others               = 4

        .

方法描述:弹出选择目录对话框

SELECTED_FOLDER返回选择目录

如图:


用接口CL_GUI_FRONTEND_SERVICES弹出选择文件对话框_第1张图片

使用cl_gui_frontend_services的gui_upload注意事项2008-12-02

在ECC5里面, WS_UPLOAD发现一点问题,最后一列的数据无法导入到内部表。

cl_gui_frontend_services的gui_upload是替代方法,但相比以前的WS_UPLOAD,需要注意两点

1、filetype参数的值,以前可以用DAT,现在要使用ASC

2、如果导入文件是TAB键分隔的文件,HAS_FIELD_SEPARATOR参数必须设置为X

你可能感兴趣的:(upload,File,action,Path,extension,encoding)