当前位置:网站首页>How to upload local file trial version in binary mode in ABAP report

How to upload local file trial version in binary mode in ABAP report

2022-08-09 13:03:00 Wang Zixi

零基础 ABAP 学习教程系列文章的目录

ABAP 基础知识

Office 专题

ALV 开发专题

更多文章正在写作中

this step of the tutorial,用 ABAP 读取本地文本文件内容,我们介绍了使用 Function Module GUI_UPLOAD to upload a text file,The entire report however 18 行代码.

REPORT zreduce1.

DATA: lv_file_name   TYPE string VALUE 'C:\temp\1.txt',
      lv_file_length TYPE i,
      lt_content     TYPE string_table,
      lv_content     TYPE string.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename   = lv_file_name
  IMPORTING
    filelength = lv_file_length
  TABLES
    data_tab   = lt_content.

LOOP AT lt_content INTO lv_content.
  WRITE:/ lv_content.
ENDLOOP.

执行之后,can be successfully stored in C 盘的文本文件 1.txt 的内容打印出来.

我们在 SE37 里打开 GUI_UPLOAD,find its parameters FILETYPE 是可选参数(optional),默认值为 ASC That is, upload the local file content in text mode.

显然,在实际项目中,We need to upload to ABAP 服务器的文件,除了文本文件之外,There are definitely other types of files included,比如 jpg,pdf,docx 这种文件.这些类型的文件,Apparently it can't be opened via a normal text editor,And also not suitable for passing ASC That is, upload in text mode.因此,我们需要使用另一种 BIN mode is binary mode for uploading.

In this step we introduce another useful one ABAP 工具类,CL_GUI_FRONTEND_SERVICES,它的 GUI_UPLOAD 方法,File upload is also possible.Actually if you look at the source code of this method,It turns out that it's actually just a simple call Function Module GUI_UPLOAD,The latter we have already learned:

In this article we demonstrate how to do it in binary,Upload a local text file to ABAP 服务器上.

下面是具体的步骤.

原网站

版权声明
本文为[Wang Zixi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208091155128719.html