‎2016 Sep 02 9:33 AM
Hi SAP Experts,
I have generated an XML file through XSLT_TOOL and used that in a program. However, when I opened the file the display is unformatted.
Currently, I fix this by opening the xml file in the notepad. Then save it without changing anything. When I open it again, it's displaying correctly.
I do not understand why this is happening and also why the file generated by the program is unformatted unlike the 2nd screenshot.
Can anyone explain this?
Thank you and Regards,
Esteves Jaleco
‎2016 Sep 02 3:14 PM
Hi,
Are you using CL_GUI_HTML_VIEWER to display XML or something else? If not how do you display the XML document?
BTW. Good luck with JPK implementation
‎2016 Sep 02 3:47 PM
Hi Bartosz,
Oh, I'm not aware of this class. I'll try using this. Currently, after i have created my xml table, using CALL TRANSFORMATION z_trans SOURCE jpk = i_jpk RESULT XML l_xml, i converted l_xml from xstring to binary then binary to table of string. then i downloaded this via cl_gui_frontend_services=>gui_download. then i opened it via the same class and using method =>execute.
Thank you. I'm guessing you had an experience in implementing this?
Regards,
Esteves
‎2016 Sep 02 4:11 PM
Indeed, I had
I was displaying 2 XMLs next to each other hence the splitter class but I believe you will find the below sample useful.
DATA lo_html_viewer_req TYPE REF TO CL_GUI_HTML_VIEWER.
DATA lo_splitter TYPE REF TO cl_gui_splitter_container.
DATA lo_container_req TYPE REF TO cl_gui_container.
CALL METHOD lo_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = lo_container_req.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xml_req
IMPORTING
output_length = lv_length
TABLES
binary_tab = lt_data[].
IF lo_html_viewer_req IS BOUND.
lo_html_viewer_req->close_document( ).
ELSE.
CREATE OBJECT lo_html_viewer_req
EXPORTING
parent = lo_container_req
EXCEPTIONS
cntl_error = 1
cntl_install_error = 2
dp_install_error = 3
dp_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
lo_html_viewer_req->load_data(
EXPORTING
type = 'application' " Type of a MIME Object
subtype = 'xml' " Subtype of a MIME Object
size = lv_length " Length of Data
* encoding = " Encoding for MIME Object
* charset = " Encoding for MIME Object
IMPORTING
assigned_url = lv_url " URL
CHANGING
data_table = lt_data[] " data table
* iscontentchanged = " Sets to 1 if the content is filtered else it is 0
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_general = 2
cntl_error = 3
OTHERS = 5
).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
lo_html_viewer_req->show_url( lv_url ).
‎2016 Sep 02 4:50 PM
Hi,
From the code, I saw that you are using gui containers. What if I'm not using any screens? I just want to download the file and be able to display it correctly?
Thank you.
‎2016 Sep 02 5:22 PM
So when you download the file, the file itself is corrupted - is that correct?
Have you tried downloading your XML as 'BIN' instead of 'ASC' (parameter FILETYPE of CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD) and skipping the step where you convert binary to string?
BTW. What do you mean that you are not displaying the file? So how did you notice you have problem with displaying the file in SAP?
‎2016 Sep 02 5:26 PM
No, not necessarily corrupted. I am currently using BIN and file is generated properly. however the display is wrong. As you can see from the first snippet, there is no formatting whatsoever. however when i opened the file via the notepad and saved it without changing anything, I am getting the desired xml display.
‎2016 Sep 02 5:35 PM
I'm still missing a step here I understand that you have issue with displaying but I do not understand how you display your XML in SAP - could you please explain?
It could be me or that it's Friday afternoon but I simply did not catch how or where you display the file