Choose path to download file .

本文详细阐述了如何配置和实现数据下载路径的功能,包括使用文件保存对话框获取用户选择的路径,以及通过GUI下载功能将数据从服务器下载到指定目录。文章还介绍了在下载过程中可能出现的各种异常情况及其处理方式,确保数据下载过程的稳定性和安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

"Definition of data for get download path
DATA : fullpath       TYPE                   string,
       filename       TYPE                   string,
       path           TYPE                   string,
       user_action    TYPE                   i,
       encoding       TYPE                   abap_encoding.
 
IF p_file IS INITIAL.
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      window_title         = 'Gui_Download Demo'
      with_encoding        = 'X'
      initial_directory    = 'D:\SAP'
    CHANGING
      filename             = filename
      path                 = path
      fullpath             = fullpath
      user_action          = user_action
      file_encoding        = encoding
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4.
 
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.
 
  IF user_action <> cl_gui_frontend_services=>action_ok.
    EXIT.
  ENDIF.
 
ELSE.
  fullpath = p_file.
 
ENDIF.
 
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename                = fullpath
    filetype                = 'DAT'
  TABLES
    data_tab                = it_top             " download internal table
  EXCEPTIONS
    file_write_error        = 1
    no_batch                = 2
    gui_refuse_filetransfer = 3
    invalid_type            = 4
    no_authority            = 5
    unknown_error           = 6
    header_not_allowed      = 7
    separator_not_allowed   = 8
    filesize_not_allowed    = 9
    header_too_long         = 10
    dp_error_create         = 11
    dp_error_send           = 12
    dp_error_write          = 13
    unknown_dp_error        = 14
    access_denied           = 15
    dp_out_of_memory        = 16
    disk_full               = 17
    dp_timeout              = 18
    file_not_found          = 19
    dataprovider_exception  = 20
    control_flush_error     = 21
    OTHERS                  = 22.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值