Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8392

Understand how the word template is merged with xml data stream - part 2 - table structure

$
0
0

In this example, it is described how the data in xml stream with table structure is merged into word template:

clipboard1.png

The word looks like below after merge:

clipboard2.png

You should have gone through Understand how the word template is merged with xml data stream - part 1 - Simple structurebefore you start with table merge.


You could find the template and xml data file used in this example from attachment.


Merge step1 cl_crm_oi_docx_helper=>replace_vars_uuid_with_path

 

The same as the step in simple structure merge.

 

Merge step2 add necessary namespace to every node in xml

 

The same as the step in simple structure merge.

 

Merge step3 cl_crm_oi_docx_transform_rt=>transform

 

the formatted template source( uuid replaced with complete path ) and formatted xml data source( n0 namespace added ) are passed into this method.

 

step3.1 cl_crm_oi_docx_transform_rt=>indicate_tree

 

The xml node is further enriched with attribute Loopcount and Path, which are especially used for render data with table structure.

 

See how the xml source looks like after method call:

 

clipboard3.png

  • New attribute Path is added for each node.
  • Loopcount: total number of nodes which have the same name as current node
  • Loopid: index of current node

 

step3.2 cl_crm_oi_docx_transform_rt=>update_payload_from_addinsch

 

This method will create a new attribute sapvartype with value "T" for those node in xml source with table structure:

clipboard4.png

step3.3 recursively call cl_crm_oi_docx_transform_rt=>process_node_cc


clipboard5.png

We identify the current node ( n0:Z_JENS_GET_MORE_COMPLEXResponse/n0:ET_ORDER/ ) is a table node by querying attribute sapvartype with value "T":

clipboard6.png

And we know from the attribute Loopcount added in step3.1 that currently there are two Item nodes in xml, which means we need to dynamically generate two new rows in the word template to display the table data contained in xml. We can achieve this by cloning the existing row in the word template which contains the mapping information.

clipboard7.png

the cloning is done in this method:

clipboard8.png

clipboard9.png

Have a look at the word template source code after method call:

clipboard10.png

w:sdt node for table header display:

clipboard11.png

w:tr ( the first cloned node ):

clipboard12.png

w:tr ( the second cloned node ):

clipboard13.png

Now the placeholder for table data display is available in word template source. A recursive call is made with iv_node_intable = X to fill cloned table row in word template with table data in xml data file.

clipboard14.png

The left stuff is the same as the step for simple structure:

 

1. get the dom element node which is to be filled by each table structure field in xml data file:

clipboard15.png

2. call set_content_control_value to set the value 0005012366 of node OBJECT_ID in xml data file to the dom element node from the first cloned table row ( lv_loopid_tr = @1 ).

clipboard16.png

Open the final merged word document:

clipboard17.png

You should find from document source code that all table row fields whose data are filled from xml data file have a new attribute saprtvalue with value X.

clipboard18.png


Viewing all articles
Browse latest Browse all 8392

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>