data: ixml type ref to if_ixml,
document type ref to if_ixml_document,
root type ref to if_ixml_element.
data: s type string.
data: categories type ref to if_ixml_element.
data: series type ref to if_ixml_element.
data: series2 type ref to if_ixml_element.
data: series3 type ref to if_ixml_element.
data: streamfactory type ref to if_ixml_stream_factory,
ostream type ref to if_ixml_ostream.
create document
ixml = cl_ixml=>create( ).
document = ixml->create_document( ).
create document root
root = document->create_element( name = 'SimpleChartData' ).
document->append_child( new_child = root ).
In this example chart you see that I could have a variable number of Categories. The application has the rule that I could have 1 to 5 categories. The Categories are then described on the bottom and unfortunately grayed out in my example. If you could read them you would see that they list the types of quality defects. The following is the code I use to add my categories:
append categories holder
categories = document->create_simple_element(
name = 'Categories'
parent = root ).
*For each Category in data append a Category Child
data: ipareto like line of appl->pareto_data.
loop at appl->pareto_data into ipareto.
s = ipareto-description.
document->create_simple_element(
parent = categories
name = 'C'
value = s ).
endloop.
Looking at the example again we see that we have three series (or points of data for each Category). We have Cumulative, Rework, and Scrap as our three series. You will also note that each series has its own chart type. Rework and Scrap are Stacked Bars, while the Cumulative is Dotted Line. We will control this by adding the customizing attribute to each series. This will connect each series to its own area in the layout definition. The following shows the code to create one series. It just has to be repeated for the other two:
append series section, negative values should have a leading minus sign
series = document->create_simple_element(
parent = root
name = 'Series' ).
label_string = text-001.
series->set_attribute( name = 'label'
value = label_string ).
series->set_attribute( name = 'customizing'
value = 'Series1' ).
loop at appl->pareto_data into ipareto.
s = ipareto-percent_scrap.
document->create_simple_element(
parent = series
name = 'S'
value = s ).
endloop.
Now all we have to is render out XML into the returning parameter of our method:
write data into string
streamfactory = ixml->create_stream_factory( ).
ostream = streamfactory->create_ostream_xstring( xml ).
document->render( ostream = ostream recursive = 'X' ).
I'm afraid I may have been a little long winded in this weblog. I hope that I haven't lost most of my audience. I just can't help but get excited by good, fun technology like the IGS. Well if anyone is still with me, be sure to tune in next time for a look at Table View Iterators.