{"id":1182,"date":"2014-10-27T09:52:43","date_gmt":"2014-10-27T08:52:43","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1182"},"modified":"2014-10-27T09:55:13","modified_gmt":"2014-10-27T08:55:13","slug":"abap-call-transformation-to-and-from-excel-using-xlst","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1182","title":{"rendered":"ABAP &#8211; CALL TRANSFORMATION to and from Excel using XLST"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"size-full wp-image-358 alignleft\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" alt=\"SAP\" width=\"44\" height=\"50\" \/>This article is here to show you how to export data from ABAP internal table to XML accepted by MS Excel using XSLT transformation. In second part I&#8217;ll show the backwards transformation &#8211; Excel to ABAP internal table.<\/p>\n<p><!--more--><\/p>\n<p>This article is about manipulation with an Excel data but generally this approach can as well be used when you just need to export some data from ABAP to XML stored on local file (or share drive file) or vice versa &#8211; when you need to parse given XML file and process its data as an ABAP internal table.<\/p>\n<h2>XSLT Transformation from ABAP to XML (ZTRANS_ABAP2XLS)<\/h2>\n<p>Call transaction STRANS and create new XSLT Program where you put the following code<\/p>\n<pre lang=\"xml\">&lt;?mso-application progid=\"Excel.Sheet\"?&gt;\r\n&lt;!-- \r\n  The following namespaces (xmlns) are required so \r\n  the resulting XML file is correctly recognized by MS Excel \r\n--&gt;\r\n&lt;xsl:stylesheet\r\n xmlns:html=\"http:\/\/www.w3.org\/TR\/REC-html40\"\r\n xmlns:xsl=\"http:\/\/www.w3.org\/1999\/XSL\/Transform\"\r\n xmlns:sap=\"http:\/\/www.sap.com\/sapxsl\"\r\n xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\r\n xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\r\n xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\r\n version=\"1.0\"&gt;\r\n  &lt;xsl:strip-space elements=\"*\"\/&gt;\r\n&lt;!-- \r\n  EXCELDATA is the input parameter passed from ABAP \r\n--&gt;\r\n  &lt;xsl:template match=\"EXCELDATA\"&gt;\r\n    &lt;xsl:processing-instruction name=\"mso-application\"&gt;\r\n      &lt;xsl:text&gt;progid=\"Excel.Sheet\"&lt;\/xsl:text&gt;\r\n    &lt;\/xsl:processing-instruction&gt;\r\n&lt;!-- \r\n  We're going to create a Workbook with just one Worksheet \r\n  called 'SAP Data' \r\n--&gt;\r\n    &lt;xsl:element name=\"Workbook\"&gt;\r\n      &lt;xsl:element name=\"Worksheet\"&gt;\r\n        &lt;xsl:attribute name=\"ss:Name\"&gt;SAP Data&lt;\/xsl:attribute&gt;\r\n&lt;!-- \r\n  This part (element 'Names') is here to demonstrate how\r\n  to define Named-Ranges in Excel.\r\n  I'll use it to name the first row of each column according\r\n  to the FIELDNAME used in the current column \r\n--&gt;\r\n        &lt;xsl:element name=\"Names\"&gt;\r\n          &lt;xsl:for-each select=\"COLUMNS\/item\"&gt;\r\n            &lt;xsl:element name=\"NamedRange\"&gt;\r\n              &lt;xsl:attribute name=\"ss:Name\"&gt;\r\n                &lt;xsl:value-of select=\".\/FIELDNAME\"\/&gt;\r\n              &lt;\/xsl:attribute&gt;\r\n&lt;!-- \r\n  We are using relative cell names (R1C1 = Row 1, Column 1)\r\n--&gt;\r\n              &lt;xsl:attribute name=\"ss:RefersTo\"&gt;'SAP Data'!R1C&lt;xsl:value-of select=\"position()\"\/&gt;&lt;\/xsl:attribute&gt;\r\n            &lt;\/xsl:element&gt;\r\n          &lt;\/xsl:for-each&gt;\r\n        &lt;\/xsl:element&gt;\r\n&lt;!-- Here comes the data part --&gt;\r\n        &lt;xsl:element name=\"Table\"&gt;\r\n&lt;!-- This template will generate column headers --&gt;\r\n          &lt;xsl:apply-templates select=\"COLUMNS\"\/&gt;\r\n&lt;!-- This template will generate table data --&gt;\r\n          &lt;xsl:apply-templates select=\"DATA\"\/&gt;\r\n        &lt;\/xsl:element&gt;\r\n      &lt;\/xsl:element&gt;\r\n    &lt;\/xsl:element&gt;\r\n  &lt;\/xsl:template&gt;\r\n \r\n&lt;!-- \r\n  Template generating column headers:\r\n  This \"METADATA\" is sent from ABAP in sub-structure 'COLUMNS'\r\n--&gt;\r\n  &lt;xsl:template match=\"COLUMNS\"&gt;\r\n    &lt;xsl:element name=\"Row\"&gt;\r\n      &lt;xsl:for-each select=\"item\"&gt;\r\n        &lt;xsl:element name=\"Cell\"&gt;\r\n          &lt;xsl:element name=\"Data\"&gt;\r\n            &lt;xsl:attribute name=\"ss:Type\"&gt;String&lt;\/xsl:attribute&gt;\r\n&lt;!-- \r\n  The following XSLT tag (xsl:choose) is here to demonstrate branching\r\n  possibilities in XSLT\r\n--&gt;\r\n            &lt;xsl:choose&gt;\r\n              &lt;xsl:when test=\".\/HEADERTEXT\"&gt;\r\n                &lt;xsl:value-of select=\".\/HEADERTEXT\"\/&gt;\r\n              &lt;\/xsl:when&gt;\r\n              &lt;xsl:otherwise&gt;\r\n                &lt;xsl:value-of select=\".\/FIELDNAME\"\/&gt;\r\n              &lt;\/xsl:otherwise&gt;\r\n            &lt;\/xsl:choose&gt;\r\n          &lt;\/xsl:element&gt;\r\n        &lt;\/xsl:element&gt;\r\n      &lt;\/xsl:for-each&gt;\r\n    &lt;\/xsl:element&gt;\r\n  &lt;\/xsl:template&gt;\r\n \r\n&lt;!-- Template used to generate table data --&gt;\r\n  &lt;xsl:template match=\"DATA\"&gt;\r\n    &lt;xsl:for-each select=\"item\"&gt;\r\n      &lt;xsl:element name=\"Row\"&gt;\r\n        &lt;xsl:variable name=\"record\" select=\".\"\/&gt;\r\n&lt;!-- \r\n  For each field defined in 'COLUMNS' we try to find the\r\n  corresponding field here in DATA section and print out \r\n  its value and type (type is also defined in COLUMNS \r\n  structure for each field)\r\n--&gt;\r\n        &lt;xsl:for-each select=\"\/\/EXCELDATA\/COLUMNS\/item\"&gt;\r\n          &lt;xsl:variable name=\"column\" select=\".\"\/&gt;\r\n          &lt;xsl:element name=\"Cell\"&gt;\r\n            &lt;xsl:element name=\"Data\"&gt;\r\n              &lt;xsl:attribute name=\"ss:Type\"&gt;\r\n                &lt;xsl:choose&gt;\r\n                  &lt;xsl:when test=\"$column\/TYPE\"&gt;\r\n                    &lt;xsl:value-of select=\"$column\/TYPE\"\/&gt;\r\n                  &lt;\/xsl:when&gt;\r\n                  &lt;xsl:otherwise&gt;String&lt;\/xsl:otherwise&gt;\r\n                &lt;\/xsl:choose&gt;\r\n              &lt;\/xsl:attribute&gt;\r\n              &lt;xsl:value-of select=\"$record\/*[name(.)=$column\/FIELDNAME]\"\/&gt;\r\n            &lt;\/xsl:element&gt;\r\n          &lt;\/xsl:element&gt;\r\n        &lt;\/xsl:for-each&gt;\r\n      &lt;\/xsl:element&gt;\r\n    &lt;\/xsl:for-each&gt;\r\n  &lt;\/xsl:template&gt;\r\n \r\n&lt;\/xsl:stylesheet&gt;<\/pre>\n<h2>XSLT Transformation from XML to ABAP (ZTRANS_XLS2ABAP)<\/h2>\n<pre lang=\"xml\">&lt;!-- \r\n  We must mention the ':ss' namespace so we can work with Excel\r\n  tags in given XML document (in Excel format)\r\n--&gt;\r\n&lt;xsl:transform \r\n  xmlns:xsl=\"http:\/\/www.w3.org\/1999\/XSL\/Transform\"\r\n  xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" \r\n  version=\"1.0\"&gt;\r\n \r\n  &lt;xsl:output \r\n    encoding=\"iso-8859-1\" \r\n    indent=\"yes\" \r\n    method=\"xml\" \r\n    version=\"1.0\"\/&gt;\r\n  &lt;xsl:strip-space elements=\"*\"\/&gt;\r\n&lt;!-- \r\n  Note the ':ss' namespace used for Workbook and Worksheet tags\r\n  here and also later in the XSLT template - this is a MUST\r\n  for correct accessing the Excel tags, otherwise no match will be\r\n  done and no data will be processed!!!\r\n--&gt;\r\n  &lt;xsl:template match=\"\/\"&gt;\r\n    &lt;asx:abap xmlns:asx=\"http:\/\/www.sap.com\/abapxml\" version=\"1.0\"&gt;\r\n      &lt;asx:values&gt;\r\n        &lt;EXCELDATA&gt;\r\n          &lt;xsl:apply-templates select=\"ss:Workbook\/ss:Worksheet\"\/&gt;\r\n        &lt;\/EXCELDATA&gt;\r\n      &lt;\/asx:values&gt;\r\n    &lt;\/asx:abap&gt;\r\n  &lt;\/xsl:template&gt;\r\n \r\n &lt;xsl:template match=\"ss:Worksheet\"&gt;\r\n  &lt;xsl:apply-templates select=\"ss:Table\"\/&gt;\r\n &lt;\/xsl:template&gt;\r\n \r\n&lt;xsl:template match=\"ss:Table\"&gt;\r\n&lt;!-- \r\n  Process all rows except the first one which contains \r\n  column header texts - it will be skipped\r\n--&gt;\r\n  &lt;xsl:apply-templates select=\"ss:Row[position() != 1]\"\/&gt;\r\n&lt;\/xsl:template&gt;\r\n \r\n  &lt;xsl:template match=\"ss:Row\"&gt;\r\n    &lt;xsl:element name=\"item\"&gt;\r\n      &lt;xsl:for-each select=\"ss:Cell\"&gt;\r\n        &lt;xsl:choose&gt;\r\n          &lt;xsl:when test=\"position() = 1\"&gt;\r\n            &lt;MATNR&gt;&lt;xsl:value-of select=\"ss:Data\"\/&gt;&lt;\/MATNR&gt;\r\n          &lt;\/xsl:when&gt;\r\n          &lt;xsl:when test=\"position() = 2\"&gt;\r\n            &lt;WERKS&gt;&lt;xsl:value-of select=\"ss:Data\"\/&gt;&lt;\/WERKS&gt;\r\n          &lt;\/xsl:when&gt;\r\n        &lt;\/xsl:choose&gt;\r\n      &lt;\/xsl:for-each&gt;\r\n    &lt;\/xsl:element&gt;\r\n  &lt;\/xsl:template&gt;\r\n&lt;\/xsl:transform&gt;<\/pre>\n<h2>Testing demo program<\/h2>\n<pre lang=\"abap\">REPORT z_excel_demo.\r\nSELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE a1title.\r\n  SELECTION-SCREEN BEGIN OF LINE.\r\n    SELECTION-SCREEN COMMENT 1(15) a1fname FOR FIELD p_file.\r\n    SELECTION-SCREEN POSITION 17.\r\n    PARAMETERS:\r\n      p_file TYPE localfile OBLIGATORY DEFAULT 'C:\/Excel_Test.XML'.\r\n  SELECTION-SCREEN END OF LINE.\r\n  SELECTION-SCREEN BEGIN OF LINE.\r\n    SELECTION-SCREEN COMMENT 1(15) a1up FOR FIELD p_up.\r\n    SELECTION-SCREEN POSITION 17.\r\n    PARAMETERS: \r\n      p_up   RADIOBUTTON GROUP g1 USER-COMMAND dummy_cmd.\r\n  SELECTION-SCREEN END OF LINE.\r\n  SELECTION-SCREEN BEGIN OF LINE.\r\n    SELECTION-SCREEN COMMENT 1(15) a1down FOR FIELD p_down.\r\n    SELECTION-SCREEN POSITION 17.\r\n    PARAMETERS: \r\n      p_down RADIOBUTTON GROUP g1 DEFAULT 'X'.\r\n  SELECTION-SCREEN END OF LINE.\r\n  SELECTION-SCREEN BEGIN OF LINE.\r\n    SELECTION-SCREEN COMMENT 1(15) a1maxln FOR FIELD p_maxln.\r\n    SELECTION-SCREEN POSITION 17.\r\n    PARAMETERS:\r\n      p_maxln TYPE i OBLIGATORY DEFAULT 200.\r\n  SELECTION-SCREEN END OF LINE.\r\nSELECTION-SCREEN END OF BLOCK a1.\r\n \r\nINITIALIZATION.\r\n  PERFORM selection_screen_texts.\r\n \r\nFORM selection_screen_texts.\r\n  a1title = 'Excel handling demo'(001).\r\n  a1fname = 'File Name'(002).\r\n  a1up    = 'XLS Upload'(003).\r\n  a1down  = 'XLS Download'(004).\r\n  a1maxln = 'Max lines'(005).\r\nENDFORM.\r\n \r\nCLASS lcl_excel DEFINITION.\r\n  PUBLIC SECTION.\r\n    METHODS:\r\n      constructor\r\n        IMPORTING\r\n          iv_filename TYPE localfile\r\n          iv_max_lines type i DEFAULT 200,\r\n      download,\r\n      upload.\r\n  PRIVATE SECTION.\r\n* Structure of one row in final Excel sheet\r\n    TYPES:\r\n      BEGIN OF mts_row,\r\n        matnr TYPE matnr,\r\n        werks TYPE werks_d,\r\n      END OF mts_row,\r\n \r\n* Header line of excel sheet with additional info about each column\r\n      BEGIN OF mts_header,\r\n        fieldname(18)  TYPE c,\r\n        headertext(50) TYPE c,\r\n        type(10)       TYPE c,\r\n      END OF mts_header.\r\n    DATA:\r\n      BEGIN OF ms_data,\r\n        columns TYPE TABLE OF mts_header,\r\n        data    TYPE TABLE OF mts_row,\r\n      END OF ms_data,\r\n      mv_max_lines type i,\r\n      mv_filename TYPE string.\r\nENDCLASS.\r\n \r\nCLASS lcl_excel IMPLEMENTATION.\r\n  METHOD constructor.\r\n    mv_max_lines = iv_max_lines.\r\n    mv_filename  = iv_filename.\r\n  ENDMETHOD.\r\n*\r\n  METHOD download.\r\n    DATA:\r\n      lv_xml_string  TYPE string,\r\n      lv_bin_string  TYPE xstring,\r\n      lt_bin_tab     TYPE solix_tab,\r\n      lv_file_length TYPE i.\r\n \r\n    FIELD-SYMBOLS:\r\n      &lt;fs_header&gt; TYPE mts_header.\r\n \r\n*   Create first column - Material (mapping to MATNR, type Number)\r\n    APPEND INITIAL LINE TO ms_data-columns ASSIGNING &lt;fs_header&gt;.\r\n    &lt;fs_header&gt;-fieldname  = 'MATNR'.\r\n    &lt;fs_header&gt;-headertext = 'Material'.\r\n    &lt;fs_header&gt;-type       = 'Number'.\r\n \r\n*   Create second column - Plant (mapping to WERKS, type String)\r\n    APPEND INITIAL LINE TO ms_data-columns ASSIGNING &lt;fs_header&gt;.\r\n    &lt;fs_header&gt;-fieldname  = 'WERKS'.\r\n    &lt;fs_header&gt;-headertext = 'Plant'.\r\n    &lt;fs_header&gt;-type       = 'String'.\r\n \r\n*   Load some data\r\n    SELECT matnr werks\r\n      INTO CORRESPONDING FIELDS OF TABLE ms_data-data\r\n      FROM marc\r\n      UP TO mv_max_lines ROWS\r\n      WHERE matnr &lt;&gt; ''.\r\n \r\n*   Use out XSLT Program transformation with our source data\r\n*   to transform ITAB to XML (Excel format)\r\n    CALL TRANSFORMATION ZTRANS_ABAP2XML\r\n      SOURCE exceldata = ms_data\r\n      RESULT XML  lv_xml_string.\r\n \r\n* Convert XML string to binary XString\r\n    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'\r\n      EXPORTING\r\n        text   = lv_xml_string\r\n      IMPORTING\r\n        buffer = lv_bin_string\r\n      EXCEPTIONS\r\n        failed = 1\r\n        OTHERS = 2.\r\n \r\n    IF sy-subrc &lt;&gt; 0.\r\n      MESSAGE ID sy-msgid \r\n              TYPE sy-msgty \r\n              NUMBER sy-msgno \r\n              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.\r\n    ENDIF.\r\n \r\n*   Convert binary data to table-type binary output variable\r\n    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'\r\n      EXPORTING\r\n        buffer        = lv_bin_string\r\n      IMPORTING\r\n        output_length = lv_file_length\r\n      TABLES\r\n        binary_tab    = lt_bin_tab.\r\n \r\n*   Save data to local file\r\n    cl_gui_frontend_services=&gt;gui_download(\r\n      EXPORTING\r\n        bin_filesize              = lv_file_length\r\n        filename                  = mv_filename\r\n        filetype                  = 'BIN'\r\n      CHANGING\r\n        data_tab                  = lt_bin_tab\r\n      EXCEPTIONS\r\n        file_write_error          = 1\r\n        no_batch                  = 2\r\n        gui_refuse_filetransfer   = 3\r\n        invalid_type              = 4\r\n        no_authority              = 5\r\n        unknown_error             = 6\r\n        header_not_allowed        = 7\r\n        separator_not_allowed     = 8\r\n        filesize_not_allowed      = 9\r\n        header_too_long           = 10\r\n        dp_error_create           = 11\r\n        dp_error_send             = 12\r\n        dp_error_write            = 13\r\n        unknown_dp_error          = 14\r\n        access_denied             = 15\r\n        dp_out_of_memory          = 16\r\n        disk_full                 = 17\r\n        dp_timeout                = 18\r\n        file_not_found            = 19\r\n        dataprovider_exception    = 20\r\n        control_flush_error       = 21\r\n        not_supported_by_gui      = 22\r\n        error_no_gui              = 23\r\n        OTHERS                    = 24\r\n    ).\r\n \r\n    IF sy-subrc &lt;&gt; 0.\r\n      MESSAGE ID sy-msgid \r\n              TYPE sy-msgty \r\n              NUMBER sy-msgno \r\n              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.\r\n    ENDIF.\r\n  ENDMETHOD.\r\n \r\n  METHOD upload.\r\n    TYPES:\r\n      BEGIN OF lts_data,\r\n        matnr TYPE matnr,\r\n        werks TYPE werks_d,\r\n      END OF lts_data.\r\n\r\n    DATA:\r\n      lt_xml_data TYPE STANDARD TABLE OF char2048,\r\n      lt_data     TYPE TABLE OF lts_data,\r\n      gs_rif_ex   TYPE REF TO cx_root.\r\n \r\n    FIELD-SYMBOLS:\r\n      &lt;fs_data&gt; LIKE LINE OF lt_data.\r\n \r\n    CALL METHOD cl_gui_frontend_services=&gt;gui_upload\r\n      EXPORTING\r\n        filename                = mv_filename\r\n      CHANGING\r\n        data_tab                = lt_xml_data\r\n      EXCEPTIONS\r\n        file_open_error         = 1\r\n        file_read_error         = 2\r\n        no_batch                = 3\r\n        gui_refuse_filetransfer = 4\r\n        invalid_type            = 5\r\n        no_authority            = 6\r\n        unknown_error           = 7\r\n        bad_data_format         = 8\r\n        header_not_allowed      = 9\r\n        separator_not_allowed   = 10\r\n        header_too_long         = 11\r\n        unknown_dp_error        = 12\r\n        access_denied           = 13\r\n        dp_out_of_memory        = 14\r\n        disk_full               = 15\r\n        dp_timeout              = 16\r\n        not_supported_by_gui    = 17\r\n        error_no_gui            = 18\r\n        OTHERS                  = 19.\r\n \r\n    IF sy-subrc &lt;&gt; 0.\r\n      MESSAGE ID sy-msgid \r\n              TYPE sy-msgty \r\n              NUMBER sy-msgno\r\n              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.\r\n    ENDIF.\r\n    TRY.\r\n*     Use XSLT Program transformation with our source data\r\n      CALL TRANSFORMATION ZTRANS_XLS2ABAP\r\n        SOURCE XML lt_xml_data\r\n        RESULT exceldata = lt_data.\r\n      CATCH cx_root INTO gs_rif_ex.\r\n        DATA: lv_msg TYPE string.\r\n        lv_msg = gs_rif_ex-&gt;get_text( ).\r\n        MESSAGE lv_msg TYPE 'E'.\r\n    ENDTRY.\r\n \r\n    WRITE:5 'Material', 30 'Plant'.\r\n    LOOP AT lt_data ASSIGNING &lt;fs_data&gt;.\r\n      WRITE:\/5 &lt;fs_data&gt;-matnr, 30 &lt;fs_data&gt;-werks.\r\n      IF sy-tabix = mv_max_lines.\r\n        EXIT.\r\n      ENDIF.\r\n    ENDLOOP.\r\n \r\n  ENDMETHOD.\r\nENDCLASS.\r\n \r\nDATA:\r\n  lo_excel TYPE REF TO lcl_excel.\r\n \r\nSTART-OF-SELECTION.\r\n  CREATE OBJECT lo_excel\r\n    EXPORTING\r\n      iv_filename  = p_file\r\n      iv_max_lines = p_maxln.\r\n \r\n  IF p_down = 'X'.\r\n    lo_excel-&gt;download( ).\r\n  ELSE.\r\n    lo_excel-&gt;upload( ).\r\n  ENDIF.\r\n \r\n  MESSAGE 'Done' TYPE 'S'.\r\n<\/pre>\n<h2>Output XML (Excel format)<\/h2>\n<p>I executed the demo program with Export option with up to 5 records from MARC table<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_01.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1188\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1188\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_01.png\" data-orig-size=\"464,206\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Process data in ABAP and download into Excel\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_01.png\" class=\"alignnone size-medium wp-image-1188\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_01-300x133.png\" alt=\"Process data in ABAP and download into Excel\" width=\"300\" height=\"133\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_01-300x133.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_01.png 464w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<pre lang=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;?mso-application progid=\"Excel.Sheet\"?&gt;\r\n&lt;Workbook \r\n  xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" \r\n  xmlns:html=\"http:\/\/www.w3.org\/TR\/REC-html40\" \r\n  xmlns:o=\"urn:schemas-microsoft-com:office:office\" \r\n  xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" \r\n  xmlns:x=\"urn:schemas-microsoft-com:office:excel\"&gt;\r\n  &lt;Worksheet ss:Name=\"SAP Data\"&gt;\r\n    &lt;Names&gt;\r\n      &lt;NamedRange ss:Name=\"MATNR\" ss:RefersTo=\"'SAP Data'!R1C1\" \/&gt;\r\n      &lt;NamedRange ss:Name=\"WERKS\" ss:RefersTo=\"'SAP Data'!R1C2\" \/&gt;\r\n    &lt;\/Names&gt;\r\n    &lt;Table&gt;\r\n      &lt;Row&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"String\"&gt;Material&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"String\"&gt;Plant&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n      &lt;\/Row&gt;\r\n      &lt;Row&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"Number\"&gt;000000000000123123&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"String\"&gt;0050&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n      &lt;\/Row&gt;\r\n      &lt;Row&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"Number\"&gt;000000000001231234&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"String\"&gt;0050&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n      &lt;\/Row&gt;\r\n      &lt;Row&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"Number\"&gt;000000000007654321&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"String\"&gt;0050&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n      &lt;\/Row&gt;\r\n      &lt;Row&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"Number\"&gt;000000000007777741&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"String\"&gt;0050&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n      &lt;\/Row&gt;\r\n      &lt;Row&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"Number\"&gt;000000000007777742&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n        &lt;Cell&gt;\r\n          &lt;Data ss:Type=\"String\"&gt;0050&lt;\/Data&gt;\r\n        &lt;\/Cell&gt;\r\n      &lt;\/Row&gt;\r\n    &lt;\/Table&gt;\r\n  &lt;\/Worksheet&gt;\r\n&lt;\/Workbook&gt;<\/pre>\n<h2><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_02.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1189\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1189\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_02.png\" data-orig-size=\"503,346\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Exported data displayed in MS Excel\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_02.png\" class=\"alignnone size-medium wp-image-1189\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_02-300x206.png\" alt=\"Exported data displayed in MS Excel\" width=\"300\" height=\"206\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_02-300x206.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_02-436x300.png 436w, https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_02.png 503w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h2>\n<h2>Output of ABAP internal table<\/h2>\n<p>I executed the demo program with Import option using the XLS file previously generated by the same program<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_03.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1187\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1187\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_03.png\" data-orig-size=\"460,203\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Excel &amp;#8211; Upload and process in ABAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_03.png\" class=\"alignnone size-medium wp-image-1187\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_03-300x132.png\" alt=\"Excel - Upload and process in ABAP\" width=\"300\" height=\"132\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_03-300x132.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_03.png 460w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_04.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1190\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1190\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_04.png\" data-orig-size=\"298,177\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Imported data from MS Excel processed in ABAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_04.png\" class=\"alignnone size-full wp-image-1190\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/TRANSFORMATIONS_04.png\" alt=\"Imported data from MS Excel processed in ABAP\" width=\"298\" height=\"177\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article is here to show you how to export data from ABAP internal table to XML accepted by MS Excel using XSLT transformation. In second part I&#8217;ll show the backwards transformation &#8211; Excel to ABAP internal table.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"ABAP - CALL TRANSFORMATION to and from Excel using XLST","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,9],"tags":[350,304,352,351,349],"class_list":["post-1182","post","type-post","status-publish","format-standard","hentry","category-abap","category-development","tag-call-transformation","tag-excel","tag-strans","tag-xml","tag-xslt"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-j4","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1182"}],"version-history":[{"count":6,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1182\/revisions"}],"predecessor-version":[{"id":1192,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1182\/revisions\/1192"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}