Overview

This is an introductory course that covers the use of SystemWeaver Script Language with a focus on Tables and Grids. Examples and exercises are provided.

Course Type

Suitable for class training or for self study.

Course Length

Two hours to half-day course.

Prerequisites

Exercises

The answers to all exercises can be found in the swExplorer ribbon tab Report Training>Answers under Tables and Grids.


Note: This presentation does not cover GUI and view concepts.


Introduction

Tables and grids enable you to view and present item data in a way that makes comparing and contrasting the information easier. The scripting of tables and grids within SystemWeaver is very similar, but the two have slightly different uses. This course does not cover the complete functionality and available options. After completing this course, explore all available features by using the SystemWeaver Help accessed by clicking the ? in the swExplorer or by taking the next course.


Comparing Tables and Grids

With regards to configuration, tables and grids share a majority of their constructs. Therefore, a table can quite easily be converted to a grid and vice versa. 

Which one you chose to use will depend on what your needs are as they have slightly different purposes: 


Table
Grid
Tables exist for the purpose of formatting data in reports and documents for review and/or printing.
  • Included in reports
  • Can be inter-dispersed with text in a report to enhance readability
  • Not editable
  • Must fit into the width of a printed page

Grids exist to give you an overview of the data and enable you to sort and filter that information. Also, it is possible to export data to Excel.
  • Excel-like matrixes that can be generated from data in SystemWeaver
  • Provides a good overview of information
  • Ability to filter, sort and group data as needed
  • Can be exported to Excel or CSV
  • Can be scrolled in a window




Examples of Tables and Grids and Their Definitions

Table
Grid


<Report>

   <Table>

   <Columns>

            <ItemNameColumn objectName="component" caption="Component" width="200"/>

            <ItemNameColumn caption="Requirement" width="200"/>

            <ItemAttributeColumn caption="Prio" type="PRIO"/>

            <ItemAttributeColumn caption="Verification Method" width="100" type="ABVM"/>

            <DescriptionColumn/>

      </Columns>

      <ForEachPart type="XESX">

         <DefObj>

            <ForEachPart type="EXAC">

               <DefObj>

                  <RowObject name="component">

                     <ForEachPart type="IBAR">

                        <DefObj>          

                           <Row/> 

                        </DefObj>

                     </ForEachPart>

                  </RowObject>

               </DefObj>

            </ForEachPart>

         </DefObj>

      </ForEachPart>

   </Table>

</Report>


<Grid>

   <Options>

      <CellAutoHeight/>

   </Options>

      <Columns>

         <ItemNameColumn objectName="component" caption="Component" width="200"/>

         <ItemNameColumn caption="Requirement" width="200"/>

         <ItemAttributeColumn caption="Prio" type="PRIO"/>

         <ItemAttributeColumn caption="Verification Method" width="100" type="ABVM"/>

         <DescriptionColumn/>

   </Columns>

   <ForEachPart type="XESX">

      <DefObj>

         <ForEachPart type="EXAC">

            <DefObj>

               <RowObject name="component">

                  <ForEachPart type="IBAR">

                     <DefObj>          

                        <Row/> 

                     </DefObj>

                  </ForEachPart>

               </RowObject>

            </DefObj>

         </ForEachPart>

      </DefObj>

   </ForEachPart>

</Grid>


Tables

Because tables exist for the purpose of formatting data in reports, you script them in the Reports view as described in Report Generation - Introductory Training. Tables are defined by the <Table> XML tag, typically have a static number of columns defined by the report template, and a number of rows that depend on the current item structure, its parts, etc.  This section will cover tables. However, what you learn here can easily be translated for use with grids as well. 


Definitions

A table definition consists of two parts: 

  • The columns defining the layout and what type of data that is to be shown in
  • The data collection where the rows are populated


Defining Columns

The <Columns> tags have been added and contain the 3 columns to be included in the table:

  1. <ItemNameColumn>: Will display the item's Name value. Its header caption will be ”Requirement” and its width will be 200 pixels.
  2. <AttributeColumn>: Will display the attribute value of the attribute type ”PRIO” and will have a default width.
  3. <DescriptionColumn>: Will display the content of the item’s Description field and will have default width.

<Report>

   <Table>

      <Columns>

        <ItemNameColumn caption="Requirement" width="200"/> (A)

                  <AttributeColumn caption="Prio" type="PRIO"/> (B)

                  <DescriptionColumn/> (C)

      </Columns>

   </Table>

</Report>


Note: For Grids and Tables, the only way to add Description information is to use <DescriptionColumn/>. The reason for this is that this column type is the only one that has an underlying component that can display the Description data. Currently, there is means of accessing the description of an Item using the Path language.


Adding Data: <Row/>

The <Row/> tag is used to populate the table with data. It has to be defined inside the <Table> tags as well. The below report will only include the data for the item we currently have selected in the structure tree, in this case Requirement 1.


<Report>

   <Table>

      <Columns>

            <ItemNameColumn caption="Requirement" width="200"/>

            <AttributeColumn caption="Prio" type="PRIO"/>

            <DescriptionColumn/>

      </Columns>

      <Row/>

   </Table>

</Report>


Iteration - View Data for Multiple Parts Using <ForEachPart> and <DefObj>

If you would like to view data for multiple parts, you can use the <ForEachPart> tag along with <DefObj> for each part and place it just above the <Row/> line.  The below example will provide two types of data (Name and Description) for two types of requirements (XESX and EXAC).


Example


<Report>
   <Table>
      <Columns>            
         <ItemNameColumn caption="Requirement" width="200"/>      
         <DescriptionColumn/>
      </Columns>
      
<ForEachPart type="XESX">
         <DefObj>
            <ForEachPart type="EXAC">

                <DefObj>                        
                     <Row/>  

                </DefObj>

            </ForEachPart>                  
        </DefObj>
      </ForEachPart>

   </Table>
</Report>



Tip: Remember, you can find the SID values for a component part by selecting it, navigating to Items>Parts and adding the SID column to the view. See Finding SystemWeaver Type Identifiers (SIDs) for more information.


Bildresultat för exercise icon freeExercise 1

  1. Open Item: x0400000000000255.
  2. For the Vehicle Architecture tree, create a report with a table that lists all the Requirements found in the Application (Software) components. The table should include each requirement's:
    • Name
    • ”Verification Method” Attribute 
    • Description


Note: When using the Sandbox Mode, the content of the sandbox can be lost when you switch to another item and change view. It is recommended that you save intermediate revisions by copying and pasting into NotePad or some external editor.

Combine Multiple Items' Data On One Line Using <RowObject>

Sometimes it is appropriate to have information about more than one item on the same row. For example, you might want to list Application Components and their Requirements both of which are items. This is done using the <RowObject> tag together with the objectName attribute in the Column definitions. The RowObject is used to connect the current item with a column identified by objectName in the column definition. The objectName in a column and the RowObject must be identical.


Example

In the below example, <RowObject name=”comp”> is used to indicate that the item or part shall be stored in a ”variable” called ”comp” for later use. When defining a column, you then indicate that the object stored in variable ”comp” be used in this column by setting the attribute ”objectName” to ”comp”.


Bildresultat för exercise icon freeExercise 2

  1. Open Item: x0400000000000255.
  2. For Vehicle Architecture, create a report with a table that lists all the Application Components and their Requirements similar to the example provided above.

Bildresultat för exercise icon freeExercise 3

  1. For the same Item: x0400000000000255, edit the Exercise 2 report to include Send Ports and Receive Ports instead of Requirements. 
  2. Remove the attribute column.

<Row/> vs <Row> </Row>

Sometimes it is preferred to have multiple values in one cell. This is achieved by letting <Row> </Row> encapsulate a part and using RowObject to store the objects to put into a column. In the below example, 

<RowObject name="req"/> is used to capture the Name of each Requirement of type "IBAR".


Bildresultat för exercise icon freeExercise 4

  1. Open Item: x0400000000000255.
  2. For Vehicle Specification Architecture, edit the report shown above to include Send Ports and Receive Port parts in the same cell instead of Requirements for all Application Components.
  3. Change the column header to 'Signal'.
  4. Click the Save XML Definition button. 
  5. Type 'Exercise 4' in the Enter Name text box and click OK. 

This pre-defined report will be used in the next exercise. 


Tip: You can use <RowObject name=””/> multiple times inside <Row> </Row>


Grids

A grid definition uses the XML tag <Grid>. Just like for reports, the grid editor is available in the View drop-down list:


The scripting you learned for defining tables can be applied to defining grids with minor adjustments.


Converting a Table to a Grid

One of the easiest ways to define a grid if you already have a table pre-defined (that is similar or identical to what you need) is to convert the table to a grid.

  1. In the View drop-down, select Reports and then select the pre-defined report from Exercise 4. 
  2. On the Definition tab, copy the table definition.
  3. In the View drop-down, select Grid, then Sandbox.
  4. Paste the table definition into the grid editor.
  5. Replace the <Table> XML tags with <Grid> tags. 
  6. Remove the <Report>tags. 

Your grid can now be viewed on the View tab.

Bildresultat för exercise icon freeExercise 5

  1. Open Item: x0400000000000255.
  2. Change the report table in Exercise 4 into a grid.

What's Next?

We hope that you are pleased with this course and feel ready to start creating report tables and grids. You can extend your knowledge by practicing the numerous scripting options described in the SystemWeaver Script Language Reference section in the Help. Additional training in the SystemWeaver Script Language is available upon request. Also, visit the Tips & Tricks Forum often to find and share configuration tips.