‎2010 Jun 18 1:45 PM
Hi All,
I have an internal table with data from different tables.I would like to generate an xml file from the internal table.Please let me know if there is any fm or report for this
Thanks
Bala Duvvuri
‎2010 Jun 18 3:48 PM
Hi,
Check "simple transformations" .
http://help.sap.com/abapdocu_70/en/ABENABAP_ST.htm.
or
SE80->Workbench _>edit object->more->transofrmation radio button enter 'Name' and click view.
CALL TRANSFORMATION ('Name')
SOURCE tab = ITAB[]
RESULT XML xml_out.
Here XML_OUT stores the converted data in XML format.
After that depends on your requirement. You can store in custom table or in the application server (unix directory) or download to front end.
Thanks!
‎2010 Jun 18 6:15 PM
Boby,
I checked the link and it has used CL_ABAP_BROWSER to display xml but i dont find that class.Please clarify
Thanks
Bala Duvvuri
‎2010 Jun 18 6:26 PM
That's only to display the resulting XML from the example. You can render the XML using ST or XSLT in the transformation as he said or you can use one of the other XML functions or classes available. Read the rest of the help files regarding transformations.
‎2010 Jun 18 7:18 PM
I followed this link
http://sapblog.rmtiwari.com/2009/04/generate-simple-transformation-for-xml.html
and created xsd and report and it created xml file but when i tried to open it ,it shows the following error in browser
As mentioned in the link i executed tcode SSTDEMO1 to download a sample xml file ,but when i tried to open it i am getting the same error
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
-
Invalid at the top level of the document. Error processing resource 'file:///C:/Download/xmlfile.xml'. Line 1, Position 124
As mentioned in the link i executed tcode SSTDEMO1 to download a sample xml file ,but when i tried to open it i am getting the same error
Please let me know how i can solve this
Thanks
Bala Duvvuri
‎2010 Jun 19 6:29 AM
This means that the xml is malformed.
Try adding -
OPTIONS addition to the CALL TRANSFORMATION statement to avoid header .
Syntax :
CALL TRANSFORMATION (`ID`) OPTIONS XML_HEADER = 'no'
SOURCE itab = itab[]
RESULT XML output.
‎2010 Jun 19 7:17 AM
Boby,
I am already using that but still i get the problem
Thanks
Bala Duvvuri
‎2010 Jun 19 7:33 AM
BALA,
I checked it ,
call function 'GUI_DOWNLOAD'
exporting filename = s
filetype = 'ASC'
write_lf = ' '
tables data_tab = xmltab_res
While downloading a special character is there in the xmltab_res internal table record-
0<flights/>
Please remove it while debugging and execute .
You will not encounter the error,
Thanks!
‎2010 Jun 19 1:55 PM
Boby,
thanks for the answer but how will i remove that special character in the program
Thanks
Bala Duvvuri
Edited by: Bala Duvvuri on Jun 20, 2010 7:21 PM
‎2010 Jun 21 7:14 AM
Set up the correct encoding while downloading with 'GUI_DOWNLOAD".
You will have code page option in the import parameters
DATA: encode TYPE ABAP_ENCODING.
encode = '4103'. "'4103' - UTF-16 LE(Little Endian)
PAss
code page = encode
‎2010 Jun 21 7:45 AM
Boby,
Still it is not working.
when i open the xml using notepad it has some two special characters ,if i remove them it is working fine from browser and these characters are created only when i use the code page parameter
this is the code i am writing
*&---------------------------------------------------------------------*
*& Report ZDEMOXML
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZDEMOXML.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
data xml_xstring TYPE XSTRING.
data lt_tab type ZNEWDATASET.
data ls_tab type ZNEWSTRUCTURE.
ls_tab-name = 'sdsd'.
append ls_tab to lt_tab.
ls_tab-name = 'sdsd'.
append ls_tab to lt_tab.
*
CALL TRANSFORMATION ZDUMMY
SOURCE NEWDATASET = lt_tab
RESULT XML xml_xstring
OPTIONS xml_header = 'NO'.
data : l_tab type tsfixml.
data lv_file_length type i.
call function 'SCMS_XSTRING_TO_BINARY'
exporting
buffer = xml_xstring
importing
output_length = lv_file_length
tables
binary_tab = l_tab.
* CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
* EXPORTING
* input_length = lv_file_length
*
* IMPORTING
* BUFFER = xml_xstring
* tables
* binary_tab = l_tab
* .
* IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
DATA: encode TYPE ABAP_ENCODING.
encode = '4103'. "'4103' - UTF-16 LE(Little Endian)
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'C:\Temp\xls.xml'
FILETYPE = 'ASC'
CODEPAGE = encode
tables
data_tab = l_tab
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'SCOL_TRACE_SHOW_XML'
EXPORTING
xdoc = xml_xstring.
**
*
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Thanks
Bala Duvvuri
Edited by: Bala Duvvuri on Jun 21, 2010 12:51 AM
Edited by: Bala Duvvuri on Jun 21, 2010 11:06 PM
‎2010 Jun 22 6:54 AM
Try downloading it in Binary format using 'BIN' in GUI_DOWNLOAD.
‎2010 Jun 22 8:14 AM
‎2010 Jun 22 8:44 AM
Could you please post your XML Transformation code as well.....Is it a Simple/XSLT Transformation?
‎2010 Jun 22 9:49 AM
Satyajit,
I followed this link and create simple transformation
http://sapblog.rmtiwari.com/2009/04/generate-simple-transformation-for-xml.html
Thanks
Bala Duvvuri
‎2010 Jun 19 7:28 AM
Hi,
Hope Use of SAP_CONVERT_TO_XML_FORMAT helps.
regd,
abhee
Edited by: abheesawant on Jun 19, 2010 8:29 AM