0

I am getting XML from from internal tables using Simple Transformation. This is the output XML.

<?xml version="1.0" encoding="UTF-8"?>
<Complement>
 <Document Doc="AAA">

    <Locations>             
        <Location>
            <Origin 
                RFC="URE180429TM6"/>            
            <Address 
                Country="SOME_COUNTRY" 
                />
                [....]
        </Location>
    </Locations>
    
    <Products NumTotal="1">
        <Product
            ValorProduct="12164501"
            />
            [....]
       </Product>
    </Products>

    [....]....

 </Document>
</Complement>

But now what I NEED to do is to Change some XML ELEMENT Name (rename them).. which should make my XML looks like this:

For example I need the first Element (Complement) wil looks like cfdi:Complement (using the Colon : between cfdi and Complement)... etc etc

<cfdi:Complement>
  <document:Document Doc="AAA">

    <document:Locations>                
        <document:Location>
            <document:Origin 
                RFC="URE180429TM6"/>            
            <document:Domicilio 
                Country="NIGERIA" 
                />
                [....]
        </document:Location>
    </document:Locations>
    
    <document:Products NumTotal="1">
        <document:Product
            ValorProduct="12164501"
            />
            [....]
       </document:Product>
    </document:Products>

    [....]....

  </document:Document>
</cfdi:Complement>

I have been trying to change the Element Names directly from Simple Transformation Code but it´s not working:

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" 
xmlns:ddic="http://www.sap.com/abapxml/types/dictionary"
xmlns:def="http://www.sap.com/abapxml/types/defined">
<tt:root name="COMPLEMENT" type="ddic:ZCOMPLEMENT"/>
<tt:template>
<tt:namespace name="cfdi"/>
<tt:namespace name="document"/>

  <cfdi:Complement>    "<----- I get error from this lines
    <document:Document>   "<----- I get error from this lines
      <tt:attribute name="Doc" value-ref=".COMPLEMENT.DOCUMENT.DOC"/>

      <document:Locations>       
        <Location>            
          <Origin>        
            <tt:attribute name="RFC" value-ref=".COMPLEMENT.DOCUMENT.LOCATIONS.LOCATION.ORIGIN.RFC"/>
              [....]
          </Origin>              
          <Address>
            <tt:attribute name="Country" value-ref=".COMPLEMENT.DOCUMENT.LOCATIONS.LOCATION.ADDRESS.COUNTRY"/>
              [....]
          </Address>                            
        </Location>
      </Locations>

      <Products>         
        <tt:attribute name="NumTotal" value-ref=".COMPLEMENT.DOCUMENT.PRODUCTS.NUMTOTAL"/>            
          <Product>
            <tt:attribute name="ValorProduct" value-ref="VALORPRODUCT"/>
              [....]
          </Product>
      </Products>
      
        [....]....
      
    </Document>
  </Complement>

</tt:template>
</tt:transform>

these are the errors i get:

undeclared namespace prefix 'cfdi'

and

undeclared namespace prefix 'document'

This is the Simple Transformation Code:

I just need to change the name of Element. But I didn´t think it is harder than it seems.

Kindly help me on this. I´m new in this Abap World. or any idea will help me so so much. Regards

  • Please provide code in a minimal version, we don't need all the stuff. Please show the version of the code which produces the error message. You have to provide a [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – Sandra Rossi Sep 15 '21 at 05:28
  • Does this answer your question? [Use multiple namespaces in single XML element through ABAP Simple Transformation](https://stackoverflow.com/questions/43585383/use-multiple-namespaces-in-single-xml-element-through-abap-simple-transformation) – Sandra Rossi Sep 15 '21 at 05:28
  • I have updated my Simple Transformation code and I pointed out where the errors come from.. and I saw you suggested link but it isn´t too clear to me. I´m still trying to get the name changed:( – Antonio Lopez Sep 15 '21 at 14:52
  • The other answer is showing `xmlns:etd` defined at a top position. For instance, you could define `xmlns:cfdi="dummy" xmlns:document="dummy"` in ` – Sandra Rossi Sep 15 '21 at 16:53
  • Thanks for answering... In this case I have not URI, or maybe I dont know why should I specify it... Is it necesary just for changing the Element Name? or what is it for?. – Antonio Lopez Sep 15 '21 at 17:20
  • You must have a URI by definition, or "cfdi" and "document" make no sense. XML namespaces are used to define XML Schemas. If you don't know immediately the right answer, you can use whatever you want. – Sandra Rossi Sep 15 '21 at 18:08
  • 1
    Finally, after testing and testing, It works. I had to define two URI one for `cfdi ` and other for `document` as you said. Thank you so so much! – Antonio Lopez Sep 15 '21 at 21:14

0 Answers0