ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Transfer data to a system file

Transfer data to a system file

原创 Linux操作系统 作者:ultraluck 时间:2019-04-19 10:09:06 0 删除 编辑
Transfer data to a system file

Transfer data to a system file

Ever want to save data to a system file from an SAP R/3 ABAP program? Its pretty straightforward. In this case we assume the internal table data_tab contains the information you want to store in the file system. dsn holds the Data set name. The directory must exist in the file structure of your system; record is the record to be written to the file.

data: dsn(20) value '/transfer/matnr',
record(460).
open dataset dsn for output in text mode.

loop at data_tab.
clear record.
move data_tab to record.
transfer record to dsn length 460.
endloop.

close dataset dsn.

- or -

As subroutines to add to a program

*&---------------------------------------------------------------------*
*& Form opendataset
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*

form opendataset.

open dataset dsn for output in text mode.
if sy-subrc <> 0.
write: / 'Error opening',dsn, sy-subrc.
stop.
endif.

endform. " opendataset

*&---------------------------------------------------------------------*
*& Form closedataset
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*

form closedataset.

close dataset dsn.
if sy-subrc ne 0.
write: / 'Error closing', dsn, sy-subrc.
stop.
endif.

endform. " closedataset
*&---------------------------------------------------------------------*
*& Form transfertodsn
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form transfertodsn.
transfer outfile to dsn length 66.
endform. " transfertodsn

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/190059/viewspace-476541/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2004-12-03

  • 博文量
    170
  • 访问量
    176248