Building Table of Tables (ToT) in RPE

A lot of times I’m asked if it’s possible to export the embedded tables from the DNG artifacts and to add them in the ToT (Table of Tables) section in WORD. My answer is always YES, it’s possible. RPE as a standalone tool or RRDG used in the DNG context can export DNG tables and add them in the ToT in the generated document.

How can we do this? We have multiple options and I’ll try to cover 2 of them and highlight the pros and cons for each of them.

App Versions Used:

  • DNG version: 6.0.6.1
  • RPE/RRDG version: 6.0.6.1

Option 1: Using the Table Caption property on DNG tables

The most preferred database for IBM Jazz Platform is IBM DB2. DB2 is packaged for free and you can find this information.

 

DNG - Set table caption

In DNG (DOORS Next Generation) we have the possibility to define the table caption for each embedded table. To do that you need to select the table and use right-click to open Table properties (see Fig 1)

Table Properties

Fig 1 - Table properties

In the Table dialog, choose the Advanced tab to define the table caption property. You can see in there that the table caption is a static text and cannot be linked to any other artifact.

Fig 2 - Advanced table properties

After adding the caption the table will look like this (in DNG the table caption will be always added on top of the table):

Fig 3 - Table caption listed above the table

Tip: To have the table caption centered you’ll have to set the table alignment to be centered in the DNG Table configuration. By default, the left alignment is used;

RPE - Using ToT element

Ok, so we saw what needs to be done in DNG for defining the table caption. Now let’s switch to RPE. 

Here, the solution is as easy as in DNG. All we need to do is to use the DNG Text schema to export the tables from DNG and to use a ToT RPE element to build the Table of tables in our WORD document. The DNG tables will be automatically added to the Table of Tables without any other extra effort.

Export DNG tables - RPE snippet

Using the DNG Text schema you’ll be able to export the DNG artifact content as XHTML. This will ensure that all artifact data content plus formatting will be exported in the generated WORD document.

Note: In order to get the xhtml format from DNG you need to use the dataSource->artifact->content->text->richTextBody query on a container and to display the div element inside a paragraph - so simple (see images below)

Fig 4 - RPE snippet - export artifact content

When RPE/RRDG is using the reportable API to get the data the DNG table - XHTML content -  will look like this (see table caption element highlighted below):

<table border="1" cellpadding="1" cellspacing="1" dir="ltr" id="_1594580295536" style="border-collapse:collapse; border-color:#696969;height:43px;overflow-wrap:break-word;table-layout:fixed;width:16cm;" width="900"> <caption style="text-align: center;">Document History Table</caption><tbody><tr><td colspan="1" id="_1587126630402" rowspan="1" style="background-color:#d3d3d3; overflow:hidden; padding:1px; text-align:center; width:1.93cm"><b><span style="background-color:#d3d3d3">Version</span> </b></td><td colspan="1" id="_1587126630403" rowspan="1" style="background-color:#d3d3d3; overflow:hidden; padding:1px; text-align:center; width:2.75cm"><b><span style="background-color:#d3d3d3">Date</span></b></td><td colspan="1" id="_1587126630404" rowspan="1" style="background-color:#d3d3d3; overflow:hidden; padding:1px; text-align:center; width:2.75cm"><b><span style="background-color:#d3d3d3">Name</span></b></td><td colspan="1" id="_1587126630405" rowspan="1" style="background-color:#d3d3d3; overflow:hidden; padding:1px; text-align:center; width:8.57cm"><b><span style="background-color:#d3d3d3">Change</span></b></td> </tr><tr><td colspan="1" id="_1587126630406" rowspan="1" style="border-color:#696969; overflow:hidden; padding:1px; width:1.93cm">1.0</td><td colspan="1" id="_1587126630407" rowspan="1" style="border-color:#696969; overflow:hidden; padding:1px; width:2.75cm">12/12/2020</td><td colspan="1" id="_1587126630408" rowspan="1" style="border-color:#696969; overflow:hidden; padding:1px; width:2.75cm">SME</td><td colspan="1" id="_1587126630409" rowspan="1" style="border-color:#696969; overflow:hidden; padding:1px; width:8.57cm">Version 1</td></tr></tbody></table>

If you are running the report now, you’ll see the DNG table exported and below the table the caption listed:

Fig 5 - Word snippet - table caption listed below the table

Adding the ToT element

Now you have the tables with captions exported from DNG, all you need to do is to insert an empty paragraph in the template (in the position where you want to inject the Table of Tables section) and to drag the Table of Tables element from the RPE Palette-> another group. 

 

If you want to have a label/title for your ToT structure you need to add a paragraph before the ToT paragraph and to display a static text -  e.g.: Table of tables


Fig 6 - Add ToT element in RPE

If you run the report you’ll see that all tables exported from DNG will be listed in the Table of Tables section. By default, you’ll always have the table number first followed by the caption label and on the right side the page number where the table is displayed.

Fig 7 - Generated ToT section in Word

Note: This format is configurable and can be changed if you go to ToT properties in RPE and select the Specific tab -> TOC code property.

Option 1 - Pro & Cons

Now, in the end, let’s see as a summary the pro/cons of this solution:

Pro:

  • Easy to implement
  • Out of the box functionality in DNG to set table caption

Cons:

  • There is no possibility to change the style of the table caption. The caption will be always listed below the table (even in the DNG will be placed above the table) and left align;
  • There is no possibility to change the look of the table caption. It’s a fix format: {table number} {table caption}
  • There is no way to add dynamic content in the table caption (only static text added in the DNG Table caption will be listed)

 


Option 2: Defining a custom artifact type in DMG for Table Caption

In case you want to have full flexibility on building/formatting the table caption you’ll have to choose Option 2  where you have a special artifact defined in DNG to store the table caption. This artifact can be added in the DNG module before or after the table, depending on how you want to be positioned in the generated Word document (full flexibility)

Create custom artifact type for storing the table caption - Table caption

All you need to do is to define a new artifact type similar to a regular paragraph/text artifact. Set the type name to be: Table Caption

Insert the Table caption artifact in the DNG module

Based on document formatting requirements this artifact will be placed before/after the artifact that contains the table in DNG (see image below)

Fig 8 - Table caption artifact added below the table

As you can see in the artifact properties panel, the type of artifact is Table Caption. This property will be used later on in the RPE snippet to determine what artifacts are going to be displayed as table captions in our final Word document.

Fig 9 - Table caption artifact

 

RPE Snippet - Export DNG table with table caption attached

Now we have in our DNG module 2 different artifacts: one to store the table and another one to store the table caption info. Even though there is extra information added in the DNG module for the table caption, we have more flexibility now to process that information in RPE.

To display the table we are using the same RPE snippet built for Option 1 (link to snippet). Because the table caption is not defined this time in the DNG table, the table will be exported without a caption below.

Fig 10 - DNG table exported without the caption

To display the table, the caption will have to build a condition to check that the artifact type is Table Caption and to use a special RPE element called - Table Caption to display the caption below/above the table in Word.

We need to use a Container element in RPE and to build a condition to check that the artifact type == Table Caption (see RPE snippet below). If the condition is met we insert a Table Caption element (found in Palette->Other->Table Caption) and display in the caption the title of the artifact.

Build the RPE condition:

Fig 11 - Filter artifacts of type 'Table Caption'

Add the Table Caption element:

Fig 12 - RPE snippet

If we are running our report now, we’ll see that the table caption is listed below the table

Fig 13 - Table caption listed below the table in Word document

Because the Table Caption is fully configurable now (is an element inside the RPE template) we can adjust the caption label as needed. We can also define the formatting for the table caption and specify the alignment

As an example, we’ll add a static Table text before the caption and we’ll choose a font size=10 and italic to display the table caption

Fig 14 - Customize table caption (RPE snippet)

Now if we are running the report again, the table will look like this:

Fig 15 - Customized table caption

Adding the ToT element

The process is the same as for Option 1. Just place a Table of Tables element in the position where you want to insert this section in the document.

In this Scenario 2 the ToT section will look like this:

Fig 16 - Final Table of Tables section in Word

Option 2 - Pro & Cons

Now, in the end, let’s see as a summary the pro/cons of this solution:

Pro:

  • Fully flexible solution
  • In terms of caption position, WYS in DNG is WYG in the generated document
  • You have the possibility to customize the caption label (using static text or javascript conditions)
  • You have the possibility to format the caption (add style information/alignment, etc.)
  • You have the possibility to insert dynamic content in the caption from different DNG artifacts

 

Cons:

  • Higher complexity and effort in defining table caption content in DNG (new artifact type needs to be defined)
  • Higher complexity in implementing the table caption in RPE

 

Image

Softacus AG

Löwenstrasse 20
8001 Zürich
Switzerland
E-Mail: info@softacus.com
Tel.: +41 43 5087081
Fax: +41 43 344 6075 

VAT: CHE-108.817.809 MWST
D-U-N-S® Number 486800618

Image

Softacus GmbH

Westendstrasse 28
60325 Frankfurt am Main
Germany
E-Mail: info@softacus.com
Tel.: +49 69 34876544
Fax: +49 69 5830 35709

VAT: DE301903892
D-U-N-S® Number 313482703

Image

Softacus s.r.o.

Křídlovická 351/47A
603 00 Brno
Czech Republic
E-Mail: info@softacus.com
Tel.: +420 530333482
Fax: +41 43 344 6075

VAT: CZ07286333
D-U-N-S® Number 496165108

Image

Softacus s.r.o.

Tatranské nám. 3
058 01 Poprad
Slovakia
E-Mail: info@softacus.com
Tel: +421 911 083 612
Fax: +41 43 344 6075

VAT: SK53507070
D-U-N-S® Number  2121388148