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

XML to ABAP using XSLT

konstantinos_vassiliadis
Active Participant
0 Likes
1,675

Hello experts,

I am desperate trying to find out how to transform an inbound XML to an ABAP data structure.

First of all, the incoming XML will have the following structure (I give a sample):

<REPLY>

     <MESSAGEID>FE2204B6-D898-41A6-B888-AB2B5455011D</MESSAGEID>

     <TIMESTAMP>20150423083544</TIMESTAMP>

        <PAYLOAD>

              <ZPOS_RECORD_REPLY>

               <RECID>F903F668-210F-4E80-B9E8-6486C9963E34</RECID>

               <CODE>0</CODE>

               <TEXT>SUCCESS</TEXT>

          </ZPOS_RECORD_REPLY>

      </PAYLOAD>

</REPLY>


And I have declared the following SAP data structures:


structure ZPOS_REPLY with the following components:

  • MESSAGEID
  • TIMESTAMP
  • PAYLOAD type ZPOS_REP_RECORDS

   type ZPOS_REP_RECORDS is a table type with line type ZPOS_RECORD_REPLY which is a structure with the following components:

  • RECID
  • CODE
  • TEXT

Now through xslt_tool I create a simple transformation (see attachment XSLT.PNG) with the following features:

- Root node name is REPLY of type ZPOS_REPLY

In ABAP program I have the following statement:

CALL TRANSFORMATION ZPOS_REPLY_6

       source XML fp_xml_rep_string

       RESULT ZPOS_REPLY = ltrans_reply.


where fp_xml_rep_string is xstring and attachment sample_reply_test.xml shows the string representation of incoming XML.


I get exception with message "Error accessing the ref. node 'MESSAGEID'".


What is the problem? I am new to XSLT and I wonder if I am missing something.


Thank you in advance,

Konstantinos

1 ACCEPTED SOLUTION
Read only

konstantinos_vassiliadis
Active Participant
0 Likes
1,484

Hello again,

I managed to resolve the issue and would like to share the solution with the rest of the community.

XSLT is in attachment xslt.png and in the ABAP program I have the following

CALL TRANSFORMATION ZPOS_REPLY_6

       source XML fp_xml_rep_string

        RESULT REPLY = ltrans_reply.


where after RESULT I specify REPLY which is the root of the inbound XML and ltrans_reply is a structure (deep) of type ZPOS_REPLY.


Now the deep structure is filled correctly with the data of the inbound XML.


Konstantinos

Hello experts,

I am desperate trying to find out how to transform an inbound XML to an ABAP data structure.

First of all, the incoming XML will have the following structure (I give a sample):

<REPLY>

     <MESSAGEID>FE2204B6-D898-41A6-B888-AB2B5455011D</MESSAGEID>

     <TIMESTAMP>20150423083544</TIMESTAMP>

        <PAYLOAD>

              <ZPOS_RECORD_REPLY>

               <RECID>F903F668-210F-4E80-B9E8-6486C9963E34</RECID>

               <CODE>0</CODE>

               <TEXT>SUCCESS</TEXT>

          </ZPOS_RECORD_REPLY>

      </PAYLOAD>

</REPLY>


And I have declared the following SAP data structures:


structure ZPOS_REPLY with the following components:

  • MESSAGEID
  • TIMESTAMP
  • PAYLOAD type ZPOS_REP_RECORDS

   type ZPOS_REP_RECORDS is a table type with line type ZPOS_RECORD_REPLY which is a structure with the following components:

  • RECID
  • CODE
  • TEXT

Now through xslt_tool I create a simple transformation (see attachment XSLT.PNG) with the following features:

- Root node name is REPLY of type ZPOS_REPLY

In ABAP program I have the following statement:

CALL TRANSFORMATION ZPOS_REPLY_6

       source XML fp_xml_rep_string

       RESULT ZPOS_REPLY = ltrans_reply.


where fp_xml_rep_string is xstring and attachment sample_reply_test.xml shows the string representation of incoming XML.


I get exception with message "Error accessing the ref. node 'MESSAGEID'".


What is the problem? I am new to XSLT and I wonder if I am missing something.


Thank you in advance,

Konstantinos

4 REPLIES 4
Read only

konstantinos_vassiliadis
Active Participant
0 Likes
1,485

Hello again,

I managed to resolve the issue and would like to share the solution with the rest of the community.

XSLT is in attachment xslt.png and in the ABAP program I have the following

CALL TRANSFORMATION ZPOS_REPLY_6

       source XML fp_xml_rep_string

        RESULT REPLY = ltrans_reply.


where after RESULT I specify REPLY which is the root of the inbound XML and ltrans_reply is a structure (deep) of type ZPOS_REPLY.


Now the deep structure is filled correctly with the data of the inbound XML.


Konstantinos

Read only

0 Likes
1,484

Hi Konstantinos,

Is this nice Visual tool to create transformation a part of  SE80 transformation editor?

Or is it a tool of different product?

Thank you,

Ihar

Read only

0 Likes
1,484

Hello Ihar,

you can access it via transaction XSLT_TOOL.

Read only

0 Likes
1,484

Thank you. I found this "Magic wand" icon