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 transfornation help dump help

Former Member
0 Likes
1,994

HI ,

I have this string type xml and it coming from internal table and i want to parse it to abap internal table, i follow some example that in the forum and i facing an dump ,do some one can help.

Regards

DATA: BEGIN OF wa,

key TYPE string,

val TYPE string,

END OF wa.

DATA it_data LIKE TABLE OF wa.

START-OF-SELECTION.

DATA:  xml_string TYPE string
      VALUE '<determination><deter key = "00009" value = "Johan"/><deter key = "1000" value = "GSS"/></determination>'.



  CALL TRANSFORMATION z_xml_to_itab
       SOURCE  XML xml_string
       RESULT  itab = it_data.

This is what i write on TR. strans

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ITAB"/>
  <tt:template>
    <determination>
      <tt:loop name="a" ref=".ITAB">
        <deter>
          <tt:attribute name="key" ref="$a.akey" name="val" ref="$a.aval" />
        </deter>
      </tt:loop>
    </determination>
  </tt:template>
</tt:transform>

When i check on the debugger the error is in line :

<tt:attribute name="key" ref="$a.akey" name="val" ref="$a.aval" />

the dump is :

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_ST_MATCH_ATTRIBUTE', was not

caught and

therefore caused a runtime error.

The reason for the exception is:

XML matching error

Expected was attribute: "val" [ ] Read was element-start: "deter" [ ].

What i miss here ?????,please help.

Regards

Joy

Edited by: Joy Stpr on Aug 3, 2009 9:54 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,676

Hello,

Instead of giving transformation template z_xml_to_itab simply use identical transformation as follows:

CALL TRANSFORMATION ID

SOURCE XML xml_string

RESULT itab = it_data.

This will transform the xml_string directly in to ABAP data.

Hope this helps you.

Thanks,

Augustin.

13 REPLIES 13
Read only

sivasatyaprasad_yerra
Product and Topic Expert
Product and Topic Expert
0 Likes
1,676

Transformation declared as ; <tt:attribute name="key" ref="$a.akey" name="val" ref="$a.aval" />

but the value provided is value="Johan". This should val="Johan". The same thing needs to be done for other vkey value also.

Read only

0 Likes
1,676

hi Siva,

Thanks ,

Since i new to this topic in abap ,

can u please elaborate on this ?

Regards

Joy

Read only

Former Member
0 Likes
1,677

Hello,

Instead of giving transformation template z_xml_to_itab simply use identical transformation as follows:

CALL TRANSFORMATION ID

SOURCE XML xml_string

RESULT itab = it_data.

This will transform the xml_string directly in to ABAP data.

Hope this helps you.

Thanks,

Augustin.

Read only

0 Likes
1,676

HI Augustarian ,

I try like u tell and i get this error :

38 *ZTEST_XML_002
>>>>>   CALL TRANSFORMATION id
   40        SOURCE  XML xml_string
   41        RESULT  itab = it_data.
   42

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_XSLT_FORMAT_ERROR', was not

caught and

therefore caused a runtime error.

The reason for the exception is:

The XML format was recognized as invalid for one of the following

reasons:

1. The basic structure of the document was incorrect - for example, the

root tag <abap> must be in the XML namespace

"http://www.sap.com/abapxml".

2. Start tags appear where no more are expected - for example, when an

integer value is to be read.

3. You have to specify the correct version number to read certain data

types.

4. Too few or too many properties exist.

Can u help ?

Regards

Joy

Read only

0 Likes
1,676

Try this link:

[http://help.sap.com/saphelp_nwpi71/helpdata/EN/e3/7d4719ca581441b6841f1054ff1326/content.htm]

This may be helpful in understanding Simple transformations

Read only

0 Likes
1,676
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ITAB"/>
  <tt:template>
    <determination>
      <tt:loop name="a" ref=".ITAB">
        <deter>
          <tt:attribute name="key" ref="$a.akey" name="val" ref="$a.aval" />
        </deter>
      </tt:loop>
    </determination>
  </tt:template>
</tt:transform>

By taking the transformation you have used..

<deter> tag should contain two attributes key and val. But the actual XML contains key and value as attributes. Which is wrong.

Check the link provided above to get more inside details of simple transformations.

Read only

0 Likes
1,676

Hi Siva,

What i do is exactly what is write on the sap help ( iread this post before i start to develop )and i think that i miss somthing ,

since i don't found what i doing wrong on my code ,

please see if u can help .

Regards

Joy

Read only

0 Likes
1,676

Sorry. I didn't understand the problem. Could you explain in detail.

I've checked the first memo and i think whatever you are doing looks correct to me. If you have any other problems, explain it in details. So, that i may help you.

Read only

0 Likes
1,676

Hello,

CALL TRANSAFORMATION expects data into XSLT format while using identical transformation.

The input XML should be formatted as follows:

<?xml version="1.0" encoding="iso-8859-1"?><asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values>.......your data fields.....</asx:values></asx:abap>

For e.g.

<?xml version="1.0" encoding="iso-8859-1"?><asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><NAME>snd</NAME></asx:values></asx:abap>

Check if you can convert your existing xml into above one with some simple string manipulation.

Thanks,

Augustin.

Read only

0 Likes
1,676

Hi ,

The problem is that i get the value XML string in the program and i need to put the value of it

on the internal table (this is happen during runtime i.e. the string value change i just copy the string structure that ramain the same but the value like the name is changing) .

when i write the code of the transformation i get dump (see my previous post )

how can i throw the data to abap internal table .

THE VALUE THAT I WANT TO MOVE TO ABAP TABLE IS SIMPLE ,

BUT I MISS SOMETHING PLEASE PROVIDE HELP.

Thanks and best regards

Joy

Edited by: Joy Stpr on Aug 3, 2009 9:15 PM

Read only

0 Likes
1,676

Change this transformation tag:

<tt:attribute name="key" ref="$a.akey" name="val" ref="$a.aval" />

to

<tt:attribute name="key" ref="$a.key" name="val" ref="$a.val" />

.

Regards,

Siva.

Read only

0 Likes
1,676

HI Siva,

Thanks a lot,

i change it like u tell and i facing other dump,

do u have an idea.

this is exactly the code that i write :

DATA: BEGIN OF wa,
         key TYPE string,
         value TYPE string,
       END OF wa.

DATA it_data LIKE TABLE OF wa.


START-OF-SELECTION.


  DATA:  xml_string TYPE string
        VALUE '<determination><deter key = "00009" value = "Johan"/><deter key = "1000" value = "GSS"/></determination>'.




  CALL TRANSFORMATION ztest_xml_009
       SOURCE  XML xml_string
       RESULT  itab = it_data.

This is what i write in strans

<?sap.transform simple?>

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">

<tt:root name="ITAB"/>

<tt:template>

<determination>

<tt:loop name="a" ref=".ITAB">

<deter>

<tt:attribute name="key" ref="$a.key" name="value" ref="$a.value" />

</deter>

</tt:loop>

</determination>

</tt:template>

</tt:transform>

And this is the dump

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_ST_MATCH_ATTRIBUTE', was not

caught and

therefore caused a runtime error.

The reason for the exception is:

XML matching error

Expected was attribute-end: "determination" [ ] Read was text: "Johan" [ ].

Can i help please :

U can just copy and paste the code and u get the same dump that i am facing

Thanks and best Regards

jOy

Edited by: Joy Stpr on Aug 4, 2009 8:57 AM

Read only

0 Likes
1,676

Use the following transformation::

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ITAB"/>
<tt:template>
<determination>
<tt:loop name="a" ref=".ITAB">
<deter>
<tt:attribute name="key" value-ref="$a.key" name="value" value-ref="$a.value" />
</deter>
</tt:loop>
</determination>
</tt:template>
</tt:transform>

Only difference is value-ref attribute is used instead of ref attribute for <tt:attribute> tag.

Regards,

Siva.