Chinaunix首页 | 论坛 | 博客
  • 博客访问: 458846
  • 博文数量: 199
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2020-05-14 13:25
个人简介

代码5S

文章分类

全部博文(199)

文章存档

2021年(5)

2020年(194)

我的朋友

分类: 其他平台

2020-08-14 17:20:02


点击(此处)折叠或打开

  1. report zmodify_program.


  2. data:gv_report type trdir-name value 'ZDEMO99'.

  3. data: begin of src occurs 1,
  4.            txt(255) type c,
  5.         end of src.

  6. parameters p_file like rlgrap-filename.

  7. at selection-screen on value-request for p_file.
  8.   perform get_file_name changing p_file."调用对话框,选择文件

  9. *Event
  10. start-of-selection.
  11.   perform sub_get_file.

  12.   if src[] is not initial.
  13.     insert report gv_report from src[].
  14.     submit zdemo99 via selection-screen and return.
  15.   endif.

  16. *&---------------------------------------------------------------------*
  17. *& Form get_file_name
  18. *&---------------------------------------------------------------------*
  19. * text
  20. *----------------------------------------------------------------------*
  21. * <--P_FILE text
  22. *----------------------------------------------------------------------*
  23. form get_file_name changing p_file.
  24.   call function 'WS_FILENAME_GET'
  25.     exporting
  26.       mask = '*.txt.'
  27.       mode = 'O'
  28.       title = '数据上传'
  29.     importing
  30.       filename = p_file
  31.     exceptions
  32.       inv_winsys = 1
  33.       no_batch = 2
  34.       selection_cancel = 3
  35.       selection_error = 4
  36.       others = 5.
  37. endform. " GET_FILE_NAME

  38. *&---------------------------------------------------------------------*
  39. *& Form sub_get_file
  40. *&---------------------------------------------------------------------*
  41. * text
  42. *----------------------------------------------------------------------*
  43. form sub_get_file .
  44.   data: lv_filename type string.
  45.   lv_filename = p_file.
  46.   call function 'GUI_UPLOAD'
  47.     exporting
  48.       filename = lv_filename
  49.     tables
  50.       data_tab = src[]
  51.     exceptions
  52.       file_open_error = 1
  53.       file_read_error = 2
  54.       no_batch = 3
  55.       gui_refuse_filetransfer = 4
  56.       invalid_type = 5
  57.       no_authority = 6
  58.       unknown_error = 7
  59.       bad_data_format = 8
  60.       header_not_allowed = 9
  61.       separator_not_allowed = 10
  62.       header_too_long = 11
  63.       unknown_dp_error = 12
  64.       access_denied = 13
  65.       dp_out_of_memory = 14
  66.       disk_full = 15
  67.       dp_timeout = 16
  68.       others = 17.
  69.   if sy-subrc <> 0.
  70.     message '读取文件失败' type 'E'.
  71.   endif.

  72. endform.

阅读(1305) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~