Introduction
I have written about my experiences with IGS Charting in the past.
thomas.jung3/blog/2004/08/31/bsp-150-a-developer146s-journal-part-x--igs-charting
data: ixml type ref to if_ixml,
document type ref to if_ixml_document,
streamfactory type ref to if_ixml_stream_factory,
istream type ref to if_ixml_istream,
parser type ref to if_ixml_parser.
ixml = cl_ixml=>create( ).
*-- create the initial document
document = ixml->create_document( ).
*-- create the stream factory
streamfactory = ixml->create_stream_factory( ).
*-- create an input stream for the table
istream = streamfactory->create_istream_xstring( xml ).
*-- create the parser
parser = ixml->create_parser( stream_factory = streamfactory
istream = istream
document = document ).
*-- parse the stream
if parser->parse( ) ne 0.
endif.
call method istream->close( )
Now we need to find the spot in the XML that we want to manipulate. I first wanted to find my ChartAxes section. Within there I have multiple Value Axes, so I need to process them one at time.
data: body type ref to if_ixml_element.
data: items type ref to if_ixml_node_collection,
item type ref to if_ixml_element,
element type ref to if_ixml_element,
node type ref to if_ixml_node,
val type string,
idx type i,
len type i.
body = document->find_from_name( name = 'ChartAxes' ).
items = body->get_elements_by_tag_name( name = 'ValueAxis' ).
len = items->
get_length( )..
do len times.
idx = sy-index - 1.
item ?= items->get_item( index = idx ).
if auto_metric = abap_true.
clear element.
element = item->find_from_name( name = 'MinimumAutomatic' ).
element->set_value( 'true' ).
clear element.
element = item->find_from_name( name = 'MaximumAutomatic' ).
element->set_value( 'true' ).
else.
clear element.
element = item->find_from_name( name = 'MinimumAutomatic' ).
element->set_value( 'false' ).
clear element.
element = item->find_from_name( name = 'MaximumAutomatic' ).
element->set_value( 'false' ).
endif.
....
enddo.
Finally we can end with the code necessary to convert our new XML back into a binary string.
clear xml.
data: ostream type ref to if_ixml_ostream.
ostream = streamfactory->create_ostream_xstring( xml ).
call method document->render( ostream = ostream ).