Skip to Content
0

How to redefine XML Transformation method

May 22, 2017 at 09:59 AM

89

avatar image

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 ??

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Uwe Fetzer May 22, 2017 at 11:59 AM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Sandra Rossi May 22, 2017 at 10:57 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded