Skip to Content
           TYPE spfli.   * create the ixml main factory   ixml = cl_ixml=>create( ).  * create a empty document   document = ixml->create_document( ).   charset = ‘SAP*’.   encoding = ixml->create_encoding( character_set = charset                                     byte_order    = endian ).   document->set_encoding( encoding = encoding ).   * create root node for JNet   element = document->create_element( name = ‘SAPJNetData’ ).   ret = element->set_attribute( name = ‘version’ value = ‘1.0’ ).   ret = element->set_attribute( name = ‘xml:lang’ value = ‘en’ ).   ret = document->append_child( new_child = element ).   root = element.  *– create TypeRepository ——————————————- *   element = document->create_element( name = ‘TypeRepository’ ).   ret = element->set_attribute( name = ‘id’ value = ‘connections’ ).   ret = element->set_attribute( name = ‘version’ value = ‘1.0’ ).   ret = root->append_child( new_child = element ).   typerep = element.   * create LAYOUT    element = document->create_element( name = ‘LAYOUT’ ).   ret = typerep->append_child( new_child = element ).   parent = element.  * create MyLayout   element = document->create_element( name = ‘type’ ).   ret = element->set_attribute( name = ‘name’ value = ‘MyLayout’ ).   ret = parent->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘component’ ).   ret = element->set_attribute( name = ‘index’ value = ‘0’ ).   ret = element->set_attribute( name = ‘width’ value = ‘100%’ ).   ret = element->set_attribute( name = ‘height’ value = ‘50%’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘component’ ).   ret = element->set_attribute( name = ‘index’ value = ‘1’ ).   ret = element->set_attribute( name = ‘width’ value = ‘100%’ ).   ret = element->set_attribute( name = ‘height’ value = ‘50%’ ).   ret = parent->append_child( new_child = element ).  *– create LABEL —————————————————- *   element = document->create_element( name = ‘LABEL’ ).   ret = typerep->append_child( new_child = element ).   parent = element.  * create MyHeaderLabel   element = document->create_element( name = ‘type’ ).   ret = element->set_attribute( name = ‘name’ value = ‘MyHeaderLabel’ ).   ret = element->set_attribute( name = ‘inherits’ value = ‘NodeLabel’ ).   ret = parent->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘color’ ).   ret = element->set_attribute( name = ‘type’ value = ‘White’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘fillColor’ ).   ret = element->set_attribute( name = ‘type’ value = ‘Blue’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘font’ ).   ret = parent->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘style’ ).   ret = element->set_value( value = ‘BOLD’ ).   ret = parent->append_child( new_child = element ).   * create NODE   element = document->create_element( name = ‘NODE’ ).   ret = typerep->append_child( new_child = element ).   parent = element.  * create MyNode   element = document->create_element( name = ‘type’ ).   ret = element->set_attribute( name = ‘name’ value = ‘MyNode’ ).   ret = parent->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘layout’ ).   ret = element->set_attribute( name = ‘type’ value = ‘MyLayout’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘label’ ).   ret = element->set_attribute( name = ‘index’ value = ‘0’ ).   ret = element->set_attribute( name = ‘type’ value = ‘MyHeaderLabel’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘label’ ).   ret = element->set_attribute( name = ‘index’ value = ‘1’ ).   ret = element->set_attribute( name = ‘type’ value = ‘NodeLabel’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘plugs’ ).   ret = element->set_attribute( name = ‘min’ value = ‘0’ ).   ret = element->set_attribute( name = ‘position’ value = ‘SOUTH’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘sockets’ ).   ret = element->set_attribute( name = ‘min’ value = ‘0’ ).   ret = element->set_attribute( name = ‘position’ value = ‘NORTH’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘shape’ ).   ret = parent->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘border’ ).   ret = element->set_attribute( name = ‘type’ value = ‘EMPTY’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘size’ ).   ret = element->set_value( value = ‘140,77’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘filled’ ).   ret = element->set_value( value = ‘TRUE’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘fillColor’ ).   ret = parent->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘rgb’ ).   ret = element->set_value( value = ‘221,221,221’ ).   ret = parent->append_child( new_child = element ).   *– create Graph —————————————————- *   element = document->create_element( name = ‘Graph’ ).   ret = element->set_attribute( name = ‘version’ value = ‘1.0’ ).   ret = root->append_child( new_child = element ).   graph = element.  * layout, direction and view   element = document->create_element( name = ‘layouts’ ).   ret = element->set_attribute( name = ‘onLoad’ value = ‘TREE’ ).   ret = graph->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘types’ ).   ret = element->set_value( value = ‘TREE’ ).   ret = parent->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘direction’ ).   ret = element->set_value( value = ‘TOP_BOTTOM’ ).  ret = graph->append_child( new_child = element ).    element = document->create_element( name = ‘view’ ).   ret = element->set_attribute( name = ‘coordinates’ value = ‘GRID’ ).   ret = graph->append_child( new_child = element ).   parent = element.    element = document->create_element( name = ‘grid’ ).   ret = element->set_value( value = ‘80,180’ ).   ret = parent->append_child( new_child = element ).    element = document->create_element( name = ‘offset’ ).   ret = element->set_value( value = ‘40,0’ ).   ret = parent->append_child( new_child = element ).  * create node for the carrier   node_carriers = wd_context->get_child_node( name = wd_this->wdctx_carriers ).   node_carriers->get_static_attributes_table(    IMPORTING      TABLE  = lt_carriers ).   CHECK r_param->index IS NOT INITIAL.    READ TABLE lt_carriers INDEX r_param->index ASSIGNING append_child( new_child = element ).  * create nodes and edges for the connections   SELECT * FROM spfli INTO TABLE lt_spfli WHERE carrid = append_child( new_child = element ).    ENDLOOP.   * convert the XML to xstring   streamfactory = ixml->create_stream_factory( ).   ostream = streamfactory->create_ostream_xstring( content ).    renderer = ixml->create_renderer( document = document                                     ostream  = ostream ).   ret = renderer->render( ).   ostream->close( ).  * fill the data_source with the XML data   wd_context->set_attribute(     EXPORTING       name =  `DATA_SOURCE`       value = content ).  * dump the XML data to a mime file so  * we can see what’s generated   DATA:     mime_repository TYPE REF TO if_mr_api,     url TYPE string VALUE ‘/SAP/BC/WebDynpro/SAP/Z_NETWORK_EXAMPLE/dump.xml’.    mime_repository = cl_mime_repository_api=>get_api( ).    CALL METHOD mime_repository->put     EXPORTING       i_url                     = URL       i_content                 = content       i_suppress_package_dialog = abap_true.   ENDMETHOD.      Of course the coding of this method is a long and explicit and the usage of select statements should be avoided in the MVC concept. But the focus here is to understand the generation of the XML data and not on nifty programming.    As a result you’ll get a nice network chart: image
To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply