Link Search Menu Expand Document

Simple structure

The easiest way to send elementary data to a report is to pass them by a structure (or in an object attributes)

    " Document structure
    BEGIN OF ts_root,
      title  TYPE char15,
      text   TYPE string,
      int    TYPE i,
      bottom TYPE string, " Any field could be REF TO, STRUCTURE or TABLE
    END OF ts_root.

The data could look like

    ls_root-title   = 'Document title'.
    ls_root-text    = 'Just string'.
    ls_root-int     = 3.
    ls_root-bottom  = 'bottom'.

The template in Excel, Word or pdf could be like:

Basic example

Title: {R-TITLE}

Just put markers where you want

Just string {R-TEXT}

Integer {R-INT}

Bottom: {R-BOTTOM}

If you combine the structure with the ls_root data, the report may look like this

Basic example

Title: Document title

Just put markers where you want

Just string Just string

Integer 3

Bottom: bottom ***

XTT Library

The code for outputting this structure to the template may look like this:

    NEW zcl_xtt_excel_xlsx( NEW zcl_xtt_file_smw0( ) )->merge( ls_root )->download( ).

* The library code is compatible with ABAP 7.02. New syntax is used for demonstration purposes

1) ZCL_XTT_EXCEL_XLSX can be replaced with 1 of the ZCL_XTT descendant classes


2) Instead of ZCL_XTT_FILE_SMW0 to any of the following


3) The MERGE () method can be called several times, for different labels. Default ‘R’

4) The DOWNLOAD () method has optional parameters for downloading the report. For other actions, you can use one of the methods:


All text formatting within {} remains the same.

In a word, a block that looks the same can consist of several with the same formatting.

To exclude such a case, you need to copy the block from {} to notepad, copy it and paste it back

From new version ZCL_XTT_WORD_DOCX & ZCL_XTT_WORD_XML classes in such cases

would use a style of the first part