Link Search Menu Expand Document

XTT - Xml template toolkit


XTT helps you to automate your reporting routine in SAP

  • Get existing report from your customers
  • Use preferable editor (MS Excel, Word or Adobe LiveCycle Designer) and replace some parts of it with markers inclosed in curly brackets
  • Link all formulas, charts and pivot tables to this markers
  • In abap call merge() method to pass all data including nested structures, tables and trees
  • Use download( ) | send( ) | show( ) method for appropriate action
  • That’s all!


tr. Z_XTT_DEMO


Excel Template

image

Code

" Template storage class
" tr OAOR -> zcl_xtt_file_oaor, external sources -> ZCL_XTT_FILE_RAW
DATA(lo_file) = NEW zcl_xtt_file_smw0( 'Z_TEMPLATE_ID.XLSX' ).

" Excel (Use ZCL_XTT_WORD_DOCX, ZCL_XTT_PDF for word and pdf respectively)
DATA(lo_xtt) = NEW zcl_xtt_excel_xlsx( io_file = lo_file ).

" R is a marker in the IV_TEMPLATE
lo_xtt->merge( iv_block_name = 'R'
               is_block = VALUE ts_root(
                begda = pn-begda
                endda = pn-endda
                
                " Transmission of a table (or tree)
                t     = lt_alv    
               ) ).

" Download to sap_tmp. You could specify path or show SaveAs dialogue
" Call SHOW( ) for inplace mode
lo_xtt->download( ).


  • Various classes for different purposes:
    ZCL_XTT_EXCEL_XLSX - Excel Workbook (.xlsx), Excel Macro-Enabled Workbook (.xlsm)
    ZCL_XTT_EXCEL_XML - Xml Spreadsheet 2003 (.xml)
    ZCL_XTT_WORD_DOCX - Word Document (
    .docx), Word Macro-Enabled Document (.docm)
    ZCL_XTT_WORD_XML - Word XML 2003 Document (
    .xml), Word XML Document (.xml)
    ZCL_XTT_PDF - Adobe XML Form (
    .xdp)

  • Report generating without OLE:
    The SAP applicaion server delivers a ready file
    No dangerous macro and security issues
    Availability of background execution

  • Using templates that gives several benefits:
    Seperation of data representation from ABAP code (no methods as cell->set_bold(true) )
    Using familiar redactor as MS Word, MS Excel & Adobe LiveCycle Designer
    No need to be XML guru and generate XML by yourself
    Complete preservation of the original document formatting
    Precreation of complex reporting objects such as pivot tables and charts


Table of contents