2013 Jul 23 6:10 AM
Hi,
I have to create an XSLT transformation, from ABAP code to XML file.
The XML to be created is as mentioned below:
but when i create i am unable to replicate this exactly. My XML:
XSLT:
Can anyone please tell me where i am going wrong. I am doing this for the first time and cant find much help.
Regards,
Shraddha
2013 Jul 23 8:04 AM
Hi Shraddha,
Check this link,you can change the tag <> names.
http://sapblog.rmtiwari.com/2009/04/generate-simple-transformation-for-xml.html
Hi,
I have to create an XSLT transformation, from ABAP code to XML file.
The XML to be created is as mentioned below:
but when i create i am unable to replicate this exactly. My XML:
XSLT:
Can anyone please tell me where i am going wrong. I am doing this for the first time and cant find much help.
Regards,
Shraddha
2013 Jul 23 8:04 AM
Hi Shraddha,
Check this link,you can change the tag <> names.
http://sapblog.rmtiwari.com/2009/04/generate-simple-transformation-for-xml.html
2013 Jul 23 8:17 AM
Hi,
Thanks a lot for your reply. Can you tell me how to i change the encoding to ISO-8859-1.
And also, Tag <Raaka-aine Nimi="" Ryhma=""> opens and closes only once, after Tag <TIEDOT>. How to achieve that?
Regards,
Shraddha
2013 Jul 23 11:35 AM
Shraddha:
Can you please rename the node 'ZZAIVO_XML' to 'Raaka-aine'?
Looking at your XML file it seems that tag <Raaka-aine Nimi="" Ryhma=""> should not represent an internal table...but a structure. In ur transformation it is represented as a structure via node 'ZZAIVO_XML'.
If you are planning to keep it as an internal table.....then make sure that there is only one entry.
2013 Jul 23 11:41 AM
Your node <Tuotemerkki> should represent an internal table....as it is repeating itself
And the node <Toimittajatiedot> should be inside the node <Tuotemerkki>
2013 Jul 23 11:44 AM
Refer the below document......though this is not directly related and talks about De-serialization....u should be able to find hints...
http://scn.sap.com/docs/DOC-43794
Also, if possible attach ur XML file so that we can try.
2013 Jul 31 11:50 AM
Hi,
Thanks a lot for your reply.
How do i rename a node? there is no option to do that.
Regards,
Shraddha
2013 Jul 23 11:58 AM
Hi,
As suggested you can edit the nodes in the XSLT_TOOL transaction and edit the nodes or structure of the transformation as for the encoding both UTF-8 and ISO 8859 1 are 8-bit encoding. But just curious if it has something to do with PI. In that case you can use XMLAnonymizer in the receiver communication channel. Check the wiki link below:
http://wiki.sdn.sap.com/wiki/display/XI/Changing+Namespaces+and+the+encoding+format+of+XML
Cheers,
Arindam
2013 Jul 23 12:09 PM
Hi Shraddha,
You can change the 'ZZAIVO_XML' as <Raaka-aine Nimi="" Ryhma="">,just by simple double clicking on 'ZZAIVO_XML'.
Double click on 'ZZAIVO_XML' and it will display the Node Type as ''ZZAIVO_XML'' next to Template,just replace this with <Raaka-aine Nimi="" Ryhma="">.
and regarding changing the Encoding ,in the same thread this is also addressed.
I am pasting that just for your reference.
REPORT z_test_ram_xml.
* complex structure example
DATA : lt_itab TYPE ldapaltab,
wa_itab LIKE LINE OF lt_itab ,
lt_val TYPE valtabc,
wa_val LIKE LINE OF lt_val .
DATA: gv_xml_xstring TYPE xstring.
DATA: gv_final_xml_xstring TYPE xstring.
* <<< Populate Example data in complex struture itab
wa_itab-name = 'header1'.
wa_itab-typ = 'header2'.
wa_itab-operation = 'header3'.
wa_val-val = 'Hi'.
APPEND wa_val TO wa_itab-vals.
wa_val-val = 'How r you'.
APPEND wa_val TO wa_itab-vals.
APPEND wa_itab TO lt_itab.
*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
* This is the main ST call.
CALL TRANSFORMATION z_test_ram
SOURCE ldap_table = lt_itab[]
RESULT XML gv_xml_xstring.
*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
* Now to get the encoding we'll use standard XSLT ID
* rather than ST - not required if you need Default UTF-8 from ST
DATA :go_ixml TYPE REF TO if_ixml,
go_stream_factory TYPE REF TO if_ixml_stream_factory,
go_encoding TYPE REF TO if_ixml_encoding,
go_resstream TYPE REF TO if_ixml_ostream.
CONSTANTS: gc_encoding TYPE string VALUE 'ISO-8859-1'. "or UTF-8 etc.
go_ixml = cl_ixml=>create( ).
go_stream_factory = go_ixml->create_stream_factory( ).
go_encoding = go_ixml->create_encoding( character_set = gc_encoding byte_order = 0 ).
go_resstream = go_stream_factory->create_ostream_XSTRING( gv_final_xml_xstring ).
CALL METHOD go_resstream->set_encoding( go_encoding ).
CALL TRANSFORMATION ID
SOURCE XML gv_xml_xstring
RESULT XML go_resstream.
cl_salv_data_services=>download_xml_to_file(
filename = 'C:\z_test_ram_xml_file.xml'
xcontent = gv_final_xml_xstring ).