I have a webservice call that returns XML. I need to transform a portion of the response to an internal table, but my simple transformation is not working with loop processing. I have read through most posts regarding the topic but they're either too old or related to serialization. There aren't any exceptions thrown, but I don't get any data in the internal table (PAPERWORK root). Below are some code snippets. Any ideas on the problem with the XSLT template? Thanks.
Sample XML:
<?xml version="1.0" encoding="utf-8" ?> <PrintVersionDataSet> <Result> <ReturnCode>W</ReturnCode> <ReturnMessage>There are reports with later version(s)</ReturnMessage> </Result> <Paperwork> <ReportCode>CVR</ReportCode> <ReportName>Cover Sheet</ReportName> <Version>2</Version> <PrintedDateTime>2009-05-01T09:54:04.1-05:00</PrintedDateTime> </Paperwork> <Paperwork> <ReportCode>SPS</ReportCode> <ReportName>Sponsor Summary</ReportName> <Version>2</Version> <PrintedDateTime>2009-05-01T09:54:04.99-05:00</PrintedDateTime> </Paperwork> </PrintVersionDataSet>
XSLT Code:
<?sap.transform simple?> <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"> <tt:root name="RESULT"/> <tt:root name="PAPERWORK"/> <tt:template> <PrintVersionDataSet> <Result tt:ref="RESULT"> <ReturnCode> <tt:value ref="RETURNCODE"/> </ReturnCode> <ReturnMessage> <tt:value ref="RETURNMESSAGE"/> </ReturnMessage> </Result> <tt:deserialize> <tt:loop ref=".PAPERWORK"> <Paperwork> <ReportCode> <tt:value ref="REPORTCODE"/> </ReportCode> <ReportName> <tt:value ref="REPORTNAME"/> </ReportName> <Version> <tt:value ref="VERSION"/> </Version> <PrintedDateTime> <tt:value ref="PRINTEDDATETIME"/> </PrintedDateTime> </Paperwork> </tt:loop> </tt:deserialize> </PrintVersionDataSet> </tt:template> </tt:transform>
ABAP Call to Transform Data:
TRY. CALL TRANSFORMATION Z_GA_PAPERWORK_VERS_WEBSVC SOURCE XML LS_RESPONSE-VERIFY_PRINT_VERSION_RESULT RESULT RESULT = LS_RESULT PAPERWORK = LT_PAPERWORK. CATCH CX_ROOT INTO ROOT_EXCEPTION. CALL METHOD ROOT_EXCEPTION->IF_MESSAGE~GET_TEXT RECEIVING RESULT = LV_MESSAGE. ENDTRY.