cancel
Showing results for 
Search instead for 
Did you mean: 

Outbound XML Transformation error in SAP

ananthula_sumanth
Participant

Hello, I am trying to generate XML. I wrote the following transformation but it is resulting error when referring the XML transformation.

'Error during access to the ref node 'ROOT'. The ref node is not defined or does not have the necessary type'

Transformation as below.

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT" />
<tt:template>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Part_by_Supplier.xsd">
<PartConversion>
<tt:loop name="line" ref=".ROOT">
<CompanyNumber>
<tt:value ref="$line.COMPANYNUMBER"/>
</CompanyNumber>
<Active>
<tt:value ref="$line.ACTIVE" />
</Active>
<CompanyPartNumber>
<tt:value ref="$line.COMPANYPARTNUMBER" />
</CompanyPartNumber>
<SupplierNumber>
<tt:value ref="$line.SUPPLIERNUMBER" />
</SupplierNumber>
<UnitMesaurePart>
<Name tt:value-ref="$line.UNITMESAUREPART.NAME"/>
<Isocode tt:value-ref="$line.UNITMESAUREPART.ISOCODE"/>
</UnitMesaurePart>
<UnitMeasureConversion>
<Name tt:value-ref="$line.UNITMEASURECONVERSION.NAME"/>
<Isocode tt:value-ref="$line.UNITMEASURECONVERSION.ISOCODE"/>
</UnitMeasureConversion>
<ConversionFactor tt:value-ref="$line.CONVERSIONFACTOR"/>
</tt:loop>
</PartConversion>
</Root>
</tt:template>
</tt:transform>

 Can someone please help. Thank you very much.
Sandra_Rossi
Active Contributor
0 Kudos
You forgot to post the relevant ABAP code! (call transformation and data type)

Accepted Solutions (1)

Accepted Solutions (1)

horst_keller
Product and Topic Expert
Product and Topic Expert

Well, for basic questions like this, I wrote a documentation and provide lots of examples in the documentation that don't have errors.

https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenabap_st.htm

Check those ...

ananthula_sumanth
Participant
0 Kudos

Very Helpful documentation

Answers (4)

Answers (4)

ananthula_sumanth
Participant
0 Kudos

There are 2 issues. In call transformation, ROOT_NAME is replaced with Transformation root name. It resolved the issue.

In sending issue, Webservice URL is incorrect. That's corrected in SOAManager and it worked. now. But only problem was we had BOM indicator in XML file and with UTF-16 encoding. That anyway is okay for us. BOM indicator is resolved with disabling <?xml...> completely. Thank you all for your help.

ananthula_sumanth
Participant
0 Kudos

CALL TRANSFORMATION ... SOURCE ROOT = structured_variable

For my transformations, in CALL TRANSFORMATION xxxxx SOURCE (root name) = data_table RESULT XML xstring.

I just changed the root name same as my root name in transformation and xstring with type string. It started working.

If someone tells me the differences for this, it will be helpful.

Sandra_Rossi
Active Contributor
0 Kudos

Obviously, your root names must match. I guess you don't need an explanation for that.

We can't answer for the type string versus xstring, because you didn't post your ABAP code. The only difference within CALL TRANSFORMATION is that an XSTRING means UTF-8 encoding, while a STRING is not converted (by definition, a STRING has the same encoding as the one of your system, some UTF-16/UCS-2, with variation on the endianness).

Sandra_Rossi
Active Contributor
0 Kudos

I see in your comment that you refer to ZML_S_PARTCONVERSION1, does the S mean that it's a structure, and that you use CALL TRANSFORMATION ... SOURCE ROOT = structured_variable... If that's right, then it means that you should replace structured_variable with an internal table (because you use tt:loop in your transformation). If your variable is a table ITAB with the obsolete header line, then remember to write ITAB[] (with square brackets) to refer to the body of the table, not the header line.

ananthula_sumanth
Participant
0 Kudos
Very Helpful
ananthula_sumanth
Participant
0 Kudos

There are 2 issues. In call transformation, ROOT_NAME is replaced with Transformation root name. It resolved the issue.

In sending issue, Webservice URL is incorrect. That's corrected in SOAManager and it worked. now. But only problem was we had BOM indicator in XML file and with UTF-16 encoding. That anyway is okay for us. BOM indicator is resolved with disabling <?xml...> completely. Thank you all for your help.

Sandra_Rossi
Active Contributor
0 Kudos

As explained in the ABAP documentation, the BOM is generated when you store the transformation result into a STRING variable. If you store it into an XSTRING variable, there's no BOM and the encoding is UTF-8.

PS: in the forum, you have the action "delete" to delete your extra replies.

rohitkumar_tiwari2
Discoverer
0 Kudos

Hello,

I believe the syntax is not correct. It should be like below:

<tt:root name="ROOT" type="?"/>

<tt:root name="DOCUMENTS" type="ddic:ZADV_CORRESPONDENCE"/>

Please change and let us know if it's helpful.

Regards,

Rohit Tiwari

ananthula_sumanth
Participant
0 Kudos

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT" type="?"/>
<tt:root name="PARTCONVERSIN" type="ddic:ZML_S_PARTCONVERSION1"/>

It now says, 'undeclared namespace prefix 'ddic'
horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Of course, see my answer to learn why.

(and also learn the basics of XML, especially about the usage of namespaces)

https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenxml_oview.htm