ITPub博客

首页 > 应用开发 > IT综合 > ABAP学习-关于数据导出

ABAP学习-关于数据导出

原创 IT综合 作者:jiang2008 时间:2007-03-07 12:51:22 0 删除 编辑
ABAP学习-关于数据导出[@more@]

关键词ABAP

导出予留为EXCEL表格

*&---------------------------------------------------------------------*
*& Report Z_TEST10
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*RESB-RSNUM 预留编号
*RESB-BWART 移动类型
*RKPF-KOSTL 成本中心
*RESB-MATNR 物料号
*RESB-ERFMG 数量

PROGRAM Z_TEST10.
DATA: FNAME(128), FTYPE(3), FSIZE TYPE I, S_BWART(10) TYPE C.

TABLES: RESB , RKPF.
*DATA: BEGIN OF IT_RESB OCCURS 0,
* RSNUM LIKE RESB-RSNUM,
* BWART(4) type c,
* MATNR LIKE RESB-MATNR,
* ERFMG LIKE RESB-ERFMG,
* END OF IT_RESB.
*DATA: BEGIN OF IT_COBL OCCURS 0,
* KOSTL LIKE COBL-KOSTL,
* END OF IT_COBL.
DATA: BEGIN OF IT_RESULT OCCURS 0,
RSNUM LIKE RESB-RSNUM,
BWART LIKE RESB-BWART,
MATNR LIKE RESB-MATNR,
ERFMG LIKE RESB-ERFMG,
KOSTL LIKE RKPF-KOSTL,
END OF IT_RESULT.

SELECT
RESB~RSNUM
RESB~BWART
RESB~MATNR
RESB~ERFMG
RKPF~KOSTL
FROM RESB
INNER JOIN RKPF ON RESB~RSNUM = RKPF~RSNUM
INTO CORRESPONDING FIELDS OF TABLE IT_RESULT.
*SELECT * FROM COBL INTO CORRESPONDING FIELDS OF TABLE IT_COBL.
LOOP AT IT_RESULT.
CONCATENATE IT_RESULT-BWART
'@' INTO S_BWART.
WRITE S_BWART TO IT_RESULT-BWART .
*WRITE IT_RESB-BWART.
ENDLOOP.

CALL FUNCTION 'GUI_DOWNLOAD'
*CALL FUNCTION 'DOWNLOAD'
EXPORTING
* CODEPAGE = 'IBM'
FILENAME = 'd:saptest.xls'
FILETYPE = 'DAT'
* ITEM = 'Test for Excel File'
* IMPORTING
* ACT_FILENAME = FNAME
* ACT_FILETYPE = FTYPE
* FILESIZE = FSIZE
TABLES
DATA_TAB = IT_RESULT.
* EXCEPTIONS
* INVALID_FILESIZE = 1
* INVALID_TABLE_WIDTH = 2
* INVALID_TYPE = 3.

WRITE: 'SY-SUBRC:', SY-SUBRC,
/ 'Name :', (60) FNAME,
/ 'Type :', FTYPE,
/ 'Size :', FSIZE.

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

上一篇: ABAP学习
请登录后发表评论 登录
全部评论
  • 博文量
    171
  • 访问量
    2895740