ABAP获取文件保存路径

该博客内容涉及一个用于用户交互的程序段,通过调用GUI前端服务的文件保存对话框,让用户选择并确认文件下载的路径。如果用户未选择路径或文件名不包含'.XLS',则会返回错误提示。程序主要关注用户输入验证和文件路径获取流程。
摘要由CSDN通过智能技术生成
REPORT Y_CLY_104X.


START-OF-SELECTION.

  DATA: P_FULLPATH   TYPE STRING.

  PERFORM FRM_GET_FILE_PATH CHANGING P_FULLPATH.

  WRITE: P_FULLPATH.

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_FILE_PATH
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_P_FULLPATH  text
*----------------------------------------------------------------------*
FORM FRM_GET_FILE_PATH  CHANGING CV_FULLPATH.
  "路径
  DATA: L_FILENAME   TYPE STRING,
        L_PATH       TYPE STRING,
        L_FULLPATH   TYPE STRING.

  CLEAR: CV_FULLPATH.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
    EXPORTING
      WINDOW_TITLE         = '下载文件'
      FILE_FILTER          = ''
    CHANGING
      FILENAME             = L_FILENAME
      PATH                 = L_PATH
      FULLPATH             = L_FULLPATH
    EXCEPTIONS
      CNTL_ERROR           = 1
      ERROR_NO_GUI         = 2
      NOT_SUPPORTED_BY_GUI = 3
      OTHERS               = 4.

  IF L_PATH     IS INITIAL
  OR L_FILENAME IS INITIAL.     " 未选择路径,则返回
    RETURN.
  ELSE.
    TRANSLATE  L_FILENAME  TO UPPER CASE .
    FIND REGEX '.XLS' IN L_FILENAME.
    IF SY-SUBRC <> 0.
      MESSAGE '请填写完整路径!' TYPE 'E'.
      RETURN.
    ENDIF.
  ENDIF.

  CV_FULLPATH = L_FULLPATH.

ENDFORM.                    " FRM_GET_FILE_PATH

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值