Report Writer > Create Report > System Variables

System Variables

You use this program to display a list of the system variables defined within SYSPRO.

System variables are fields that have a pre-defined use. All system variables are prefixed with a dollar sign ($).

System variables

The following system variables can be used in calculations, headings and condition definitions within the Report Writer module:

Variable Description
$CompanyDate This is the current company date.
$PreparedDate This is the company date on which the report is generated (run).

The format for this field is defined in the setup field: Report prepared date (see System Setup - Date Format tab).

$Date This is the current operating system date.
$Time This is the current operating system time in hours and minutes (HH:MM).
$TimeHours This is the current operating system hour based on a 24 hour clock (1-24).
$TimeHours12 This is the current operating system hour based on a 12 hour clock (1-12).

You would typically use this variable together with the variable $TimeAmPm to indicate whether the time is before or after midday.

$TimeMinutes This is the current operating system minute.
TimeAmPm This is the current operating system AM or PM. You would typically use this together with the variable $TimeHours12 to indicate whether the time was before or after midday.
$Company This is the company ID.
$CompanyName This is the company name.
$Report This is the report code defined against the report.
$ReportName This is the description defined against the report.
$Table This is the primary table code.
$TableName This is the primary table name (description).
$Operator This is the operator code.
$OperatorName This is the operator name for the operator code.
$Version This is the report writer version number.
$ReportName This is the description defined against the report.
$Table This is the primary table code.
$TableName This is the primary table name (description).
$Operator This is the operator code.
$OperatorName This is the operator name for the operator code.
$Version This is the report writer version number.
$Page This is the current page number. You would typically use this to print page numbers on your reports.
$Row This is the number of rows selected to print by the report. You could use this variable to number the rows printed on a report or to count the number of rows printed.
$RowsRead

This is the number of rows read by the report, even if they have been excluded from printing because of a condition.

The variable $RowsRead returns different values in SQL as opposed to C-ISAM. In SQL, $RowsRead means the number of rows returned by the SQL SELECT statement and only includes rows that match the WHERE logic. This is because SQL only returns the selected rows, whilst C-ISAM reads all the records. SQL only includes rows that are to be processed.

$RowsUpdated

This is the number of rows updated by a report defined to update one or more columns in a table.

$Group

This is the current group level. You would typically use this to determine the group/subtotal level being processed.

$Sequence

This can be used to find the sequence number of the sequence in which the report was printed. This is useful if you define a report that can be run in different sequences, where this sequence is requested at run time.

$SequenceName

This can be used to display the sequence name of the sequence in which the report was printed.

$Null

This is the null value and can be used to find fields with no values against them. This variable cannot be used on numeric fields/columns.

$Space

This can be used to produce a line skip or to clear values in a field.

For example, when you define Detail lines in the Report layout, you can use the $Space variable on the Heading Line to indicate that no column headings are required.

$TableLevel

This variable can be used to base conditions on the level of the main tables. This variable would only be used where at least one table is linked to the primary table in the report.

It is especially useful for defining conditions and when generating extract reports.

There are three different table levels:

  • 0 is always the Primary table

  • 1 is always the first 1-Many table linked to the Primary table

  • 2 is always the second 1-Many table linked to the first 1-Many table.

Sample usage

$Row

You define a report to display $Row at the end of each report line. This will also count the number of rows printed.

  • Tables: InvMaster (Level 0) and InvWarehouse (Level 1)
  • Columns: Stock Code, Description, Warehouse, $Row
  • User defined variable: $Row to print on detail line
Stock Code Description Product Class Warehouse $Row
BCL100 Bicycle Chain BA E 1
BP100 Bicycle Pump BA E 2
BBMB1 Bottom Bracket BB E 3
BBMW1 Ball Bearings BB E 4
B100 Bicycle BH W 5

$RowsRead

You define a report to read a file that contains details for 10 customers. 5 customers belong to the North branch and 5 to the South branch. You select to print only those customers in the North branch. You display $RowsRead on the total line.

  • Tables: ArCustomer
  • Columns: Customer, Branch, Salesperson, $RowsRead
  • Include logic: Where column Branch is equal to 10 (North) and not 20 (South)
  • User defined variable: $RowsRead to print on total line

Sample C-ISAM Report - Showing use of $RowsRead Variable

Customer Branch Salesperson
Bayside Bikes 10 102
Bikes and Blades - North 10 100
Maniac Sports 10 101
Sport Inc - North 10 100
Sport and Leisure - North 10 101
$RowsRead Total: 10    

Sample SQL Report - Showing use of $RowsRead Variable

Customer Branch Salesperson
Bayside Bikes 10 102
Bikes and Blades - North 10 100
Maniac Sports 10 101
Sport Inc - North 10 100
Sport and Leisure - North 10 101
$RowsRead Total: 5    

$RowsUpdated

You define a report to display inventory movements that have a journal number of 0 defined against them. You select to update the journal number from 0 to 5.

  • Tables: InvMaster, InvMovements and InvWarehouse
  • Columns: Stock Code, Warehouse, Journal Number, Transaction Quantity
  • Include logic: Where InvMovements journal is equal to zero
  • User defined variable: %JnlUpdate to print on each detail line and ask at run time for value
  • Report total line: Print $RowsUpdated to indicated the number of rows changed

Sample Report - Showing use of $RowsUpdated Variable

Stock Code Warehouse Journal Trn Quantity Jnl Update
BCL100 W 0 3 5
BP100 E 0 2 5
BBMB1 S 0 1 5
BBMW1 E 0 5 5
B100 N 0 6 5
  Company total: 5 Rows Updated    

$Group

You define a report to list stock on hand by warehouse, with subtotals by product class and warehouse. You select to display $Group on all subtotal levels. The report is defined with the following:

  • Tables: InvMaster and InvWarehouse
  • Columns: Stock Code, Description, Product Class, Warehouse, Qty on Hand
  • Sequence: Warehouse, Product Class then Stock code
  • Subtotal break: Warehouse, Product Class then Stock code
  • Subtotal Level 1 and 2: Print $Group

Sample Report - Showing use of $Group Variable

Stock Code Description Product Class Warehouse Qty on Hand $Group
BCL100 Bicycle Chain BA E 25  
BP100 Bicycle Pump BA E 12  
  Total Product Class: BA     37 2
BBMB1 Bottom Bracket BB E 11  
BBMW1 Ball Bearings BB E 10  
  Total Product Class: BB     21 2
  Total Warehouse: E     58 1
B100 Bicycle BH W 2  

$Sequence

You define a report to print the stock code and warehouse. You further define a run time prompt enabling the operator to run the report in either stock code or warehouse sequence.

  • Tables: InvMaster and InvWarehouse
  • Columns: Stock Code, Description, Warehouse, Qty on Hand
  • Page Headings: Add $Sequence to print on line 3 after the standard report headings
  • Run time prompt: Define the sequence in which to run the report where by Stock code is sequence 1 and by Warehouse is sequence 2.

Sample Report - Showing use of $Sequence Variable

Prepared: Report: Sequence: 11/07/2001 13.41 Report - Stock Codes 1      
Stock Code Description Warehouse Qty on Hand $Group
B100 Bicycle E 25 25
BBMB1 Bottom Bracket W 11 11
BBMW1 Ball Bearings S 10 10
BCL100 Bicycle Chain E 2 2

$SequenceName

Using the example for the variable: $Sequence, by printing the variable $SequenceName on line 3 of the report heading, rather than $Sequence, the report heading would change as follows:

Sample Report - Showing use of $SequenceName Variable

Prepared: Report: Sequence name: 11/07/2001 13.41 Report - Stock Codes Stock Code      
Stock Code Description Warehouse Qty on Hand $Group
B100 Bicycle E 25 25
BBMB1 Bottom Bracket W 11 11
BBMW1 Ball Bearings S 10 10
BCL100 Bicycle Chain E 2 2

$Null

You define a report to list all stock items that do not have a warehouse defined against them. You use the $Null variable in your include logic.

  • Tables: InvMaster and InvWarehouse
  • Columns: Stock Code, Description, Warehouse
  • Include logic: Where Invwarehouse Warehouse Code is equal to $Null

$Space

You define a report to list stock on hand by product class. You use the $Space variable to skip a line whenever the product class changes.

  • Tables: InvMaster
  • Columns: Product Class, Stock Code, Description
  • Sequence: Product Class, then Stock Code
  • Subtotal break: Product Class.
  • Subtotal Level 1: Print $Space.

Sample Report - Showing use of $Space Variable

Product Class Stock Code Description
BB BCL100 Bicycle Chain
BA BP100 Bicycle Pump
     
BB BBMB1 Bottom Bracket
BB BBMW1 Ball Bearings
     
BH B100 Bicycle

$TableLevel

You define a report to display the text WH in front of the warehouse code every time it changes.

Display the $TableLevel, at the end of each line, to observe exactly when the level changes.

  • Tables: InvMaster (Level 0), InvWarehouse (Level 1)and InvMovements (Level 2).
  • Columns: Stock code, Description, Warehouse, Trans Qty, Journal No, $TableLevel.
  • Include Logic: Where $TableLevel is less than or equal to one.
  • User Defined Variable: $TableLevel to print on detail line.

Sample Report - Showing use of $TableLevel Variable

Stock Code Description Warehouse Trn Qty Journal $TableLevel
B100 Bicycle W 3 262 0
      2 268 2
      1 270 2
    E 5 263 1
      3 271 2
BBMB100 Bottom Bracket E 11 264 0
BBMW100 Ball Bearings W 1 264 0
      3 271 2
    E 6 266 1
      4 267 2
BCL100 Bicycle Chain S 9 261 0
      9 270 2