02-09-2006 2:24 AM
Hi All,
Is there a Function Module or anyother method available to convert data in an internal table to an XML format.
Thanks in advance for your help and suggestions.
02-09-2006 2:29 AM
Hi,
I found this on aUser forum sometime back... pl go through it..
*&---------------------------------------------------------------------*
*& Report ZTESTXML *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Report ZPRUEBA_MML_13 *
* Export an internal table to XML document *
* NO BORRAR ESTE CODIGO *
*----------------------------------------------------------------------*
report zprueba_mml_13.
*----------------------------------------------------------------------*
* PANTALLA SELECCION *
parameters: gk_ruta type rlgrap-filename.
* PANTALLA SELECCION *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* TYPE TURNOS *
types: begin of turnos,
lu like t552a-tpr01,
ma like t552a-tpr01,
mi like t552a-tpr01,
ju like t552a-tpr01,
vi like t552a-tpr01,
sa like t552a-tpr01,
do like t552a-tpr01,
end of turnos.
* TYPE TURNOS *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* TYPE SOCIO *
types: begin of socio,
numero like pernr-pernr,
reposicion like pa0050-zauve,
nombre like pa0002-vorna,
turnos type turnos,
end of socio.
* TYPE SOCIO *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* ESTRUCTURA ACCESOS *
data: begin of accesos occurs 0,
socio type socio,
end of accesos.
* ESTRUCTURA ACCESOS *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* START OF SELECTION *
start-of-selection.
perform llena_accesos.
perform descarga_xml.
end-of-selection.
* END OF SELECTION *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* FORM LLENA_ACCESOS *
form llena_accesos.
refresh accesos.
clear accesos.
move: '45050' to accesos-socio-numero,
'MOISES MORENO' to accesos-socio-nombre,
'0' to accesos-socio-reposicion,
'T1' to accesos-socio-turnos-lu,
'T2' to accesos-socio-turnos-ma,
'T3' to accesos-socio-turnos-mi,
'T4' to accesos-socio-turnos-ju,
'T5' to accesos-socio-turnos-vi,
'T6' to accesos-socio-turnos-sa,
'T7' to accesos-socio-turnos-do.
append accesos.
clear accesos.
move: '45051' to accesos-socio-numero,
'RUTH PEÑA' to accesos-socio-nombre,
'0' to accesos-socio-reposicion,
'T1' to accesos-socio-turnos-lu,
'T2' to accesos-socio-turnos-ma,
'T3' to accesos-socio-turnos-mi,
'T4' to accesos-socio-turnos-ju,
'T5' to accesos-socio-turnos-vi,
'T6' to accesos-socio-turnos-sa,
'T7' to accesos-socio-turnos-do.
append accesos.
endform. "LLENA_ACCESOS
* FORM LLENA_ACCESOS *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* FORM DESCARGA_XML *
form descarga_xml.
data: l_dom type ref to if_ixml_element,
m_document type ref to if_ixml_document,
g_ixml type ref to if_ixml,
w_string type xstring,
w_size type i,
w_result type i,
w_line type string,
it_xml type dcxmllines,
s_xml like line of it_xml,
w_rc like sy-subrc.
data: xml type dcxmllines.
data: rc type sy-subrc,
begin of xml_tab occurs 0,
d like line of xml,
end of xml_tab.
class cl_ixml definition load.
g_ixml = cl_ixml=>create( ).
check not g_ixml is initial.
m_document = g_ixml->create_document( ).
check not m_document is initial.
write: / 'Converting DATA TO DOM 1:'.
call function 'SDIXML_DATA_TO_DOM'
exporting
name = 'ACCESOS'
dataobject = accesos[]
importing
data_as_dom = l_dom
changing
document = m_document
exceptions
illegal_name = 1
others = 2.
if sy-subrc = 0.
write 'Ok'.
else.
write: 'Err =',
sy-subrc.
endif.
check not l_dom is initial.
w_rc = m_document->append_child( new_child = l_dom ).
if w_rc is initial.
write 'Ok'.
else.
write: 'Err =',
w_rc.
endif.
call function 'SDIXML_DOM_TO_XML'
exporting
document = m_document
importing
xml_as_string = w_string
size = w_size
tables
xml_as_table = it_xml
exceptions
no_document = 1
others = 2.
if sy-subrc = 0.
write 'Ok'.
else.
write: 'Err =',
sy-subrc.
endif.
loop at it_xml into xml_tab-d.
append xml_tab.
endloop.
call function 'WS_DOWNLOAD'
exporting
bin_filesize = w_size
filename = gk_ruta
filetype = 'BIN'
tables
data_tab = xml_tab
exceptions
others = 10.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. "DESCARGA_XML
* FORM DESCARGA_XML *
*----------------------------------------------------------------------*
Regards,
Suresh Datti
02-09-2006 3:19 AM
02-09-2006 3:28 AM
Hi Aurang
Check This one...It might solve your problem....
SAP_CONVERT_TO_XML_FORMAT
Cheers:)
Mithlesh
02-09-2006 3:31 AM
Hi Aurang,
I found this link very helpful with converting XML into Internal Table and vice versa...
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap-co... code sample using rfc_read_table for webas.pdf
Hope this helps.
Cheers,
Pat.
02-09-2006 3:37 AM
You can also check out this interface
if_ixml_stream_factory
· create_istream_itable
This will solve your purpose...· create_istream_string
· create_istream_uri
· create_istream_xstring
· create_ostream_cstring
· create_ostream_itable
· create_ostream_uri
· create_ostream_xstring
· query_interface
http://help.sap.com/saphelp_erp2005/helpdata/en/bb/5766c1dca511d4990b00508b6b8b11/frameset.htm
Cheers:)
Mithlesh
02-09-2006 4:47 AM
02-09-2006 4:56 AM
check this:
/people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
regards
08-08-2006 11:31 PM
Hi ,
I need to know how to create specific XML schema output. i tried with FM available and classes available but i need the output in the following format.
<?xml version="1.0" encoding="UTF-8" ?>
- <ps:ProcessSet xmlns:ps="http://schemas.ariba.com/IS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xtc="http://schemas/ariba/xt/core" xmlns:xtd="http://schemas/ariba/xt/datatypes" xmlns:dts="http://schemas/ariba/xt/database" msgid="yw890-hplw47j-904gk4n-s3n4mzq2">
- <ProcessSetProperties null_representation="indirect" process_scope="Entity">
<DateTimeFormats dateTimeFormat="YYYY-MM-DD HH24:MI:SS" />
<Source>SG</Source>
<Message_Version>1.0.0</Message_Version>
I need ABAP code for the above format.
Thanks in Advance
Anney
11-05-2013 11:56 AM