cancel
Showing results for 
Search instead for 
Did you mean: 

XML output showing error in Browser

06-14-2023 6:32 AM
ricky_shaw Contributor
2565 views 10 comments
0 Likes
SAP Managed Tags
Subscribe

Hi,

I am generating an XML output using call transformation & this is followed by downloading to an .xml file on my PC desktop.

" Get Item Info.
call transformation zfilerunds
source requestfile = ls_checks
result xml ls_xml_result .

append ls_xml_result to it_xml_out.

data: fname type string.

fname = 'C:\Users\ \OneDrive\Desktop\Refunds1.xml'.
call method cl_gui_frontend_services=>gui_download
exporting
filename = fname
filetype = 'ASC'
replacement = ''
changing
data_tab = it_xml_out "it_xml_bkdata
exceptions
others = 24.

Its the same on Edge, Chrome or Firefox browsers. Please suggest me if i need to do any setting for xml handling.

0 Likes

Accepted Solutions (0)

Answers (2)

Answers (2)

Sandra_Rossi
Active Contributor
0 Likes

It could be a combination of several factors. I guess you are using IE?

  • I guess you have generated UTF-16 because you are using characters/string
  • GUI_DOWNLOAD converts the text into your laptop codepage based on your SAP GUI settings, which may lead to bytes inconsistent with encoding="utf-16"
  • maybe your IE version doesn't know how to display UTF-16
  • etc.

If it's not clear what I'm saying, just do everything with bytes to avoid codepage issues:

  • Transform into XSTRING instead of STRING (will be UTF-8)
  • GUI_DOWNLOAD in BIN mode (won't convert the bytes)
DATA xstring TYPE xstring.
call transformation zfilerunds
   source requestfile = ls_checks
   result xml xstring.

DATA(solix_tab) = cl_bcs_convert=>xstring_to_solix( xstring ).

data: fname  type string.
fname = 'C:\Users\ \OneDrive\Desktop\Refunds1.xml'.
call method cl_gui_frontend_services=>gui_download
  exporting
    bin_filesize = xstrlen( xstring )
    filename = fname
    filetype = 'BIN'
  changing
    data_tab = solix_tab
  exceptions
    others   = 24.
ricky_shaw
Contributor
0 Likes

ok. Even when i am downloading the file from AL11 & as .xml onto a desktop its showing this error.

Sandra_Rossi
Active Contributor
0 Likes

Exact same kind of issue, but you also complexify because you are using an additional ABAP code to read from server, then write to desktop. If the data is transferred as character instead of byte, you risk that it's altered due to character encoding.

You won't understand what happens if you don't clearly understand what are characters, bytes, character encoding (codepages and algorithm).

xiaosanyu
Participant
0 Likes

change zfilerunds to ID and try again.

ricky_shaw
Contributor
0 Likes

Hi Yu, I didn't get you.Can you please elaborate?

xiaosanyu
Participant
0 Likes
DATA: lv_xml TYPE string.

CALL TRANSFORMATION id
  SOURCE source = <abap_structure>
  RESULT XML lv_xml.

CALL FUNCTION 'DOWNLOAD'
  EXPORTING
    filename             = 'file.xml'
    filetype             = 'ASC'
  TABLES
    data_tab             = lv_xml.

Using this code demo, check if the generated XML file can be opened

xiaosanyu
Participant
0 Likes

Also, you can show me the content of your XML file so that I can check the problem

ricky_shaw
Contributor
0 Likes

Hi Xu, I shared the pic of the XML contents..

zfilerunds is the name of my XMLfile. How can i make it to ID.

Can you send me the syntax?