Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to redefine XML Transformation method

0 Kudos

I wanna to generate XML from an iternal table using XML transformation method, but i want to Personalize some balise for example !!this is what i have like result of XML transformation:

=> Structure:

types: BEGIN OF t_vbpa,
  parvw TYPE vbpa-parvw,
  kunnr TYPE vbpa-kunnr,
  END OF t_vbpa.
data: ty_vbpa TYPE TABLE OF t_vbpa,
      ds_vbpa like LINE OF ty_vbpa.

types: BEGIN OF t_vbap,
  posnr TYPE vbap-posar,
  matnr TYPE vbap-matnr,
  pmatn TYPE vbap-pmatn,
  vbpas TYPE t_vbpa OCCURS 0,
  END OF t_vbap.
  data: ty_vbap TYPE TABLE OF t_vbap,
      ds_vbap like LINE OF ty_vbap.

types: BEGIN OF t_vbak,
  vbeln TYPE vbak-vbeln,
  erdat TYPE vbak-erdat,
  ernam TYPE vbak-ernam,
  vbaps TYPE t_vbap OCCURS 0,
  END OF t_vbak.
data: ty_vbak TYPE TABLE OF t_vbak,
      ds_vbak like LINE OF ty_vbak.

***XML
  CALL TRANSFORMATION ('ID')
     SOURCE tab = ty_vbak[]
     RESULT XML xml_out.

=> XmL Result :

<?xml version="1.0" encoding="utf-16"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values><TAB>
<Line>
<VBELN>13</VBELN>
<ERDAT>09.04.2009</ERDAT>
<ERNAM>SNG10043</ERNAM>
<VBAPS>
	<item>
		<POSNR>10</POSNR>
		<MATNR>C20050</MATNR>
		<PMATN/>
		<VBPAS>
			<item>
				<PARVW>AG</PARVW>
				<KUNNR>BF0000</KUNNR>
			</item>
		</VBPAS>
	</item>
</VBAPS>
</Line>
</TAB>
</asx:values>
</asx:abap>

this is what i want in result:

<?xml version="1.0" encoding="utf-16"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VBELN>13</VBELN>
<ERDAT>09.04.2009</ERDAT>
<ERNAM>SNG10043</ERNAM>
<VBAPS>
	<item_VBAP>
		<POSNR>10</POSNR>
		<MATNR>C20050</MATNR>
		<PMATN/>
		<VBPAS>
			<item_VBPA>
				<PARVW>AG</PARVW>
				<KUNNR>BF0000</KUNNR>
			</item_VBPA>
		</VBPAS>
	</item_VBAP>
</VBAPS>
</asx:values>
</asx:abap> 

Any ideas how to do that ??

1 ACCEPTED SOLUTION

UweFetzer_se38
Active Contributor

You can change the standard output with Transaction XSLT_TOOL. Instead of calling the standard transformation "ID" now you can use your own transformtion.

2 REPLIES 2

Sandra_Rossi
Active Contributor
0 Kudos

ID is a predefined transformation with simple logic (serialization generates <item> for every line of an internal table). If you want something else, create your own Z transformation.

But the question is why do you need to do that? As it seems you want to keep the <asx:...> elements, it'd mean that you want to be able to deserialize using the ID transformation. So, I don't see the interest.

UweFetzer_se38
Active Contributor

You can change the standard output with Transaction XSLT_TOOL. Instead of calling the standard transformation "ID" now you can use your own transformtion.