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: 

Transformation XML - problem with LOOP

0 Kudos

Hello Experts,

I have problem with transformation (STRANS), header is passing to the structure but the table by loop unfortunately not. When I CALL TRANSFORMATION the values from Confirmation (Name1, NrRef, Id, Sk, Na, Code) save to structure as RESULT of transformation but the position from Document unfortunately not.

My XML:

test-xmla-1.xml

My transformation:

<?sap.transform simple?><br><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">

<br><tt:root name="Confirmation" type="ddic:ZTEST_XML"/><br>
<tt:template><br>    
<Confirmation xmlns="http://........../v1"><br>
      <Name1 tt:value-ref=".Confirmation.Name1"/><br>
      <NrRef tt:value-ref=".Confirmation.NrRef"/><br>
      <Id tt:value-ref=".Confirmation.Id"/><br>
      <Sk tt:value-ref=".Confirmation.Sk"/><br>
      <Na tt:value-ref=".Confirmation.Na"/><br>
      <Code tt:value-ref=".Confirmation.Code"/><br>
      <Document><br>
        <tt:loop ref=".Confirmation.Document"><br>
            <NrDok tt:value-ref="NrDok"/><br>
            <NrInv tt:value-ref="NrInv"/><br>
            <DatSend tt:value-ref="DatSend"/><br>
            <DatReg tt:value-ref="DatReg"/><br>
            <SkDok tt:value-ref="SkDok"/><br>
        </tt:loop><br>
      </Document><br>
    </Confirmation><br>
  </tt:template><br>
</tt:transform>

Defined structures:

ZTEST_XML is structure like

Name1        Types String<br>
NrRef        Types String<br>
Id           Types String<br>
Sk           Types String<br>
Na           Types String<br>
Code         Types String<br>
Document     Types ZTEST_TT_DOCUMENT<br>

ZTEST_TT_DOCUMENT is Table Type with line type:

NrDok        Types String<br>
NrInv        Types String<br>
DatSend      Types String<br>
DatReg       Types String<br>
SkDok        Types String
1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

You did:

      <Document>
        <tt:loop ref=".Confirmation.Document">
            ...
        </tt:loop>
      </Document>
But it should be:
      <tt:loop ref=".Confirmation.Document">
        <Document>
            ...
        </Document>
</tt:loop>
3 REPLIES 3

Sandra_Rossi
Active Contributor
0 Kudos

So, your question is about the programming language Simple Transformation (a transformation can also be in language XSLT), and you want to deserialize XML into a complex structure where one component is an internal table.

You have lots of <br> tags in your pasted code. Maybe if you use Ctrl+Shift+V (instead of Ctrl+V), you'll avoid all these <br>.

Sandra_Rossi
Active Contributor
0 Kudos

You did:

      <Document>
        <tt:loop ref=".Confirmation.Document">
            ...
        </tt:loop>
      </Document>
But it should be:
      <tt:loop ref=".Confirmation.Document">
        <Document>
            ...
        </Document>
</tt:loop>

Thank you Sandra, it works 🙂