‎2009 Mar 03 2:21 PM
Hello,
I have following transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<Payload tt:ref="ROOT">
<Language>
<tt:value ref="LANGUAGE"/>
</Language>
<Location>
<tt:value ref="LOCATION_COUNTRY"/>
</Location>
</Payload>
</tt:template>
</tt:transform>
I call the transformation with
CALL TRANSFORMATION zconvert_st
SOURCE root = struc1
RESULT XML xml_string.
struc1 is an internal table. but how have to I write the transformation when the internal table has more than 1 line? The transformation run only when I have 1 line, but I want to listed all lines in the xml
‎2009 Mar 03 3:30 PM
now I have this definition and see it works
TYPES: BEGIN OF ty_struc1,
name(29) TYPE c,
location_country(10) TYPE c,
stras(29) TYPE c,
code(29) TYPE c,
cityorsuburb(29) TYPE c,
stateorprovince(29) TYPE c,
postcode(29) TYPE c,
language(29) TYPE c,
END OF ty_struc1.
DATA: struc1 TYPE STANDARD TABLE OF ty_struc1,
gs_struc1 LIKE LINE OF struc1.
but why cannot I use the older definition of my itab?
‎2009 Mar 03 2:25 PM
You can use the TT:LOOP tag to loop through your supplied internal table.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<tt:loop ref=".ROOT">
<Payload tt:ref="ROOT">
<Language>
<tt:value ref="LANGUAGE"/>
</Language>
<Location>
<tt:value ref="LOCATION_COUNTRY"/>
</Location>
</Payload>
</tt:loop>
</tt:template>
</tt:transform>
Regards,
Naimesh Patel
‎2009 Mar 03 2:30 PM
‎2009 Mar 03 2:38 PM
I forgot to mention that we need to use the <TABLE> </TABLE> tag. This example works as intented:
Program:
TYPES: BEGIN OF ty_mara,
matnr TYPE matnr,
END OF ty_mara.
DATA: itab TYPE STANDARD TABLE OF ty_mara,
la_tab LIKE LINE OF itab,
xmlstr TYPE xstring.
la_tab-matnr = 'TEST1'.
APPEND la_tab TO itab.
la_tab-matnr = 'TEST2'.
APPEND la_tab TO itab.
CALL TRANSFORMATION ztest_np
SOURCE table = itab
RESULT XML xmlstr.
CALL FUNCTION 'DISPLAY_XML_STRING'
EXPORTING xml_string = xmlstr.
Transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="table"/>
<tt:template>
<table>
<tt:loop ref=".table">
<item>
<MATNR>
<tt:value ref="MATNR"/>
</MATNR>
</item>
</tt:loop>
</table>
</tt:template>
</tt:transform>
Regards,
Naimesh Patel
Edited by: Naimesh Patel on Mar 3, 2009 8:39 AM
‎2009 Mar 03 2:55 PM
Hi Naimesh,
I test your program and it works perfect but when I edit my program depending on yours I always get the dump at the mentioned coding loop.
this is my current transformation
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="table"/>
<tt:template>
<Payload>
<tt:loop ref=".table">
<item>
<Language>
<tt:value ref="LANGUAGE"/>
</Language>
<Location>
<tt:value ref="LOCATION_COUNTRY"/>
</Location>
</item>
</tt:loop>
</Payload>
</tt:template>
</tt:transform>
‎2009 Mar 03 3:06 PM
Wierd, it works good for me. Do you have LANGUAGE & LOCATION_COUNTRY in your table?
Regards,
Naimesh Patel
‎2009 Mar 03 3:10 PM
this is my internal table :
DATA: BEGIN OF struc1 OCCURS 0,
name(29) TYPE c,
location_country(10) TYPE c,
stras(29) TYPE c,
code(29) TYPE c,
language(29) TYPE c,
END OF struc1.
DATA: gs_struc1 LIKE LINE OF struc1.
gs_struc1-name = 'name_2'.
gs_struc1-location_country = 'country_2'.
gs_struc1-stras = 'Street_2'.
gs_struc1-code = 'code_2'.
gs_struc1-language = 'ENG_2'.
APPEND gs_struc1 TO struc1.
gs_struc1-name = 'name'.
gs_struc1-location_country = 'country'.
gs_struc1-stras = 'Street'.
gs_struc1-code = 'code'.
gs_struc1-language = 'ENG'.
APPEND gs_struc1 TO struc1.
CLEAR xml_string.
CALL TRANSFORMATION zconvert_st2
SOURCE table = struc1
RESULT XML xml_string.
‎2009 Mar 03 3:28 PM
when I change MATNR in your transformation with Location and Language I also get the dump.
Is the problem depending on my internal table?
‎2009 Mar 04 4:11 PM
‎2009 Mar 05 8:42 AM
‎2009 Mar 03 3:30 PM
now I have this definition and see it works
TYPES: BEGIN OF ty_struc1,
name(29) TYPE c,
location_country(10) TYPE c,
stras(29) TYPE c,
code(29) TYPE c,
cityorsuburb(29) TYPE c,
stateorprovince(29) TYPE c,
postcode(29) TYPE c,
language(29) TYPE c,
END OF ty_struc1.
DATA: struc1 TYPE STANDARD TABLE OF ty_struc1,
gs_struc1 LIKE LINE OF struc1.
but why cannot I use the older definition of my itab?
‎2009 Mar 03 5:59 PM
On line help on the CALL TRANSFORMATION says:
Addition 2a
... PARAMETERS {{p1 = e1 p2 = e2 ...}|(ptab)}
Effect
Use this addition to pass ABAP data objects e1 e2 ... as parameters p1 p2 ... to an XSL transformation. In Release 6.10, the data objects e1 e2 ... must be character-type, as of release 6.20 all elementary data objects and object references are allowed.
When you use your old table definition, system doesn't create the table witht he Character Type. With the new defintion (TYPE STANDARD TABLE OF ty... ) it is now the compitible with the CALL TRANSFORMATION.
Regards,
Naimesh Patel
‎2009 Mar 04 10:47 AM
‎2009 Mar 04 10:52 AM
I have values in the original xml which are within the symbol " ".
How can I add a value from the internal table into the field symbol " " ?
The origin XML:
<Origin Code1="value1" Code2="value2">
when I write in the simple transformation :
<Origin Code1=" <tt:value ref="VALUE1"/> Code2=" <tt:value ref="VALUE2"/>>
It doesn't work. How do I have to write the syntax therefore?
‎2009 Mar 04 11:53 AM
I have the solution, you have to use attributes like
<Origin>
<tt:attribute name="Code1" value-ref="ROOT1" />
ROOT1 is the field of your internal table and the result is :
<Origin Code1="value1">
‎2009 Mar 04 12:52 PM
Hi,
I have a problem with the order of the namespaces.
I have following header in my transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:xsi="http://www.w3.org" xmlns:xsd="http://www.w3.org/2001">
<tt:root name="table"/>
<tt:template>
<XmlInterchange Version="1">
<tt:namespace name="xsi" />
<tt:namespace name="xsd" />
the problem is that I want to list Version="1" after the namespace xsd, but I don't know how it should work?
‎2009 Apr 24 11:36 AM
a posted to a wrong place, sorry
Edited by: hoffmanng on Apr 24, 2009 12:41 PM