Xslt ecc6  ISO-8859-1 problem when download xml file

Advertisement
October 11

Hello,
i create an ABAP test program:
*& Report Z_ABAP_TO_XML                                             *
*& Write the data from an internal ABAP table into an XML document, *
*& and write it onto your frontend computer                         *
REPORT z_abap_to_xml.
TYPE-POOLS: abap.
CONSTANTS gs_file TYPE string VALUE 'C:\Users\Marco Consultant\Desktop\test.xml'.
* This is the structure for the data to go into the XML file
TYPES: BEGIN OF ts_person,
  cust_id(4)    TYPE n,
  firstname(20) TYPE c,
  lastname(20)  TYPE c,
END OF ts_person.
* Table for the XML content
DATA: gt_itab        TYPE STANDARD TABLE OF char2048.
* Table and work area for the data to fill the XML file with
DATA: gt_person      TYPE STANDARD TABLE OF ts_person,
      gs_person      TYPE ts_person.
* Source table that contains references
* of the internal tables that go into the XML file
DATA: gt_source_itab TYPE abap_trans_srcbind_tab,
      gs_source_wa   TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex      TYPE REF TO cx_root,
      gs_var_text    TYPE string.
* Fill the internal table
gs_person-cust_id   = '3'.
gs_person-firstname = 'Bill'.
gs_person-lastname  = 'Gates'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '4'.
gs_person-firstname = 'Frodo'.
gs_person-lastname  = 'Baggins'.
APPEND gs_person TO gt_person.
* Fill the source table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IPERSON".
GET REFERENCE OF gt_person INTO gs_source_wa-value.
gs_source_wa-name = 'IPERSON'.
APPEND gs_source_wa TO gt_source_itab.
* Perform the XSLT stylesheet
TRY.
    CALL TRANSFORMATION z_abap_to_xml
    SOURCE (gt_source_itab)
    RESULT XML gt_itab.
  CATCH cx_root INTO gs_rif_ex.
    gs_var_text = gs_rif_ex->get_text( ).
    gs_var_text = gs_rif_ex->get_text( ).
    MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
* Download the XML file to your client
CALL METHOD cl_gui_frontend_services=>gui_download
  EXPORTING
    filename                = gs_file
  CHANGING
    data_tab                = gt_itab
  EXCEPTIONS
    file_write_error        = 1
    no_batch                = 2
    gui_refuse_filetransfer = 3
    invalid_type            = 4
    no_authority            = 5
    unknown_error           = 6
    header_not_allowed      = 7
    separator_not_allowed   = 8
    filesize_not_allowed    = 9
    header_too_long         = 10
    dp_error_create         = 11
    dp_error_send           = 12
    dp_error_write          = 13
    unknown_dp_error        = 14
    access_denied           = 15
    dp_out_of_memory        = 16
    disk_full               = 17
    dp_timeout              = 18
    file_not_found          = 19
    dataprovider_exception  = 20
    control_flush_error     = 21
    not_supported_by_gui    = 22
    error_no_gui            = 23
    OTHERS                  = 24.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
and i created XSLT test conversion:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
  <xsl:strip-space elements="*"/>
  <xsl:template match="/">
    <CUSTOMERS>
      <xsl:apply-templates select="//IPERSON/item"/>
    </CUSTOMERS>
  </xsl:template>
  <xsl:template match="IPERSON/item">
    <item>
      <customer_id>
        <xsl:value-of select="CUST_ID"/>
      </customer_id>
      <first_name>
        <xsl:value-of select="FIRSTNAME"/>
      </first_name>
      <last_name>
        <xsl:value-of select="LASTNAME"/>
      </last_name>
    </item>
  </xsl:template>
</xsl:transform>
Seem all correct infact the program download  a file XML but the file have the encoding="UTF-16" also if i have specified "iso-8859-1" and if i tried to opend the xml file the file appears not correct because is generated with as first character "#", why?
Below the xml generated..
What i have to do to generate a correct XML without errors?
#<?xml version="1.0" encoding="utf-16"?>
<CUSTOMERS>
  <item>
    <customer_id>0003</customer_id>
    <first_name>Bill</first_name>
    <last_name>Gates</last_name>
  </item>
  <item>
    <customer_id>0004</customer_id>
    <first_name>Frodo</first_name>
    <last_name>Baggins</last_name>
  </item>
</CUSTOMERS>

Advertisement

Replay

hello all!
i resolve the problem using:
* Perform the XSLT stylesheet
  g_ixml = cl_ixml=>create( ).
  g_stream_factory = g_ixml->CREATE_STREAM_FACTORY( ).
  g_encoding = g_ixml->create_encoding( character_set = 'utf-16' "unicode
    byte_order = 0 ).
  resstream = g_stream_factory->CREATE_OSTREAM_ITABLE( table = gt_xml_itab ).
  call method resstream->set_encoding
    exporting encoding = g_encoding.
I think it's the right way, i put all my ABAP program updated:
*& Report Z_ABAP_TO_XML                                             *
*& Write the data from an internal ABAP table into an XML document, *
*& and write it onto your frontend computer                         *
REPORT z_abap_to_xml.
TYPE-POOLS: abap.
CONSTANTS gs_file TYPE string VALUE 'C:UsersMarco ConsultantDesktop     est.xml'.
data:  g_ixml type ref to if_ixml.
data:  g_stream_factory type ref to IF_IXML_STREAM_FACTORY.
data:  resstream type ref to if_ixml_ostream.
data:  g_encoding type ref to if_ixml_encoding.
* This is the structure for the data to go into the XML file
TYPES: BEGIN OF ts_person,
  cust_id(4)    TYPE n,
  firstname(20) TYPE c,
  lastname(20)  TYPE c,
END OF ts_person.
* Table for the XML content
DATA: gt_xml_itab        TYPE STANDARD TABLE OF char2048.
* Table and work area for the data to fill the XML file with
DATA: gt_person      TYPE STANDARD TABLE OF ts_person,
      gs_person      TYPE ts_person.
* Source table that contains references
* of the internal tables that go into the XML file
DATA: gt_source_itab TYPE abap_trans_srcbind_tab,
      gs_source_wa   TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex      TYPE REF TO cx_root,
      gs_var_text    TYPE string.
* Fill the internal table
gs_person-cust_id   = '3'.
gs_person-firstname = 'Bill'.
gs_person-lastname  = 'Gates'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '4'.
gs_person-firstname = 'Frodo'.
gs_person-lastname  = 'Baggins'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '5'.
gs_person-firstname = 'Frodo'.
gs_person-lastname  = 'Baggins'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '6'.
gs_person-firstname = 'Frodo'.
gs_person-lastname  = 'Baggins'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '7'.
gs_person-firstname = 'Frodo'.
gs_person-lastname  = 'Baggins'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '8'.
gs_person-firstname = 'Frodo'.
gs_person-lastname  = 'Baggins'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '9'.
gs_person-firstname = 'Frodo'.
gs_person-lastname  = 'Baggins'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '10'.
gs_person-firstname = 'Frodo'.
gs_person-lastname  = 'Baggins'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '11'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
gs_person-cust_id   = '88'.
gs_person-firstname = 'Frodoèé'.
gs_person-lastname  = 'Baggins~¦Üu0192'.
APPEND gs_person TO gt_person.
* Fill the source table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IPERSON".
GET REFERENCE OF gt_person INTO gs_source_wa-value.
gs_source_wa-name = 'IPERSON'.
APPEND gs_source_wa TO gt_source_itab.
* Perform the XSLT stylesheet
  g_ixml = cl_ixml=>create( ).
  g_stream_factory = g_ixml->CREATE_STREAM_FACTORY( ).
  g_encoding = g_ixml->create_encoding( character_set = 'utf-16' "unicode
    byte_order = 0 ).
  resstream = g_stream_factory->CREATE_OSTREAM_ITABLE( table = gt_xml_itab ).
  call method resstream->set_encoding
    exporting encoding = g_encoding.
TRY.
    CALL TRANSFORMATION z_abap_to_xml
    SOURCE (gt_source_itab)
    RESULT XML gt_xml_itab.
  CATCH cx_root INTO gs_rif_ex.
    gs_var_text = gs_rif_ex->get_text( ).
    gs_var_text = gs_rif_ex->get_text( ).
    MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
* Download the XML file to your client
CALL METHOD cl_gui_frontend_services=>gui_download
  EXPORTING
    filename                = gs_file
    FILETYPE                  = 'BIN'
  CHANGING
    data_tab                = gt_xml_itab
  EXCEPTIONS
    file_write_error        = 1
    no_batch                = 2
    gui_refuse_filetransfer = 3
    invalid_type            = 4
    no_authority            = 5
    unknown_error           = 6
    header_not_allowed      = 7
    separator_not_allowed   = 8
    filesize_not_allowed    = 9
    header_too_long         = 10
    dp_error_create         = 11
    dp_error_send           = 12
    dp_error_write          = 13
    unknown_dp_error        = 14
    access_denied           = 15
    dp_out_of_memory        = 16
    disk_full               = 17
    dp_timeout              = 18
    file_not_found          = 19
    dataprovider_exception  = 20
    control_flush_error     = 21
    not_supported_by_gui    = 22
    error_no_gui            = 23
    OTHERS                  = 24.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-- we don't need the stream any more, so let's close it...
CALL METHOD resstream->CLOSE( ).
CLEAR resstream.

View 4 Replies

Problem when loading xml file using sql loader

November 30

I am trying to load data into table test_xml (xmldata XMLType) i have an xml file and i want whole file to be loaded into a single column when i use the following control file and executed from command prompt as follows sqlldr [email protected]$TWO_TASK control=$X

View All Replies

Client found response content type of 'text/html;charset=iso-8859-1', but expected 'text/xml'.

November 30

Hello All, I am on BI 4.0 SP6. I am login to Advance Analysis Office using sso with Authentication : Windows AD, but when i login errors occurs: Client found response content type of 'text/html;charset=iso-8859-1', but expected 'text/xml'. The reques

View All Replies

I am running 4.0.1 and when I download something the Download box stays blank-even though I have selected in General Preferences 'Show the downloads window when downloading a file' AND selected 'Save files to Downloads'....???

October 11

I am running 4.0.1 and when I download something the Download box stays blank-even though I have selected in General Preferences 'Show the downloads window when downloading a file' AND selected 'Save files to Downloads'....???In Firefox Options / Pri

View All Replies

I can not do the update , what should I do to fix this error ? "There was a problem with downloading the file . For tips on troubleshooting , please go to Customer Support . ( Error code : 204 ) ." thanks

October 11

I can not do the update , what should I do to fix this error ? "There was a problem with downloading the file . For tips on troubleshooting , please go to Customer Support . ( Error code : 204 ) ." thanksHi, Please refer to the help document bel

View All Replies

How can I turn off the Download pop up Window from displaying when downloading a file?

November 30

How can I turn off the Download pop up Window from displaying when downloading a file?To not display the built-in Firefox downloads window, Tools > Options > General tab, un-check "Show the <u>D</u>ownloads window when downloading a

View All Replies

How to download XML file to ITAB

October 11

hi friends this  is my urgent req. how to download XML file to Local itab any other function or sample program available. with luv. pauldharmaHi, please check this code. Uploading Excel file to SAP Using Function Module ALSM_EXCEL_TO_INTERNAL_TABLE R

View All Replies

Problems when downloading a podcast

October 11

Hi, I need help on what to do when I get a error message when downloading a podcast. To be specific, the Mad Money Jim Cramer's Podcast. When I try to download the podcast, the message that appears is: "There was a problem downloading, Authorization

View All Replies

I have a 2007 iMac with version 10.6.8.  When downloading "some" files to my computer, these files become "zip files."  When I open the zip file, it produces a document in some coding language. How can I open the file to produce a legible document?

November 30

I have a 2007 iMac with version 10.6.8 and 4GB of expanded memory.  When downloading "some" emailed documents, the downloaded file becomes a "zip file," which when opened looks like a coded message.  How can I open the "zip file&q

View All Replies

Error message when downloading a file in Firefox 3.0.1

October 11

Hello everyone, hope you can help. I'm thinking maybe this is a permissions issue? When I try to download a file in Firefox 3 I get the following error message: "/Users/xxxx/Desktop/iPhoto_714.dmg could not be opened, because an unknown error occurre

View All Replies

"\n" problem while downloading the file in unix environment

November 30

Hi folks, I have some problem in uploading and downloading the file in unix environment.. This is my sample code i am using. File userDataFile = new File("xyz".csv"); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(user

View All Replies

Both Safari & Chrome freezing when downloading a file

October 11

Hi, Ever since upgrading to Yosemite I'm having issues sometimes downloading files from browsers. I usually use Safari and I noticed that when clicking on file and selecting Download Linked File or Download Linked File As, Safari freezes and requires

View All Replies

Compression failed message when downloading zip files. Any suggestions never had this issue before.

November 30

Hi using a site i always have used when downloading something it downloads then when it is about to open the zip file it says decompression failed. Any suggestions i googled many solutions nothing seemed to work. Here is my mac book info if it helps.

View All Replies

#2032 Stream Error when downloading .air file for update

November 30

Hi guys, I have made a very simple self update air application. When the .air file to download for updating is on a localhost server everything works fine, however when the .air file is on a remote server I got a #2032 stream error when trying to dow

View All Replies

Audio problem when importing video files.

November 30

Hello everyone, I just started using FCP X a few days ago for a university project and I seem to encounter an audio problem when importing videos in .mp4, .mov format or via the import from camera option. Indeed I need to import videos in .mp4 and .m

View All Replies

Problem when selecting ITunes File "ITunes Library.itl" cannot be read because it was created by a newer version of ITunes? Need help!

November 30

Issue when selecting ITunes - File reads "ITunes Library.itl" cannot be read because it was created by a newer version of ITunes. 1. Re-installed ITunes and problem still exist, and 2. Re-installed earlier version of ITTunes (10.3) problem still

View All Replies

Problem in downloading multiple files

October 11

Hi I have an item of type messageDownload in an Advanced Table region. Switcher Region ---> Case 1 ---> Case 2 --> region(Header) --> Region(Advanced Table) --> Column --> Item (messageDownload). The field is fetching the right file when

View All Replies

Problem in Downloading the file by using FM : GUI_DOWNLOAD in XLSX format

November 30

Dear Experts,     We are using FM: GUI_DOWNLOAD to download the data in .XLSX Format,But it is giving ERROR while opening the Excel file. So,Please help me how to download the file in .XLSX format. checked DC30 - for file extensions..there we were ob

View All Replies

Debugging mode stopped automatically when using xml file load

November 30

Dear Sir, I am trying to develop a new add-on using xml files for creating new forms. In fact I was using the sample code delivered with the SDK ( WorkingWithXml - under VB.NET). The Problem is that when I am in the debuging mode and after the form l

View All Replies

Error when opening xml file .....

November 30

Hi all, I am using Simple transforamtion and trying to download the file to presentation server. The file is downloaded and when i open it i get this message : "XML document must have a top level element. Error processing resource " Please let m

View All Replies

Tags:

  1. how to post miro for zero grn value
  2. software to stop pops safari 5.1.10
  3. mac internet recovery mac mini2009
  4. youtube does not open safari mac kids ç
  5. BAPI_SALESDOCUMENT_CHANGE sample
  6. Profitability Segment Number service PO
  7. segment e1idku4
  8. SAP fm view maintian
  9. CL_SQL_RESULT_SET=============CP
  10. modifing a ke30 report
Copyrights 2017 Fcffair BigData Resource, All rights reserved