惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
G
Google Developers Blog
小众软件
小众软件
V
V2EX
月光博客
月光博客
腾讯CDC
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
D
Docker
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI

博客园 - 冰冷

经典正则表达式 (转) 常用的javascript小技巧[作者oror][转] HR 事务代码 (转) rp-provide-from-last 给SAP系统安装联机帮助(事务码SR13) (转) - 冰冷 - 博客园 如何修改 SAP 登录后的背景图片(事务码 SMW0,SM30)(转) sapgui640免除每次登录都要输入密码(转) 关于MiPlatform310 关于oracle form开发中commit WHEN-VALIDATE-ITEM 和 KEY-NEXT-ITEM两个trigger 的先后顺序 vs2005中的treeview VS2005 写存储过程 关于给winform的DataGrid中添加复选框的问题 用.NET创建windows服务 google中的超强搜索 关于FAT32 -> NTFS 文件系统转换 数据库连接字符串大全 [TrackBack] 转自CSDN 地址:http://blog.csdn.net/gauss32/archive/2004/10/27/154621.aspx 关于配置证书服务器,和自己颁发企业证书 自动日志组件 - Log4net应用(转贴来自http://dotnet.3yee.com/)
导出txt文件简单的例子
冰冷 · 2007-09-18 · via 博客园 - 冰冷

REPORT  ZTEST_XIN0917                           .

TYPES:BEGIN OF i_file ,
       col1 TYPE i ,
        col2(3) TYPE c,
        col3(5) TYPE c,
     END OF i_file.

DATA: itab_file TYPE i_file OCCURS 0 WITH HEADER LINE.

***用户可看SAP帮助使用Download和upload的例##
***使用类弹出用户对话框
  DATA :s_filedir    LIKE rlgrap-filename .
  DATA: s_filemask(20) TYPE  c VALUE   ',*.txt ,*.txt. '.
  DATA: s_filepath(60) TYPE  c.


itab_file-col1 = 1.
itab_file-col2 = 'aaa'.
itab_file-col3 = 'aaa'.

append itab_file.


***Get current direcotry
  CALL FUNCTION 'WS_QUERY'
    EXPORTING
      query  = 'CD'
    IMPORTING
      return = s_filepath.
*** get file name ***
  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_filename     = space
      def_path         = s_filepath
      mask             = s_filemask
      mode             = 'O'
    IMPORTING
      filename         = s_filedir
    EXCEPTIONS
      inv_winsys       = 1
      no_batch         = 2
      selection_cancel = 3
      selection_error  = 4
      OTHERS           = 5.
  CHECK sy-subrc EQ 0. "User might cancel operation.
***如果文件后坠非.TXT加上后坠
  TRANSLATE s_filedir TO UPPER CASE.
  IF '.TXT' CN s_filedir .
    CONCATENATE s_filedir '.TXT' INTO s_filedir .
  ENDIF.
*** write data to file ****
  CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      filename         = s_filedir
      filetype         = 'DAT'
      mode             = 'A'
    TABLES
      data_tab         = itab_file
    EXCEPTIONS
      file_open_error  = 01
      file_write_error = 02
      invalid_type     = 03
      no_batch         = 04
      unknown_error    = 05.
  CASE sy-subrc.
    WHEN 0.
      MESSAGE i001(00) WITH 'Data have been write into file:'
                            s_filedir ',Please check!' .
    WHEN 1.
      MESSAGE i001(00) WITH 'Error while opening file:' s_filedir.
    WHEN 2.
      MESSAGE i001(00) WITH  'Error in writing file ' s_filedir.
    WHEN 3.
      MESSAGE i001(00) WITH  'invalid file type of ' s_filedir .
    WHEN OTHERS.
      MESSAGE i001(00) WITH  'unknown error occured'.
  ENDCASE.