Application Development and Automation 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: 
Read only

TRANSFORMATION ABAP : Error accessing the ref. node

2,800

Hi all,

With this Transformation :

 <?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="ROOT" type="?"/>
  <tt:root name="CRPROD_FILE" type="ddic:ZTT_XML_CROF"/>
  <tt:template>
    <tt:loop ref=".CRPROD_FILE">
      <CRPROD_FILE>
        <FNAME tt:value-ref="CROF_FIC.FNAME"/>
        <ZLOGID tt:value-ref="CROF_FIC.ZLOGID"/>
        <ZNBPROD tt:value-ref="CROF_FIC.ZNBPROD"/>
        <PROD_ORDER>
          <AUFNR tt:value-ref="CROF_HD.AUFNR"/>
          <GSTRP tt:value-ref="CROF_HD.GSTRP"/>
          <GLTRP tt:value-ref="CROF_HD.GLTRP"/>
          <GLTRI tt:value-ref="CROF_HD.GLTRI"/>
          <MATNR tt:value-ref="CROF_HD.MATNR"/>
          <MENGE tt:value-ref="CROF_HD.MENGE"/>
          <MENGE1 tt:value-ref="CROF_HD.MENGE1"/>
        </PROD_ORDER>
      </CRPROD_FILE>
    </tt:loop>
  </tt:template>
</tt:transform>
And this File in input :
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CRPROD_FILE>
<FNAME>FILE_TST.xml</FNAME>
<ZLOGID>TSTID</ZLOGID><ZNBPROD>1</ZNBPROD><PROD_ORDER><AUFNR>900001005861</AUFNR><GSTRP>20200713</GSTRP><GLTRP>2020717</GLTRP><GLTRI>2020714</GLTRI><MATNR>101061</MATNR><MENGE>10</MENGE><MENGE1>10</MENGE1></PROD_ORDER></CRPROD_FILE>

We got the "Error accessing the ref. node 'CRPROD_FILE'".
What is wrong ?

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,429

There are two possible solutions, depending on what you want to achieve:

  • Either you want the element <CRPROD_FILE> to occur several times in the XML file, in that case your XML structure is missing a root element (<CRPROD_FILES> or <DATA> for instance).
  • Or you want the element <CRPROD_FILE> to occur only once in the XML file, so you should put <CRPROD_FILE> outside the loop. And maybe you need to do other changes in your transformation.
4 REPLIES 4
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,430

There are two possible solutions, depending on what you want to achieve:

  • Either you want the element <CRPROD_FILE> to occur several times in the XML file, in that case your XML structure is missing a root element (<CRPROD_FILES> or <DATA> for instance).
  • Or you want the element <CRPROD_FILE> to occur only once in the XML file, so you should put <CRPROD_FILE> outside the loop. And maybe you need to do other changes in your transformation.
Read only

0 Likes
2,429

Hi Sandra,
Its the second time you help me, thanks for your reply !
I changed it with the second way ZST_XML_CROF structure (instead of ZTT_XML_CROF table)

<?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="ROOT" type="?"/>
  <tt:root name="CRPROD_FILE" type="ddic:ZST_XML_CROF"/>
  <tt:template>
    <CRPROD_FILE>
        <FNAME tt:value-ref="CRPROD_FILE.CROF_FIC.FNAME"/>
        <ZLOGID tt:value-ref="CRPROD_FILE.CROF_FIC.ZLOGID"/>
        <ZNBPROD tt:value-ref="CRPROD_FILE.CROF_FIC.ZNBPROD"/>
        <PROD_ORDER>
          <AUFNR tt:value-ref="CRPROD_FILE.CROF_HD.AUFNR"/>
          <GSTRP tt:value-ref="CRPROD_FILE.CROF_HD.GSTRP"/>
          <GLTRP tt:value-ref="CRPROD_FILE.CROF_HD.GLTRP"/>
          <GLTRI tt:value-ref="CRPROD_FILE.CROF_HD.GLTRI"/>
          <MATNR tt:value-ref="CRPROD_FILE.CROF_HD.MATNR"/>
          <MENGE tt:value-ref="CRPROD_FILE.CROF_HD.MENGE"/>
          <MENGE1 tt:value-ref="CRPROD_FILE.CROF_HD.MENGE1"/>
        </PROD_ORDER>
      </CRPROD_FILE>
  </tt:template>
</tt:transform>
and now i got the "Error accessing the ref. node 'CROF_FIC.FNAME'".

How to declare this Node ?

Read only

0 Likes
2,429

Please use the COMMENT button for comments, questions, adding details, replying to OP comment, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

Read only

2,429

I think the issue is more about the starting point of VALUE-REF. You should start from the root using a dot. And you could reduce the size of the names with tt:ref:

<?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="ROOT" type="?"/>
  <tt:root name="CRPROD_FILE" type="ddic:ZST_XML_CROF"/>
  <tt:template>
    <CRPROD_FILE tt:ref=".CRPROD_FILE">                <!-- =============== here -->
        <FNAME tt:value-ref="CROF_FIC.FNAME"/>
        <ZLOGID tt:value-ref="CROF_FIC.ZLOGID"/>
        <ZNBPROD tt:value-ref="CROF_FIC.ZNBPROD"/>
        <PROD_ORDER tt:ref="CROF_HD">                  <!-- =============== and here -->
          <AUFNR tt:value-ref="AUFNR"/>
          <GSTRP tt:value-ref="GSTRP"/>
          <GLTRP tt:value-ref="GLTRP"/>
          <GLTRI tt:value-ref="GLTRI"/>
          <MATNR tt:value-ref="MATNR"/>
          <MENGE tt:value-ref="MENGE"/>
          <MENGE1 tt:value-ref="MENGE1"/>
        </PROD_ORDER>
      </CRPROD_FILE>
  </tt:template>
</tt:transform>