3

我正在 Business Warehouse 中开发一个程序,该程序允许您通过使用 rspcchain 表遵循父链到子链的层次结构来映射所有流程链。截至目前,我已经将输出打印到屏幕上,但想将此输出导出到 excel。我一直无法找到用于此目的的功能模块,因此将不胜感激任何帮助

注意- 在了解了可用的 SALV 类之后,我更改了代码以不同方式显示表格。

REPORT  Z_PC_VARIANT_MAPPING.

*Declaring types and variables
TYPES: BEGIN OF t_chains,
  chain_id LIKE  rspcchain-chain_id,
  variant LIKE rspcchain-variante,
END OF t_chains.

DATA: lt_rspcchain TYPE STANDARD TABLE OF t_chains,
      lwa_rspcchain TYPE t_chains,
      o_alv TYPE REF TO cl_salv_table,
      lx_msg TYPE REF TO cx_salv_msg.

TABLES: rspcchain.

*selection screen setup
SELECT-OPTIONS chain_id FOR rspcchain-chain_id.
SELECT-OPTIONS type FOR rspcchain-type.

*filling local table
SELECT chain_id variante
  FROM rspcchain  INTO TABLE lt_rspcchain
  WHERE chain_id IN chain_id AND
  type IN  type AND
  objvers = 'A'.

*original code to test printing output on screen
*LOOP AT lt_rspcchain INTO lwa_rspcchain.
*  skip.
*  WRITE lwa_rspcchain-chain_id.
*  WRITE lwa_rspcchain-variant.
*ENDLOOP.

IF sy-subrc NE 0. "sy-subrc = return code
  WRITE 'Data not found'.
ENDIF.


*loading data from local table into alv object table
TRY.
  cl_salv_table=>factory(
    IMPORTING
      r_salv_table = o_alv
    CHANGING
      t_table      = lt_rspcchain ).
  CATCH cx_salv_msg INTO lx_msg.
ENDTRY.

*calling display method to display table
o_alv->display( ).
4

3 回答 3

3

You can use the SALV framework for this, it comes with a class to export whatever would be displayed to various formats, including .MHTML and .XML formats that are understood by Excel. The class CL_SALV_TABLE has a method TO_XML to support this; additionally, you might need the CL_SALV_BS_XML_UTILS to handle the transformations. See the report SALV_TEST_TABLE_DISPLAY_OR_XML for example coding.

于 2013-05-29T17:08:05.247 回答
1

You should look at the ABAP2XLSX project.

http://wiki.sdn.sap.com/wiki/display/ABAP/abap2xlsx

Not sure if all the necessary components exist in BW, but this is really the best solution for creating spreadsheets out of ABAP code that I have found.

于 2013-05-29T19:17:49.667 回答
0

您可以尝试以下方法下载 CSV 文件,该文件的 .xls 扩展名可以在 Excel 中完美打开:

通过调用转换lt_rspcchain为 csv 内部表SAP_CONVERT_TO_CSV_FORMAT

通过调用找出用户想要存储文件的位置cl_gui_frontend_services=>file_save_dialog( )

通过调用存储文件cl_gui_frontend_services=>gui_download( )

I assume you will be able to find how these work by experience or through Google.

于 2013-05-29T15:14:48.210 回答