Skip to Content
Technical Articles
Author's profile photo Birzhan Moldabayev

Yet another reporting library


Let me present to your judgment yet one more template engine for Excel, Word and Pdf. All you need to do to is combine the data with a template.

The easiest way to send data to a report is to pass them by a structure (or an object with 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


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


    • Instead of ZCL_XTT_FILE_SMW0 to any of the following



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



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



Documentation and example files available here



Templates and reports


In conclusion:
As you can see the general idea is very simple: As other template engines XTT allows you to separate a model (ABAP data) from a view (a template). This separation gives the ability to change a view without changing a model.

For those who decided to try the opus in a sandbox

Installation guide



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Maxim Freck
      Maxim Freck

      Very nice! Great success!

      Author's profile photo Birzhan Moldabayev
      Birzhan Moldabayev
      Blog Post Author


      Author's profile photo S Abinath
      S Abinath

      Nice Article, Thanks for sharing