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: 

Getting syntax error while converting internal table data to XML

0 Kudos

REPORT  ZCREATEXML_FROMITAB.

    DATA: BEGIN OF carrier_wa,
            carrid   TYPE sflight-carrid,
            carrname TYPE sflight-connid,
            planetype      TYPE sflight-PLANETYPE,
          END OF carrier_wa,
          carrier_tab LIKE TABLE OF carrier_wa,
          xml_xstring TYPE xstring,
          g_xml_outputs TYPE string.
DATA: wa_erfiling TYPE string,
        lt_erfiling LIKE STANDARD TABLE OF wa_erfiling.
PARAMETERS: p_file TYPE string MODIF ID xml.

SELECT FROM sflight

   INTO CORRESPONDING FIELDS OF TABLE carrier_tab.

CALL TRANSFORMATION Zdemo_st_table OPTIONS XML_HEADER = 'NO'
                        SOURCE CARRIERS = carrier_tab
                        RESULT XML xml_xstring.

          CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
              EXPORTING
                in_xstring = xml_xstring
              IMPORTING
                out_string = g_xml_outputs.
wa_erfiling = g_xml_outputs.

APPEND wa_erfiling to lt_erfiling.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
     filename                        = p_file
     filetype                        = 'ASC'
    TABLES
      data_tab                        = lt_erfiling
          .

  IF sy-subrc <> 0.
    MESSAGE 'XML Generation Failed' TYPE 'E'.
  ELSE.
    MESSAGE 'XML Generation Successful' TYPE 'S'.
  ENDIF.

And my Transformation is

<?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="CARRIERS" type="ddic:SFLIGHT"/>

  <tt:template>

    <DUTY-PAYABLE-FOR-CLEARANCE>

      <test2 tt:value-ref=".CARRIERS.CARRID"/>

      <test tt:value-ref=".CARRIERS.CONNID"/>

      <test1 tt:value-ref=".CARRIERS.PLANETYPE"/>

    </DUTY-PAYABLE-FOR-CLEARANCE>

  </tt:template>

</tt:transform>

Please let me know the reason for the error.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

@ Sreenath : As far as i could see, you have declared it in a different name  

carrname TYPE sflight-connid 

but it is  <test tt:value-ref=".CARRIERS.CONNID"/> so just try changing carrname to

carriers.connid.

PS : I'm not sure whether what i mentioned above is correct or not.

3 REPLIES 3

Former Member
0 Kudos

@ Sreenath : As far as i could see, you have declared it in a different name  

carrname TYPE sflight-connid 

but it is  <test tt:value-ref=".CARRIERS.CONNID"/> so just try changing carrname to

carriers.connid.

PS : I'm not sure whether what i mentioned above is correct or not.

0 Kudos

Hi Krishna kumar ,

I have made the chsnges as you said but still i am getting the same error message.    

regards

0 Kudos

Hi,

I could able to resolve this by trial and error. The issue is the input parameter for the transformation ( ie SOURCE ) should be of the same type of the DDIC that you have mentioned in the transformation root.

regards,