2011 Oct 28 8:45 AM
Hello.
I am new to the SAP chart engine, XML and transformations so please be patient with me from an ABAP-program I am trying to call a Z-transformation and attach an internal table with two columns. In the ST program I want to loop through the table and for each row insert the two values from the table in the XML.
In an ABAP-program I have an internal table containing datacoordinates for a scattered chart.
The table looks like this:
DATA: BEGIN OF coordinate,
x_value TYPE f,
y_value TYPE f,
END OF coordinate,
polygon_data LIKE STANDARD TABLE OF coordinate with header line.
As a prototype I just add a few coordinates like this:
polygon_data-x_value = '700'.
polygon_data-y_value = '8'.
APPEND polygon_data.
polygon_data-x_value = '1400'.
polygon_data-y_value = '3'.
APPEND polygon_data.
polygon_data-x_value = '1400'.
polygon_data-y_value = '10'.
APPEND polygon_data.
polygon_data-x_value = '700'.
polygon_data-y_value = '10'.
APPEND polygon_data.
polygon_data-x_value = '700'.
polygon_data-y_value = '3'.
APPEND polygon_data.
I have created a Z-transformation and I call it like this (I also have a separate transformation for all the customizing generated with SAP chart designer but that one works fine):
DATA: data_xml TYPE xstring.
CALL TRANSFORMATION ztest_ce_tables2xml
SOURCE polygon_data = polygon_data
RESULT XML data_xml.
Since I am trying to create a scattered chart I need to insert an X and Y value for each coordinate.In the manual SAP Chart engine - XML format description it looks like this:
...
<ChartData>
<Series>
<Point>
<Value type="x">1</Value>
<Value type="y">1</Value>
</Point>
<Point>
<Value type="x">2</Value>
<Value type="y">2</Value>
</Point>
...
My ST-program that I cannot get to work looks like below. How can I loop through my internal table and get the X and thy Y value for each row in my internal table?
BR Tommy (Sweden)
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="POLYGON_DATA"/>
<tt:template>
<ChartData>
<Series>
<tt:loop ref=".POLYGON_DATA">
<Point>
<Value type="x"><tt:copy ref=".POLYGON_DATA.X_VALUE"/></Value>
<Value type="y"><tt:copy ref=".POLYGON_DATA.Y_VALUE"/></Value>
</Point>
</tt:loop>
</Series>
</ChartData>
</tt:template>
</tt:transform>
2011 Oct 28 9:39 AM
Hello again.
I found the solution and would like to share it with the forum, maybe it could help someone.
My first error was in the call transformation statement:
CALL TRANSFORMATION ztest_ce_tables2xml
SOURCE polygon_data = polygon_data [] <----
Do not forget these
RESULT XML data_xml.
I also had an error in the ST program, it should look like this:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="POLYGON_DATA"/>
<tt:template>
<ChartData>
<Series>
<tt:loop ref=".POLYGON_DATA">
<Point>
<Value type="x"><tt:value ref="$ref.X_VALUE"/></Value>
<Value type="y"><tt:value ref="$ref.Y_VALUE"/></Value>
</Point>
</tt:loop>
</Series>
</ChartData>
</tt:template>
</tt:transform>