100% found this document useful (1 vote)
700 views

SQR Programming

This document provides an overview of SQR (Structured Query Report) programming. SQR is a reporting language for SQL databases that allows users to create simple or complex reports without traditional programming. The document outlines how to execute SQR programs from the command line or within PeopleSoft, and describes key SQR features like variables, commands, control statements, and debugging tools. It also provides examples of executing SQR from the command line and Process Scheduler.

Uploaded by

vivek
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
700 views

SQR Programming

This document provides an overview of SQR (Structured Query Report) programming. SQR is a reporting language for SQL databases that allows users to create simple or complex reports without traditional programming. The document outlines how to execute SQR programs from the command line or within PeopleSoft, and describes key SQR features like variables, commands, control statements, and debugging tools. It also provides examples of executing SQR from the command line and Process Scheduler.

Uploaded by

vivek
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 50

SQR Programming

SQR
(Structured Query Report)

Training Participation Guide (TPG)

Page 1 of 50

SQR Programming
CONTENTS
Introduction..................................................................................................3
SQR features.................................................................................................3
Executing SQR Programs...............................................................................4
1. Executing SQR from the Command Line..................................................................4
2. Executing SQR from the PeopleSoft Submenu.........................................................5
3. Executing SQR from the Process Scheduler.............................................................5
4. Output from an SQR Program...................................................................................6
SQR Variables.............................................................................................11
SQR Commands...........................................................................................13
1. SQR Print Command................................................................................................13
2. Format Commands...................................................................................................13
4. SQR Database Access..............................................................................................15
4.1. BEGIN-SELECT and END-SELECT....................................................................15
4.2. BEGIN-SQL and END-SQL Statements............................................................16
4.3 Dynamic SQL......................................................................................................17
5. Control Statements..................................................................................................17
5.1 DO Command.....................................................................................................17
5.2 IFELSEEND-IF................................................................................................18
5.3 WHILEEND-WHILE...........................................................................................19
5.4 EVALUATEEND-EVALUATE...............................................................................20
5.5 BREAK Command...............................................................................................21
5.6 EXIT-SELECT Command.....................................................................................21
5.7 GOTO Command.................................................................................................22
5.8 STOP Command..................................................................................................22
6. LET Command...........................................................................................................22
7. MOVE Command.......................................................................................................23
8. OPERATORS...............................................................................................................23
9. Important functions..................................................................................................23
10. INPUT Command....................................................................................................25
11. ASK Command........................................................................................................26
12. String Functions.....................................................................................................26
12.1 STRING.............................................................................................................26
12.2 UNSTRING.........................................................................................................27
12.3 SUBSTR.............................................................................................................27
13. Arrays......................................................................................................................27
13.1 CLEAR-ARRAY Command.................................................................................28
13.2 GET Command..................................................................................................28
13.3 PUT Command..................................................................................................29
14. Display and Show Command.................................................................................29
Multiple Reports..........................................................................................30
Flat Files.....................................................................................................31
Debugging and Testing...............................................................................36
#DEBUG Command......................................................................................................36
Using Compiler Directives for Debugging...................................................................36
Important SQCs..........................................................................................38
Using Load Look-up.....................................................................................39

Training Participation Guide (TPG)

Page 2 of 50

SQR Programming
Process Scheduler Components:.................................................................41
Run Control.................................................................................................41
Process Monitor..........................................................................................47

Training Participation Guide (TPG)

Page 3 of 50

SQR Programming
Introduction
Structured Query Report Writer, or SQR, is a report generator for SQL based
relational databases. SQR assists the user or programmer in creating simple or
complex reports without resorting to a standard programming language. SQR gives
you full control over the report display. You define the page size, headings, footings
and exactly how you want the information to appear. SQR is capable of handing
many different kinds of reports, including tabular (with multiple detail lines), single
or multiple page and form letters. SQR can display data in columns. Special formats
such as mailing labels are also possible. SQR can even create output suitable for
magnetic tape transfer or for creating pages on laser printers. The more you use
SQR, the more you will understand just how many different varieties of reports are
possible.
SQR is a specialized programming language for data access, for manipulating data,
and for reporting. SQR supports the full complement of SQL commands. Using SQR,
you can build complex report procedures that execute subsidiary SQL statements
conditionally, implementing either nested or hierarchical program logic. An SQR
program can execute multiple queries.
SQR features
-

Flexibility and scalability of client-server architecture


Comprehensive facilities for combined report processing and SQL processing
Multiple platform portability
Multiple RDBMS portability
It allows multiple reports to be created with only one pass through the data

Besides creating report output, SQR may be used as a high level programming
language, adding procedural logic and control to SQL queries and commands. Many
non-report applications can be written using SQR, including global database
manipulation and maintenance, table load and unload, interactive query and display
and many other applications.

Training Participation Guide (TPG)

Page 4 of 50

SQR Programming
Executing SQR Programs
An SQR program can be run either outside or inside PeopleSoft. While outside
PeopleSoft, an SQR program can be run from a command line. Inside PeopleSoft,
SQR can be run directly off the PeopleSoft submenu or as a scheduled process in the
Process Scheduler.
1. Executing SQR from the Command Line
SQR programs can be run from a command line. The syntax for executing an SQR
program from a command line follows:
Syntax
SQR program_name connectivity flags arguments @file
Where

Program_name is the name of your program.


Connectivity is the information needed to sign on to your database. It varies
depending on the type of database it is. For example, if the database is
Sybase, then connectivity refers to the username and password needed to
sign on to your database.
Flags are the option flags. Each flag should have a hyphen in front of it. If the
flag has an argument, the argument should come immediately following the
flag without any spaces between. For example, -Errorfile.dat -E
is the save
errors to a file flag; errorfile.dat is the name of file that the errors will be
saved to. Note there is no space between the flag (-E) and the argument
(errorfile.dat).
Arguments are any arguments being passed into the program.
@file is the name of a file that contains arguments to the SQR program. This
file must have one argument on each line.

A subset of the available flags that can be used follows:


Flag
-A
-B
-CB
-DEBUG
-E
-F
-I
-KEEP
-NOLIS
-PRINTER:LP
-PRINTER:HP
-PRINTER:HT
-PRINTER:PS

Description
Appends the output to an existing output file.
Indicates the number of rows to retrieve from database.
Causes the communication box to be used when running from
Windows
Causes the compiler to compile any lines preceded by #DEBUG
Writes errors to the error file specified.
Writes the output to the file specified.
Used to list the directories to be searched on a #include if the file to
be included is not in the current directory.
Causes SQR to generate a .SPF file as well as a .LIS file when
running a report
No .LIS file is generated. Instead, .SPF files are generated.
Creates a .LIS file that can be printed to a line printer.
Creates a .LIS file that can be printed to an HP LaserJet
Creates an HTML (HyperText Markup Language) .LIS file
Creates a PostScript (Adobe) .LIS file.

Training Participation Guide (TPG)

Page 5 of 50

SQR Programming
-PRINTER:WP
Creates a Windows (Microsoft) .LIS file.
Generally, SQR reports would be run in batch mode. To do this, a command
procedure, shell script, or batch file would be created which would contain the SQR
command lines. In this way, many SQR reports could be started one after another
without an operator manually running each one.
2. Executing SQR from the PeopleSoft Submenu
SQR programs can be run from PeopleSoft by selecting START, PROGRAMS,
PEOPLESOFT, SQR. This brings up the Windows SQR dialog box as shown in Figure
15-1. (If SQR is not showing up in the PeopleSoft submenu, then it is necessary to
go to the CLIENT SETUP tab of the Configuration Manager and check the SQR box of
the Shortcut Link group.) While it is possible to run SQR programs from the Windows
SQR dialog box, this would probably be used only to run non-PeopleSoft SQR
programs since run controls cannot be used here.

Figure 15-1: SQR dialog box appears so that the user can run an SQR report from
the PeopleSoft submenu.
To run an SQR program from the SQR dialog box, the user must enter the following:

Full path of the SQR program in the report name field.


The name of the database being used.
The username and password to sign on to the database.
Any report flags and arguments needed for the report to run properly.

3. Executing SQR from the Process Scheduler


SQR programs can be scheduled in the Process Scheduler.

Training Participation Guide (TPG)

Page 6 of 50

SQR Programming

After clicking the Run Button

4. Output from an SQR Program


The output from your SQR program is usually created in the directory where it is
being run, and it is named program.lis unless the -F flag is being used. The path of
the output file can be specified with the -F flag along with the name of the output
file.

Training Participation Guide (TPG)

Page 7 of 50

SQR Programming
Programming in SQR
SQR Sections
An SQR program is made up of many different sections. One section controls what
the heading of the report will look like. Another section controls the footer of the
report. There is a setup section, a program section, and a procedure section.

Heading
The heading section is an optional section. It contains a BEGIN-HEADING as the first
line and an END-HEADING as the last line. This section defines what the heading of
the report(s) will look like. Typically inside the heading section, there would be print
statements that would print such information as the title of the report, the current
date, the page number, and column labels. The BEGIN-HEADING line defines the
number of lines the heading will consist of on the report. In addition, if the program
is going to produce multiple reports, there can be a separate heading for each
report. To define a separate heading for each report being produced by the program,
the FOR-REPORTS qualifier must be used on the BEGIN-HEADING line. If the FORREPORTS qualifier is not included on the BEGIN-HEADING line, then the heading is
by default for all the reports being created in the program. An example heading
section follows:
BEGIN-HEADING 4 FOR-REPORTS=(REPORT1, REPORT2, REPORT5)
PRINT 'Our first Report' (1) Center
PRINT $current-date (2,1)
END-HEADING
The BEGIN-HEADING line above indicates that the heading will be four lines long and
that the heading defined in this heading section will apply to reports named
REPORT1, REPORT2, and REPORT5. The heading will print out "Our first Report'
centered on line 1 of the heading portion of the report. The current date will be
displayed in row 2, column 1. The $current-date is a reserved SQR variable that is
maintained by SQR. There will be two blank lines in the header since the header is
defined to be four lines long. More information on creating multiple reports will be
discussed later in this chapter. For now, just keep in mind in order to use the FOR-

Training Participation Guide (TPG)

Page 8 of 50

SQR Programming
REPORTS qualifier, DECLARE-REPORT and USE-REPORT must be used in other
sections of the SQR program.
The heading section can also contain logic statements such as if and else. Calls to
procedures are legal in the heading section as are print commands. Again, keep in
mind that the heading section is not a required section of the SQR program.
Note that there are three areas on a report page: the heading, the body of the
report, and the footing of the report. Each of these areas will have its own line
numbers. Thus, even though the heading area starts at line 1, the body area will
start at line 1 and the footing area will start at line 1 as well.
Footing
The footing section is also an optional section. The footing section contains a BEGINFOOTING as the first line and an END-FOOTING as the last line. This section defines
what the footer of the report(s) will look like. The BEGIN-FOOTING line defines the
number of lines the footer will consist of on the report. In addition, if the program is
going to produce multiple reports, there can be a separate footer for each report. To
define a separate footer for each report being produced by the program, the FORREPORTS qualifier must be used on the BEGIN-FOOTING line.
BEGIN-FOOTING 1
! PRINT "PAGE N OF M" IN THE FOOTING
PAGE-NUMBER (1,1) 'PAGE '
LAST-PAGE () ' OF '
END-FOOTING
The footing section can contain logic statements, calls to procedures, and print
commands. Anything that is legal in the heading section of the SQR program is also
legal in the footing section.
Setup
The setup section is an optional section. This section begins with a BEGIN-SETUP line
and ends with an END-SETUP line. This section is the only place that allows the
developer to declare reports, charts, images, layouts, printer, and procedure via the
DECLARE-REPORT, DECLARE-CHART, DECLARE-IMAGE, DECLARE-LAYOUT, DECLAREPRINTER, and DECLARE-PROCEDURE commands.
The ASK command can only appear in the setup section also. No logic statements are
allowed in this section. In addition to the above-mentioned commands that can
appear only in this section, the setup section can also have the following commands,
which can appear in other SQR sections as well:
ALTER-LOCALE, BEGIN-SQL, DECLARE-VARIABLE, LOAD-LOOKUP, CREATE-ARRAY.
The setup section is executed at compile time.

Training Participation Guide (TPG)

Page 9 of 50

SQR Programming
Program
The program section is a required section of an SQR program. This section is
executed first when the program is run. The first line of this section is the BEGINPROGRAM line, and the last line is the END-PROGRAM line. This section can contain
logic statements and procedure calls. Use caution when including BEGIN-SQL or
BEGIN-SELECT statements in this section. Depending on the version of SQR that is
being run, these statements may not be allowed in the program section. Since
version 4 of SQR, the BEGIN-SQL and BEGIN-SELECT statements are allowed in the
program section. It seems that many SQR programmers usually only put procedure
calls in the program section and do the bulk of the processing inside the procedures
even though most any SQR command could be placed in the program section. This is
a matter of style.
To call a procedure, you use the DO command. The following SQR code contains a
BEGIN-PROGRAM statement, a couple calls to procedures, and the END-PROGRAM
statement:
BEGIN-PROGRAM
DO MAIN
DO CLEANUP
END-PROGRAM
Each SQR command must be on its own line and can be indented if desired.
Remember that if the command is going to the database (e.g., BEGIN-SELECT, each
line must be in column 1.
Procedure
The procedure section is an optional section of the SQR program. It can have
arguments if desired. The procedure can be called in the BEGIN-PROGRAM section of
the SQR program or it can be called from another procedure. The procedure section
can have any SQR command in it. The procedure section starts with a BEGINPROCEDURE and ends with an END-PROCEDURE. If the procedure is to be a local
procedure it can have a keyword LOCAL on it. Procedures are by default global.
BEGIN-PROCEDURE test LOCAL (ARG1,ARG2, ARG3)
END-PROCEDURE

Training Participation Guide (TPG)

Page 10 of 50

SQR Programming
Exercise 1
Write a SQR program to Print Hello World.
Solution: -

BEGIN-PROGRAM
PRINT 'HELLO WORLD' (1,1)
END-PROGRAM
BEGIN-HEADING 1
PRINT 'TUTORIAL REPORT' (1) CENTER
END-HEADING
BEGIN-FOOTING 1
! PRINT "PAGE N OF M" IN THE FOOTING
PAGE-NUMBER (1,1) 'PAGE '
LAST-PAGE () ' OF '
END-FOOTING

Training Participation Guide (TPG)

Page 11 of 50

SQR Programming
SQR Variables
There are several different types of SQR variables:
1. Numeric:
Numeric variables must start with a #. A numeric variable can be of type
decimal, float, or integer. The precision of a numeric variable is 38 digits.
2. String:
A string variable must start with a $.
The text string can be of any length.
The null string is between single quotes.
3. Column:
A column variable starts with a &. Column variables are filled from the
database when a select statement is being performed.
4. Reserved:
Reserved variables are controlled by SQR automatically. #page-count
is an
example of a reserved variable that SQR maintains for you. There is a
separate reserved variable for each report of a multi-report program.
5. Date
Date variable.
Scope of Variables
All variables are global unless they are specifically being passed as arguments to a
procedure with a colon in front of the variable or they are in a local procedure. A
local procedure has the key word local on it.
If there happens to be a global variable and local variable with the same
name, in order to refer to the global variable in the local procedure, #_, $_, or &_
must be in front of the variable. For example, if #x is a global variable and there is a
local procedure test that has a local variable #x, then, to refer to the global variable
while in procedure test, it must be referred to as #_x.
Declaring Variables:
It is not required to explicitly declare variables in SQR. If variable $a is not declared,
then it is a string variable because of the $ in front of it. However, it is possible to
explicitly declare variables via DECLARE-VARIABLE. The syntax to DECLAREVARIABLE follows:
DECLARE-VARIABLE
[ DEFAULT-NUMERIC = {DECIMAL | FLOAT | INTEGER ]
[ DECIMAL [ ( prec_lit ) ] num_var ]
[ FLOAT num_var ]
[ DATE date_var ]
[ INTEGER num_var ]
[ TEXT string_var ]
END-DECLARE
The DECLARE-VARIABLE can be only in a BEGIN-SETUP section or the first line of a
local procedure. It can be used to set the default of a numeric variable to decimal,

Training Participation Guide (TPG)

Page 12 of 50

SQR Programming
float, or integer. It is also used to declare variables to a certain type. For example,
the following DECLARE-VARIABLE sets the numeric default to decimal, declares
variables #Y and #Z to be integer, and declares $BIRTHDATE to be type DATE.
BEGIN-SETUP
DECLARE-VARIABLE
DEFAULT-NUMERIC=DECIMAL
INTEGER #Y #Z
DATE $BIRTHDATE
END-DECLARE
END-SETUP

Training Participation Guide (TPG)

Page 13 of 50

SQR Programming
SQR Commands
1. SQR Print Command
Every SQR report requires print commands. The print command prints what will be
on the report. The syntax of the print command follows:
PRINT VARNAME (ROWPOS,COLPOS,WIDTH) [format command] [format command]
where
Varname - The name of the variable to be printed.
ROWPOS - The row position where the data will start.
COLPOS - The column position where the data will start.
WIDTH - The width of the field to be printed.
FORMAT COMMAND - Several format commands can be in a print command,
including BOLD, which will make the text being displayed appear in boldface print.
An example of a simple print statement follows:
PRINT $NAME (2,10,30)
In this example, the value stored in the text variable NAME will be printed in row (or
line number) 2, column 10 with a width of 30.
Relative printing refers to printing the value of a variable or literal in a location on
the report that is relative to the cursor's current print position. When a print
command is relative, there is usually a positive or negative sign in front of it or the
position is blank. The following few examples illustrate relative printing:
PRINT 'MY ADDRESS IS '(+1,5)
PRINT &ADDRESS (,+30)
In these examples, the same text MY ADDRESS IS is printed, but this time it is
printed one line down from where the current print cursor is located starting in
column 5. The actual value of &ADDRESS is printed on the same line as MY
ADDRESS IS since the row column is blank. It starts in the last column printed plus
30. Therefore, it starts in column 48 since MY ADDRESS IS starts in column 5 and
ends in column 18.

2. Format Commands
The print command has the following format commands:
BOLD - Prints the printed text in bold.
BOX - Draws a box around the printed text.
NOP - Noprintstops the text from being printed.
CENTER - Centers the text on the specified line.

Training Participation Guide (TPG)

Page 14 of 50

SQR Programming
CODE-PRINTER - Causes the printer to print something special.
SHADE - Draws a shaded box around the printed text.
EDIT - Edits the text before it is printed.
UNDERLINE - Underlines the text to be printed.
FILL - Fills the line(s) specified with a specific character or string.
MONEY - Causes the numeric variable to be printed using the MONEY_EDIT_MASK in
the current locale.
NUMBER - Causes the numeric variable to be printed using the NUMBER_EDIT_MASK
in the current locale.
WRAP - Wraps at word spaces.
ON-BREAK - Very useful format command that helps with reports that need to have
subtotals, etc. when a change occurs in the data. ON-BREAK is an option of the print
command (both implicit and explicit prints). It is a very useful tool for creating
reports, which are sorted by a field. Each time the field changes conditional
processing can be performed. The syntax of the ON-BREAK print qualifier follows:
ON-BREAK [PRINT = {ALWAYS|CHANGE|CHANGE/TOP-PAGE|NEVER}]
[SKIPLINES =]
[AFTER = procedure name]
[BEFORE = procedure name]
[SAVE = variable]
[LEVEL = nn]
Examples: PRINT &SOC_SEC_NUM (1,) EDIT 'xxx-xx-xxxx' BOLD CENTERED
PRINT #WINNING_AMT (,+10) EDIT $999,999.99
PRINT 'Test phrase' (1,) CENTER
Explicit versus Implicit Printing
A print command can be explicit or implicit. An explicit print command is one where
the word PRINT is actually there. The following example, as well as the examples in
the previous section, is an explicit print command:
PRINT 'THIS IS AN EXPLICIT PRINT COMMAND'(1,1)
An implicit print command is a print command where the word PRINT is not actually
necessary. This is used only in select paragraphs where the columns being selected
are to be printed. An example of a select paragraph where the columns are printed
follows:
BEGIN-SELECT
EMPLOYEE (1,1)
ADDRESS (,+25)
CITY (,+20)
FROM EMPTABLE
END-SELECT

Training Participation Guide (TPG)

Page 15 of 50

SQR Programming
4. SQR Database Access
The main reason for using SQR is to write a report on the data from your database.
This section discusses the essentials for accessing the database via SQR. SQR
enables us to perform both Data Definition Language (DDL) and Data Manipulation
Language (DML) SQL statements against the database. DDL includes both SQL
create and alter statements. DML includes insert, update, and delete SQL
statements. All of these can be performed in an SQR SQL paragraph. SQR also
provides a specialized paragraph for SQL selects. SQR selects are only used for
selecting data out of the database.

4.1. BEGIN-SELECT and END-SELECT


The BEGIN-SELECT statement begins the select paragraph, and the END-SELECT
ends the select paragraph. The select paragraph selects columns of data from the
database. In other words, the select paragraph retrieves the data from the database
and stores them in column variables. The select statement is read-only. It retrieves
the data from the database but does not allow the data in the database to be
modified. In addition, since the data are being read from the database one row at a
time, logic can be performed on each row because SQR statements are allowed in a
select paragraph. An example program follows: BEGIN-PROGRAM
DO MAIN
END-PROGRAM
BEGIN-PROCEDURE MAIN
BEGIN-SELECT
EMPLOYEE_NAME (+1,1)
DEPARTMENT
START_DATE (,35)
SALARY
(,+15)
ADD 1 TO #EMP_COUNT
FROM EMPLOYEE_TABLE
WHERE DEPARTMENT=1000
ORDER BY SALARY
END-SELECT
END-PROCEDURE
As we stated earlier, the program section will be executed first. Therefore, the first
thing that happens is the procedure main will be executed. In procedure main, there
is a select paragraph. The columns being retrieved from the database are
EMPLOYEE_NAME, DEPARTMENT, START_DATE, and SALARY. These column names
are the exact column names that appear in the database table EMPLOYEE_TABLE.
The rows that will be returned will be those that have a department number of 1000.
The rows will be returned by ascending salary. This program will create a report that
prints out the rows of matched data. If the data are to be printed on the report, the

Training Participation Guide (TPG)

Page 16 of 50

SQR Programming
parentheses must appear next to the column name that indicates the row and
column number that this piece of data should be printed on. The report created by
this program will print out the employee name in the next row after where the cursor
is currently located and in column 1. The department number will not be printed
since there are no parentheses next to it. The start date will be printed on the same
row as employee name but in column 35. The salary will be printed on the same row,
but 15 column positions away from the end of the start date. Note that all the
columns in the BEGIN-SELECT paragraph start in column 1. This is mandatory if the
select paragraph is to run without error. Note also that the line that is adding 1 to the
EMP_COUNT is indented. This line is an SQR statement, and it must be indented. In
other words, the actual lines representing the SQL statement being sent to the
database must be in column 1. There must be no commas between the column
names. All other statements must be indented. Note the variable #EMP_COUNT. This
represents a numeric variable. If we chose to, we could use the column variables of
&EMPLOYEE_NAME, &DEPARTMENT, &SALARY, or &START_DATE. These variables are
filled with the data retrieved from the table in the database.
It is possible to use dynamic SQL in this section.

4.2. BEGIN-SQL and END-SQL Statements


The BEGIN-SQL statement is the first line of an SQL paragraph, and the END-SQL is
the last line of an SQL paragraph. The SQL paragraph is used for any SQL statement
except the select statement. Unlike the select paragraph which is read-only on the
data in the database, the SQL paragraph can modify the database via such SQL
statements as create, alter, insert, delete, or update. The syntax to the SQL
statements is whatever the database being used requires. The SQL paragraph can
contain more than one SQL statement, but the statements must be separated by a
semicolon. Note that it is not good practice to have more than one statement in the
SQL paragraph because if one SQL statement fails, the next one will be executed,
anyway. Even if the ON-ERROR qualifier is used on the BEGIN-SQL statement to trap
errors, it may not always be clear which of the SQL statements in the paragraph
failed. It is good practice to always use the ON-ERROR qualifier to trap errors.
The following program has an insert statement inside the SQL paragraph. It also has
ON-ERROR on the BEGIN-SQL line. If an error occurs when performing the insert
statement, procedure INSERT_CLASS_ERROR will be executed automatically.
BEGIN-PROGRAM
DO PROC1
END-PROGRAM
BEGIN-HEADING 3
PRINT 'COLLEGE CLASS ENTRY' (1) CENTER BOLD
PRINT $CURRENT-DATE (2) CENTER
END-HEADING
BEGIN-PROCEDURE PROC1
INPUT $CLASS_DATE 'ENTER THE DATE' TYPE=DATE

Training Participation Guide (TPG)

Page 17 of 50

SQR Programming
INPUT $CLASS_TIME 'ENTER THE TIME'
INPUT $CLASS 'ENTER THE CLASS'
BEGIN-SQL ON-ERROR=INSERT_CLASS_ERROR
INSERT INTO APPTS(CLASS_DATE, CLASS_TIME, CLASS)
VALUES ($CLASS_DATE, $CLASS_TIME, $CLASS)
END-SQL
END-PROCEDURE
BEGIN-PROCEDURE INSERT_CLASS_ERROR
PRINT 'ERROR IN PROC1' (+1)
PRINT $SQL-ERROR (+1,1)
END-PROCEDURE
4.3 Dynamic SQL
Using dynamic SQL variables in the SQL paragraph, part or all of the SQL paragraph
is replaced dynamically as the report runs. Dynamic query variables in the SQL
paragraph cannot contain references to bind variables or to other query variables.
Dynamic SQL variables cannot be used in the SETUP section.
Following is an example of dynamic query variables in the SQL paragraph:
BEGIN-SQL ON-ERROR=ERROR-DISPLAY
DELETE FROM [$TABLE]
WHERE [$DELETE_WHERE]
END-SQL
If a SQL statement begins with a dynamic query variable, that variable cannot be
null. The statement must contain at least the first word of a valid SQL statement
each time the statement is executed. Variables elsewhere in the statement can be
null, as long as the whole statement is valid when constructed.
5. Control Statements
This section discusses the different control structures that are included in the SQR
language.
5.1 DO Command
The DO command is used to call a procedure. We have seen procedures being called
via the DO command in several of the previous examples. The syntax of the DO
command is simply the word DO followed by the procedure name to be called. For
example, if it is desired to call procedure MAIN, the command would be
DO MAIN

Training Participation Guide (TPG)

Page 18 of 50

SQR Programming
The call to the procedure may be either with or without arguments. This call to
procedure MAIN is without arguments. An example of a DO command calling a
procedure with arguments follows:
DO SENDVAL(#VALUE1, #VALUE2)
This DO command is calling procedure SENDVAL and passing two arguments to it:
#VALUE1 and #VALUE2. In this example, after procedure SENDVAL is executed, the
#VALUE1 and #VALUE2 variables will remain whatever the values were before
SENDVAL was executed even if procedure SENDVAL changed their values. In other
words, these variables are sent by reference, not by value. If we wanted to send
these variables by value, we would need to put a colon in front of them. To be clear,
if the value of #VALUE1 or #VALUE2 were modified in procedure SENDVAL and we
wanted this new value to be available to the calling procedure, then the variables
must have a colon in front of them. The DO command should look as follows:
DO SENDVAL(:#VALUE1, :#VALUE2)
5.2 IFELSEEND-IF
An example using an IF control structure follows: BEGIN-SELECT
EMP_NAME
SALARY
START_DATE
NUM_VAC_WKS
IF (&SALARY <70000)
DO ADD_WEEK_VACATION
DO GIVE_COPY_OF_THIS_BOOK
PRINT &EMP_NAME (+1,1)
PRINT &START_DATE (,+20)
PRINT &SALARY (,+10)
PRINT &NUM_VAC_WKS (,+15)
ELSE
DO GIVE_BIG_STOCK_OPTIONS
END-IF
FROM EMP_TABLE
END-SELECT
In this example, each row of data returned from the employee table is checked to
determine if the salary of the employee is less than $70,000.00. If it is less than
$70,000.00, then the procedures ADD_WEEK_VACATION and
GIVE_COPY_OF_THIS_BOOK are called and some of the data are printed to a report.
Otherwise, the salary is greater than or equal to $70,000.00 and the ELSE is
processed. When the ELSE is processed, the procedure GIVE_BIG_STOCK_OPTIONS
is called.
There is no THEN in this control structure. If one is added, an error will occur. In
addition, each key word must be on its own line. Do not place the ELSE on the same
line as the IF. An ELSE clause is not required but is allowed. There is no ELSE IF

Training Participation Guide (TPG)

Page 19 of 50

SQR Programming
allowed in SQR. It is okay to have several levels of IF statements. The following
examples are also valid IF control structures. In the first example below, there is no
ELSE clause. If the numeric variable #ERRORCOUNT = 3, the literal TOO MANY BAD
TRIES is printed out to the report.
5.3 WHILEEND-WHILE
The WHILEEND-WHILE control structure loops through the code inside the WHILE
construct while the expression on the WHILE line is true. Once the expression on the
WHILE line is no longer true, the next line to be executed is the line following the
END-WHILE. A WHILE loop can also be exited using the BREAK command. Once the
BREAK is reached, the next line of code to be executed is the line following the ENDWHILE. An example program containing a WHILEEND-WHILE construct is shown
below:
BEGIN-PROGRAM
DO MAIN
END-PROGRAM
BEGIN-PROCEDURE MAIN
LET $CARTYPE = 'FORD'
WHILE ($CARTYPE <> 'MERCEDES')
DO MERCEDES_SALES_PITCH
LET #COUNT = #COUNT + 1
INPUT $YESNO 'Would you buy a Mercedes now that you have heard the sales pitch
(Y/N)?'
IF ($YESNO = 'Y')
LET $CARTYPE = 'MERCEDES'
ELSE
IF (#COUNT = 5)
PRINT 'You are a tough customer' (+1,1)
BREAK
END-IF
END-IF
END-WHILE
PRINT 'FIRST LINE EXECUTED AFTER WHILE LOOP'(+1,1)
END-PROCEDURE
BEGIN-PROCEDURE MERCEDES_SALES_PITCH
PRINT 'MERCEDES IS A GREAT CAR. BUY IT'(+1,1)
END-PROCEDURE
In this example, the text variable $CARTYPE is not equal to MERCEDES, so the code
inside the WHILE will be executed. It will continue to be executed as long as
$CARTYPE is not equal to MERCEDES (note that the WHILE condition is checked only
at the top of the WHILE loop). The procedure MERCEDES_SALES_PITCH is called
each time, and the number of times the procedure is called is incremented with each
pass through. The INPUT command is used to ask the users whether they would buy
a Mercedes now that they have heard the sales pitch. The users' responses are
stored in the text variable $YESNO. If Y was entered, then $CARTYPE is set to
MERCEDES. Each time the END-WHILE is reached, the execution of the program

Training Participation Guide (TPG)

Page 20 of 50

SQR Programming
jumps back up to the WHILE condition. Each time the WHILE is executed, the
condition is checked. If the condition is still true, the code inside the WHILE will again
be executed. In this case, once Y is entered and the variable $CARTYPE is set to
MERCEDES via the LET command, the WHILE condition will no longer be true and the
next line that would be executed would be the print command just below the ENDWHILE. This example also illustrates the use of the BREAK command. If the user
answers N (no) to buying a Mercedes 5 times, then the BREAK command is
executed. This breaks you right out of the WHILE loop, and the next line to be
executed is the print command just below the END-WHILE.
5.4 EVALUATEEND-EVALUATE
The EVALUATE construct is equivalent to a case or switch statement in other
programming languages. It has much better performance than several nested IF
statements. An EVALUATE construct is made up of the EVALUATE line, WHEN
expressions with the code to be executed should the value of the variable in the
EVALUATE match the WHEN value, a WHEN-OTHER section, and an END-EVALUATE
statement. Each WHEN must be on its own line. There should be a BREAK between
the WHEN sections. If no BREAK is present, then the next WHEN section will be
evaluated. Should the value of #NUMCARS be modified inside a WHEN section that
does not have a BREAK command inside it, it is possible that the code inside other
WHEN sections may be executed. This may be your intention, and if so, it is legal.
However, leaving the BREAK command out more than most often would be a bug
that you did not intend to do.
An example illustrating an EVALUATE control structure follows:
BEGIN-PROGRAM
DO MAIN
END-PROGRAM
BEGIN-PROCEDURE MAIN
INPUT #NUMCARS 'Enter the number of cars your household currently owns:'
TYPE=integer
EVALUATE #NUMCARS
WHEN = 0
DO MERCEDES_SALES_PITCH
LET #ZEROCARS = #ZEROCARS + 1
BREAK
WHEN = 1
LET #ONECAR = #ONECAR + 1
BREAK
WHEN = 2
LET #TWOCARS = #TWOCARS + 1
BREAK
WHEN = 3
LET #THCARS = #THCARS + 1
BREAK
WHEN-OTHER
PRINT 'DO YOU LIVE AT A USED CAR DEALERSHIP'(+1,1)
PRINT 'OR ARE YOU A PEOPLESOFT CONSULTANT?'( +1,1)
END-EVALUATE

Training Participation Guide (TPG)

Page 21 of 50

SQR Programming
END-PROCEDURE
BEGIN-PROCEDURE MERCEDES_SALES_PITCH
PRINT 'MERCEDES IS A GREAT CAR. BUY IT'(+1,1)
END-PROCEDURE
In this example, the user is prompted to enter the number of cars currently at their
household via the INPUT command. The value they entered is stored in the numeric
variable #NUMCARS. On the basis of the value of #NUMCARS, only one of the WHEN
sections will be executed. Once the code in the WHEN section is executed, the BREAK
command will execute, which causes the next line to be executed to be the line
immediately following the END-EVALUATE.
5.5 BREAK Command
The BREAK command is used to break out of the EVALUATE or the WHILE control
structures. Refer to the EVALUATE section and the WHILE section of this chapter for
more information.

5.6 EXIT-SELECT Command


The EXIT-SELECT command works identically to the BREAK command. Both are
unconditional exits to a control structure. The EXIT-SELECT is used only in the
SELECT paragraph, whereas, the BREAK command is used to unconditionally exit out
of the EVALUATE and WHILE constructs. A program follows which contains an EXITSELECT statement to exit out of the select statement if the number of employees
living in Ohio is greater than 100.
BEGIN-PROGRAM
DO MAIN
END-PROGRAM
BEGIN-PROCEDURE MAIN
BEGIN-SELECT
NAME
STATE
IF (&STATE ='OH')
PRINT &NAME (+1,1)
PRINT &STATE (,35)
ADD 1 TO #OH_EMPS
END-IF
IF (#OH_EMPS > 100)
PRINT 'MAX OHIO EMPLOYEES ALLOWED'(+1,1)
EXIT-SELECT
END-IF
FROM EMPLOYEE_TABLE
END-SELECT
END-PROCEDURE

Training Participation Guide (TPG)

Page 22 of 50

SQR Programming
5.7 GOTO Command
The GOTO command causes the execution of the program to jump to the specified
label. The syntax of the GOTO command is the word GOTO followed by a label name.
The GOTO command allows you to jump either backward or forward. In the following
example, if the value of the number of cars currently at your household is greater
than 4, the execution of the program jumps back up to label NEXTINPUT and the
next line executed is to prompt the user to reenter the number of cars.
BEGIN-PROGRAM
DO MAIN
END-PROGRAM
BEGIN-PROCEDURE MAIN
NEXTINPUT:
INPUT #NUMCARS 'Enter the number of cars currently at your household:'
TYPE=integer
IF (#NUMCARS > 4)
PRINT 'ERROR: VALUE MUST BE LESS THAN OR EQUAL TO 4'(+1,1)
GOTO NEXTINPUT
END-IF
INPUT $YESNO 'Do you want to buy a Mercedes?'
END-PROCEDURE
The GOTO command and the label must be in the section of the program and in the
same paragraph as well.

5.8 STOP Command


The STOP command forces the SQR program to stop executing. Typically, you would
print out some errors prior to the STOP command so that the user would understand
why the program came to a halt. In addition, the QUIET option can be used so that
SQR abort messages will not be displayed.
IF (#VALUE > 4)
PRINT 'ERROR: VALUE MUST BE LESS THAN OR EQUAL TO 4'(+1,1)
STOP QUIET
END-IF
6. LET Command
The LET command is an SQR assignment statement. We have seen it several times in
the previous program examples. The syntax of the LET command follows:
LET destination_variable = expression
The expression can be as simple as a number or a single variable. The types of the
variable do not have to be the same because SQR handles conversion of the
variables to prevent the occurrence of errors. The expression can be very complex

Training Participation Guide (TPG)

Page 23 of 50

SQR Programming
and made up of operands, operators, and functions. Parentheses can be used to
override existing precedence rules. Some LET command examples follow:
Let
Let
Let
Let

#tax = #price * #tax


#var1 = (#a 1 #b + #c) / 100
#var2 = abs(#var1) + exp(#var1 * 2)
$string = $string || $string1 || string2

7. MOVE Command
The MOVE command moves one variable to another. It can be used to convert to
another variable type since the source variable and destination variable can be
different types. It can edit the field also.
Some examples follow:
MOVE 45 TO #AGE
MOVE 'LYNN' TO $FIRSTNAME
MOVE '123456789' TO $SOCSECNUM XXX-XX-XXXX
8. OPERATORS
The following is a list of operators. The operators are listed by highest precedence
first.
||
+, ^
*, /, %
+, >, <, >=, <=, =, <>, !=
NOT
AND
OR, XOR

Concatenate strings or dates


Sign prefix (positive or negative)
Exponent
Multiply, divide, remainder
Plus, minus
Comparison operators: greater than, less than,
greater or equal to, less than or equal to, equal, not
equal to, not equal to
Logical NOT
Logical AND
Logical OR, XOR (exclusive OR)

9. Important functions
ABS
ACOS
ASCII
ASIN
ATAN
COS
COSH

Returns the absolute value of the variable specified;


let #dabsvar = abs(#dvar)
Returns the arccosine of the variable specified
Returns the ASCII value for the first character in the
string specified
Returns the arcsine
Returns the arctangent
Returns the cosine
Returns the hyperbolic cosine of the variable
specified

Training Participation Guide (TPG)

Page 24 of 50

SQR Programming
DATEADD
DELETE
E10
EXISTS
EXP
LOG
LOG10
MOD
RAD
RENAME
SIGN
SIN
SINH
TAN
TANH

Returns a date after adding (or subtracting) the


specified units to the specified date value
Deletes the file specified
Returns the value of 10 raised to the value specified
Determines if the file specified exists
Returns the value of e raised to the value specified
Returns the natural logarithm of the specified value
Returns the base10 logarithm of the variable
specified
Returns the fractional remainder
Returns a value expressed in radians of num_value
which is expressed in degrees
Renames the first file name to the new filename
Returns a -1, 0, or 11 depending on the sign of
specified variable's value
Returns the sine of the specified variable
Returns the hyperbolic sine of the specified variable
Returns the tangent of the specified variable
Returns the hyperbolic tangent of the specified
variable

ADD Command
The ADD command adds a value to a variable The variable on the right is the one
being modified. The ROUND =xx option can be used to round the result. The digits
on the right side of the decimal point are rounded to the number of digits specified
with xx. This ROUND option only applies to decimal or float results.
In the following example 1 is added to the numeric variable #NUMVAR:
ADD 1 TO #NUMVAR
This is more efficient than the let command:
LET #NUMVAR = #NUMVAR 1 1.
The following ADD command adds the raise amount to the salary. Therefore, #salary
will now be equal to #salary 1 #raise.
ADD #raise to #salary.
SUBTRACT Command
The SUBTRACT command subtracts from a variable. The variable on the right is the
one being modified. The ROUND=xx option can be used to round the result. The
digits on the right side of the decimal point are rounded to the number of digits
specified with xx. This ROUND option only applies to decimal or float results.
The following SUBTRACT command subtracts 2 from the variable #HOURLY_RATE.
The result of the subtraction is stored in #HOURLY_RATE.

Training Participation Guide (TPG)

Page 25 of 50

SQR Programming
SUBTRACT 2 FROM #HOURLY_RATE
The following SUBTRACT command subtracts #PENALTY from #TAX_REFUND. The
result is stored in #TAX_REFUND.
SUBTRACT #PENALTY FROM #TAX_REFUND
MULTIPLY Command
The MULTIPLY command multiplies one variable times another. Again, the variable on
the right side is the destination variable. The ROUND=xx option can be used on the
multiply command to round the result. The digits on the right side of the decimal
point are rounded to the number of digits specified with xx. This ROUND option
applies only to decimal or float results.
The following example multiplies #SALES_TAX_RATE * #TOTAL. The result is stored
in variable #TOTAL, and the number of decimal places is 2.
MULTIPLY #SALES_TAX_RATE TIMES #TOTAL ROUND=2
DIVIDE Command
The DIVIDE command divides one number into another. Again, the ROUND=xx
option can be used. The following DIVIDE command divides #total by 98.75 and
stores the result into #total (#total = #total / 98.75):
divide 98.75 into #total
10. INPUT Command
The INPUT command is a screen input/output (I/O) command. It prompts the user
and reads the user's response into a variable. The syntax of the INPUT command
follows:
INPUT variablename ['prompt'] [TYPE=typevalue ] [MAXLEN=value] [FORMAT=]
[NOPROMPT]
Where,
Variablename: This variable will hold the input value entered by the user.
Prompt: The prompt to be displayed on the screen must be in single quotes. If a
prompt is not specified, the default prompt is Enter $variablename.
NOPROMPT: Use of this qualifier stops any prompt from being displayed to the
screen.
TYPE: Specifies the data type of the input. The data type of the input variable can be
CHAR, TEXT, NUMBER, INTEGER, or DATE. If TYPE is not included in the INPUT
command, the default is CHAR or TEXT. When TYPE is included on the INPUT
command, the user will be prompted again if the value entered does not match the
specified type.

Training Participation Guide (TPG)

Page 26 of 50

SQR Programming
MAXLEN: Maximum length of the input. When used on the INPUT command, this
causes the user to be prompted again if the value entered is greater than the
maximum length allowed. Note that MAXLEN should always be used when the data
entered will be used in a table insert.
FORMAT: This qualifier is used to set the desired date format. If the format of the
date entered by the user does not match the format specified with the FORMAT
qualifier, then the user will be prompted again to reenter.
A sample program using the INPUT command follows:
BEGIN-PROGRAM
DO LIST_EMPS
END-PROGRAM
BEGIN-PROCEDURE LIST_EMPS
INPUT #DEPT_NUM 'Enter the dept number to search for: ' MAXLEN=2
TYPE=INTEGER
BEGIN-SELECT
EMP_NAME (+1,1)
DEPT_NO (, 25,5)
SALARY (, 40)
FROM EMPLOYEE_TABLE
WHERE DEPT_NO = #DEPT_NUM
END-SELECT
END-PROCEDURE

11. ASK Command


The ASK command is a screen input/output (I/O) command also. It sets substitution
variables. The substitution variables are set at compile time. The ASK command is
allowed in the SETUP section only. The ASK command must be used in an SQR
program if it is desired to receive parameters from the Process Scheduler.
ASK sub-var (prompt)
Where
sub-var is the substitution variable
prompt is an optional prompt that is displayed if the value for sub-var was not on the
command line or in an argument file

12. String Functions


12.1 STRING
The STRING command concatenates a list of variables or literals into a single text
variable. The delimiter specified in the STRING command separates the data being
concatenated. The delimiter can be a combination of symbol(s) and character(s).
However, whatever the delimiter is defined to be, it cannot occur in the data.

Training Participation Guide (TPG)

Page 27 of 50

SQR Programming
The following example concatenates the data shown, separates it by a colon, and
stores it into variable $WININFO:
STRING $winner_name $selling_agent $state $amt_won BY ':' INTO $WININFO
The result of this STRING command would set $WININFO to the following string.
Note that a colon separates the data. This is because the delimiter was set to colon
in the preceding STRING command.
John Doe:Cumberland Farms:Massachusetts:100000.00
12.2 UNSTRING
The UNSTRING command performs the opposite function of the STRING command. It
separates the data in a text variable into separate variables based on the delimiter
specified.
To unstring $WININFO above into separate variables, perform the following
UNSTRING command:
UNSTRING $WININFO BY ':' INTO $winner_name $selling_agent $state $amt_won
Be sure that when unstringing the text variable, the variables to set are in the proper
order.
12.3 SUBSTR
The substr function allows you to extract one string from another, starting at a
specified position and continuing for a set number of characters.
Let $STRVAR = SUBSTR($STRINGVALUE, [Start position], [length])
13. Arrays
SQR supports arrays. To create an array in SQR, use the CREATE-ARRAY command.
CREATE-ARRAY NAME = arrayname SIZE = nn
FIELD = name:type [:occurs ][= {init_value_txt_lit|_num_lit}]
where
NAME = arrayname
Specifies the name of the array.
SIZE = nn
Defines the number of elements in the array.
FIELD: Specifies the name of the field; the type of the field, and the number of
occurrences of the field. The valid types of the field are DECIMAL, FLOAT, INTEGER,
NUMBER, CHAR, and DATE.

Training Participation Guide (TPG)

Page 28 of 50

SQR Programming
The CREATE-ARRAY commands must be inside the BEGIN-SETUP section. The
following example creates an array named CARS that has 500 elements. The
elements of the array are referenced from 0 to 499. The fields that are in the CARS
array are CARYEAR, which is a number and is initialized to -1. MAKE is a character
and is initialized to None. MODEL is a character and is initialized to Undefined.
INSTOCK is a number, which two occurrences both are intialized to -1. INSTOCK will
be referenced by INSTOCK(0) or INSTOCK(1) depending on which occurrence is
being referenced.
BEGIN-SETUP
CREATE-ARRAY NAME=CARS SIZE=500
FIELD=CARYEAR:NUMBER=-1
FIELD=MAKE:CHAR='None'
FIELD=MODEL:CHAR='Undefined'
FIELD=INSTOCK:NUMBER:2=-1
END-SETUP
To reset the values in the array to their initial values, use the CLEAR-ARRAY
command. Arrays are accessed with the GET and PUT commands. Other commands
that can manipulate arrays are ARRAY-ADD, ARRAY-SUBTRACT, ARRAY-MULTIPLY, and
ARRAY-DIVIDE.
13.1 CLEAR-ARRAY Command
The CLEAR-ARRAY command clears the array. If there were initial values, the array is
set to the initial values that were set up in the CREATE-ARRAY command. The syntax
of the CLEAR-ARRAY command follows:
CLEAR-ARRAY {NAME=arrayname}
where NAME = arrayname specifies the name of the array to be cleared or initialized.
For example, the following CLEAR-ARRAY command initializes the CARS array:
CLEAR-ARRAY NAME=cars
13.2 GET Command
The GET command retrieves data from an array and stores them in a variable. The
syntax of the GET command follows:
GET var FROM arrayname(element) fieldname(occurrence)
A couple of GET examples follow. The following example places the value stored in
the #X element of array CARS field CARYEAR into variable $year:
GET $year FROM CARS(#X) CARYEAR
The next example places the first occurrence of INSTOCK of the first element of array
CARS into variable $number. Remember that the elements of the array are
referenced from 0 to 499. Therefore, the first element is in the 0 position.
Occurrences of a field are also referenced starting with 0.
GET $number FROM CARS(0) INSTOCK(0)

Training Participation Guide (TPG)

Page 29 of 50

SQR Programming
13.3 PUT Command
The PUT command places data into an array. The syntax of the PUT command
follows:
PUT variable INTO arrayname (element) field (occurrence)
The following example puts the value of numeric variable #X into the #A element of
CARS in the INSTOCK(1) field.
PUT #X INTO CARS(#A) INSTOCK(1)
14. Display and Show Command
The DISPLAY command is used to display data to the screen rather than to the
output report as with the print command. The DISPLAY command can use the same
EDIT commands as the print command. Each DISPLAY command causes the data to
be displayed on a new line of the screen. This can be suppressed via the NOLINE
option of the DISPLAY command.
The following example displays 123-4567 onto the screen because of the edit mask.
Display
Display
Display
Display

'1234567'
$temp1
'1234567'
$temp2

The SHOW command also writes information to the SQR trace files. However, unlike
the display command, show may be used to write one or more variables or literals
with each statement. For example, the following show command is equivalent to the
four display commands listed above:
Show '1234567' $temp1 '1234567' $temp2

Training Participation Guide (TPG)

Page 30 of 50

SQR Programming
Multiple Reports
It is possible to have the same program output to many different reports. The
reports will each be in a separate output file. The first step to handling multiple
reports in a program is to declare the reports in the BEGIN-SETUP section. For
example, in the following setup section, two reports are declared: the DETAIL report
and the SUMMARY report.
BEGIN-SETUP
DECLARE-REPORT DETAIL
END-DECLARE
DECLARE-REPORT SUMMARY
END-DECLARE
END-SETUP
Once the report names are declared, the USE-REPORT is used to make a report
current. The print commands print to the current report.
USE-REPORT DETAIL
PRINT 'THIS PRINT WILL
PRINT 'THIS PRINT WILL
USE-REPORT SUMMARY
PRINT 'THIS PRINT WILL
USE-REPORT DETAIL
PRINT 'THIS PRINT WILL

BE PRINTED ON THE DETAIL REPORT'(+1,1)


ALSO BE PRINTED ON THE DETAIL REPORT'(+1,1)
BE PRINTED ON THE SUMMARY REPORT'(+1,1)
BE PRINTED ON THE DETAIL REPORT ' (+1,1)

In addition, each report can have its own header and footer by listing the report
names in the FOR-REPORTS = qualifier of the BEGIN-HEADING or BEGIN-FOOTING
lines.
BEGIN-HEADING 3 FOR-REPORTS=(DETAIL)
PRINT 'MAJOR'(+1,1)
PRINT 'GRADE POINT' (,+10)
PRINT 'STUDENT NAME'(,+10)
END-HEADING
BEGIN-HEADING 3 FOR-REPORTS=(SUMMARY)
PRINT 'MAJOR'(+1,1)
PRINT 'AVERAGE GRADEPOINT'(,+10)
PRINT 'HIGH GRADEPOINT'(,+10)
PRINT 'LOW GRADEPOINT' (,+10)
END-HEADING

Training Participation Guide (TPG)

Page 31 of 50

SQR Programming
Flat Files
SQR language contains the ability to process flat files. A flat file is an ASCII or text
file or a tape containing ASCII or text files. The data in the database can be exported
to a flat file or imported from a flat file. The SQR commands that perform these
functions are the OPEN command, the READ command, and the WRITE command.
Opening a Flat File via the OPEN command The OPEN command is used to open a
flat file. The syntax of the OPEN command follows:
OPEN filename AS filenum accesstype
{FOR-READING|FOR-WRITING|FOR-APPEND}
{RECORD = record length [:FIXED|:FIXED_NOLF|:VARY]}
[STATUS = numbervar ]
where
filename - The name of the flat file to be opened.
filenum - The logical unit number of the flat file to be opened.
accesstype - Access type must be set to FOR-READING, FOR-WRITING, or FORAPPEND.
FOR-READING
The file is opened for sequential read.
FOR-WRITING
A new file is opened for writing.
FOR-APPEND
The file is opened and new data are written at the end of the existing data.
Record length - This is the length of the record. If the record type is FIXED, the
record length is the length without the terminator. If the record type is VARY, the
record length is the maximum length of the record. The default record type is VARY.
The maximum record length that can be opened is 32767.
STATUS = #var
The #var is a variable that will store the status of the OPEN command. The OPEN
command is successful when the #var value is 0. If #var is -1, then the OPEN
command failed. Use of the STATUS qualifier is highly recommended because
otherwise if the OPEN command fails, the program will just simply come to a halt.
Some OPEN command examples follow. The following example opens the file
CUSTOMER.DAT for reading. This file will have a record length of 80, and the record
length will be 80 fixed. The status variable to check is called #STAT. The logical unit
number assigned to this file is 2. This logical unit number must then be used in the
READ or WRITE commands to access this file.
OPEN 'CUSTOMER.DAT' AS 2 FOR-READING RECORD=80:FIXED STATUS=#STAT
IF #STAT != 0
PRINT 'OPEN ERROR ON CUSTOMER.DAT'(+1,1)

Training Participation Guide (TPG)

Page 32 of 50

SQR Programming
STOP
END-IF
The following example opens the file stored in string variable $FILE_NAME. The
logical unit number assigned to this file is 1. The file is opened for writing and the
maximum record length is 132. The status variable is #ST.
OPEN $FILE_NAME AS 1 FOR-WRITING RECORD=132:VARY STATUS=#ST
IF #ST <> 0
!process errors as desired
END-IF
The following example opens the file EMPLOYEE.DAT. The logical unit number
assigned to this file is 3. The file is opened for appending and the record length is 80
fixed length with no line delimiters. The status variable is #OPEN_STATUS.
OPEN 'EMPLOYEE.DAT' AS 3 FOR-APPENDING RECORD=80:FIXED_NOLP
STATUS=#OPEN_STATUS
IF #OPEN_STATUS=-1
PRINT 'OPEN ERROR ON FILE EMPLOYEE.DAT'(+1,1)
END-IF
Reading a Flat File via the READ Command The READ command reads a record
from a flat file and stores it into SQR variable(s). The syntax of the READ command
is
READ logical-unit-number INTO variables STATUS=#var
where
Logical-unit-number - The number assigned to the file in the open command.
Variables - Variable or variables in which the record data from the flat file will be
stored; the :length option can be used when filling the variables.
STATUS = #var
The #var is a variable that will store the status of the READ command. The read
command is successful when the #var value is 0. Otherwise a system error number
will be stored in #var. It is highly recommended to use the STATUS qualifier because
otherwise if the READ command fails, the program will simply come to a halt.
The #end-file reserved SQR variable is 1 when the end of the flat file is reached and
there are no more data to read. The data from the flat file can be read into text or
numeric variables.
A few examples follow. The first two examples are similar. They are reading from a
flat file containing customer information. In fact, the same information is contained
in both files. The difference is that in the first example, the data in the file are not
delimited. Instead, the length of each field is known and the READ command is using
the :length option when storing the data in each variable. In the second example,
the entire record of 80 characters long is being stored in string variable $cust_var.

Training Participation Guide (TPG)

Page 33 of 50

SQR Programming
The UNSTRING command is used to separate the data which is comma-delimited in
the file into separate variables.
READ 2 INTO $CUSTNAME:20 $ADDR:20 $CITY:10 $STATE:2 $ZIP:5
$ITEMBOUGHT:23
READ 2 INTO $CUST_VAR:80
UNSTRING $CUST_VAR BY ',' INTO $CUSTNAME $ADDR $CITY $STATE $ZIP
$ITEMBOUGHT
In this example, the flat file contains text data and numeric data. The record is read
and the first two characters are stored in the text variable $PROCCODE. The next 10
characters in the file are stored in the numeric variable #VALUE. The next character
is stored in the numeric variable #FLAG, and the next nine characters are stored in
text variable $DEPT.
READ 1 INTO $PROCCODE:2 #VALUE:10 #FLAG:1 $DEPT:9
Finally, there is a short program which determines if the file customer.dat exists by
using the EXISTS command. If it does exist, the file is opened for reading with a
varied record length of 132. Otherwise, an error is displayed and the program is
stopped via the STOP command. The status variable #iostat is checked to determine
if the open was successful. Again, if the open was unsuccessful, the program is
stopped via the STOP command. Next, the program will go into the WHILE loop and
continue reading from the customer.dat file until there are no more records to read.
No more records is determined by checking the #end-file variable. If #end-file is 1,
then the BREAK command breaks us out of the WHILE loop. The UNSTRING
command is used to break up the comma-delimited file into variables $name,
$addr1, $city, $state, and $phone. The data are printed to the report for each record
that was read from the file.
BEGIN-PROGRAM
DO MAIN
END-PROGRAM
BEGIN-PROCEDURE MAIN
IF EXISTS('CUSTOMER.DAT')=0
OPEN 'CUSTOMER.DAT' AS 1 FOR-READING STATUS=#IOSTAT RECORD=132
ELSE
DISPLAY 'FILE CUSTOMER.DAT DOES NOT EXIST: EXITING'
STOP QUIET
END-IF
IF #IOSTAT=-1
DISPLAY 'ERROR OPENING FILE CUSTOMER.DAT'
STOP QUIET
END-IF
WHILE 1=1
READ 1 INTO $CUST_VAR:132
IF #END-FILE
BREAK ! NO MORE RECORDS TO READ
END-IF
UNSTRING $CUST_VAR BY ',' INTO $NAME $ADDR1 $CITY $STATE $PHONE

Training Participation Guide (TPG)

Page 34 of 50

SQR Programming
PRINT $NAME (,+10)
PRINT $ADDR1 (,+25)
PRINT $CITY (,+25)
PRINT $STATE (, +12)
PRINT $PHONE (, +12)
END-WHILE
CLOSE 1
END-PROCEDURE
In this program, the data that were read in from the flat file could be inserted
directly into the database table if desired by placing the following BEGIN-SQL
paragraph into the while loop of the program:
BEGIN-SQL
INSERT INTO CUSTOMER_TABLE (NAME, ADDRESS, CITY, STATE, PHONE) VALUES
($NAME, $ADDR1, $CITY, $STATE, $PHONE)
END-SQL
Writing to a Flat File via the WRITE command The WRITE command writes data
stored in SQR variable(s) to a flat file. The file must be opened for writing in order to
write to the file.
The syntax of the WRITE command is
WRITE logical-unit-number FROM variables STATUS=#var
where
Logical-unit-number - The number assigned to the file in the open command.
Variables - Variable(s) that will be written to the flat file; the :length option can be
used and if so, the value will be truncated or filled to meet the length.
STATUS = #var
The #var is a variable that will store the status of the WRITE command. The WRITE
command is successful when the #var value is 0. Otherwise a system error number
will be stored in #var. Use of the STATUS qualifier is highly recommended because
otherwise if the WRITE command fails, the program will simply come to a halt.
A few examples follow. The first two examples are similar. They involve writing
customer information to a flat file. In fact, the same information will be written to
both files. The difference is that in the first example, the variables are written
directly to the file. The second example utilizes the STRING command.
The STRING command concatenates them together separated by commas into text
variable $CUST_VAR. Then $CUST_VAR is written directly into the file.
WRITE 2 FROM $CUSTNAME:20 $ADDR:20 $CITY:10 $STATE:2 $ZIP:5 $ITEM:23

Training Participation Guide (TPG)

Page 35 of 50

SQR Programming
and
STRING $CUSTNAME $ADDR $CITY $STATE $ZIP $ITEMBOUGHT BY ','
INTO $CUST_VAR
WRITE 2 FROM $CUST_VAR

Training Participation Guide (TPG)

Page 36 of 50

SQR Programming
Debugging and Testing
#DEBUG Command
When debugging a program it is often useful to:

Display data or show when a procedure or query executes by using temporary


SHOW or DISPLAY commands in key places in the program.
Isolate problem areas by temporarily skipping the parts of the program that
work correctly.
Temporarily cause additional behavior in questionable areas of the program.
For example, display or modify variables that you suspect are causing a
problem.

SQR provides the #DEBUG command to help you make temporary changes to your
code. You can use the #DEBUG command to conditionally process portions of your
program. Precede the command with #DEBUG, as shown in the following example:
#DEBUG DISPLAY $S
When the #DEBUG precedes a command, that command is processed only if the
-DEBUG flag is specified on the SQR command line. In this example, the value of $s
is displayed only when you run the program with -DEBUG.
You can obtain multiple debug commands by using up to 10 letters or digits to
differentiate between them. Indicate which command is to be debugged on the
-DEBUG flag, as shown in the following example:
sqr myreport username/password -DEBUGabc
In this example, commands preceded by #DEBUG, #DEBUGa, #DEBUGb, or
#DEBUGc are compiled when the program is executed. Commands preceded with
#DEBUGd are not compiled because d was not specified in the -DEBUG commandline flag.
Using Compiler Directives for Debugging
You can conditionally compile entire sections of your program using the five compiler
directives:

#IF
#ELSE
#END-IF or #ENDIF
#IFDEF
#IFNDEF

You can use the value of a substitution variable, declared by a #DEFINE command,
to activate or deactivate a set of statements, as shown in the following example:
#DEFINE DEBUG_SESSION Y

Training Participation Guide (TPG)

Page 37 of 50

SQR Programming
#IF DEBUG_SESSION = 'Y'
BEGIN-PROCEDURE DUMP_ARRAY
LET #I = 0
WHILE #I < #COUNTER
! GET DATA FROM THE ARRAY
GET $STATE $CITY $NAME $PHONE FROM CUSTOMER_ARRAY(#I)
PRINT $STATE (,1)
PRINT $CITY (,7)
PRINT $NAME (,24)
PRINT $PHONE (,55)
POSITION (+1)
ADD 1 TO #I
END-WHILE
END-PROCEDURE ! DUMP_ARRAY
#END-IF
The dump_array procedure is used only for debugging. By defining DEBUG_SESSION
as Y, the dump_array procedure is included in the program. Later, you can change
DEBUG_SESSION to N and exclude the dump_array procedure from the program.
The #IF command in this example is case-insensitive.

Training Participation Guide (TPG)

Page 38 of 50

SQR Programming
Important SQCs
SQC files contain blocks of reusable code, which may be included by reference in one
or more SQR programs. PeopleSoft has developed many such files to aid in the
execution of common tasks such as producing standard report headings, establishing
report layouts, performing data conversions and implementing database calls. These
procedures are in SQC files that are copied into SQR programs or other SQC files
using the #INCLUDE statement.
The following SQCs are common to most SQR programs:
File Name
Setenv.sqc
Setup31.sqc
Setup32.sqc
Datetime.sqc

Datemath.sqc
Curdttim.sqc

Number.sqc

Readxlat.sqc

Stdhdg01.sqc
Stdhgtr.sqc
Fshdg01.sqc
Reset.sqc
Stdapi.sqc

Description
Defines information that is common to
your database platform, operation
system, and report environment.
Standard setup sections that define
the page layout, printer configuration
and paper orientation.
Creates edit masks for conversion of
date and time variables from one
format to another. It also contains
procedures to perform the actual
conversion of those variables.
Converts dates between native
database format and DTU format
(yyyy-mm-dd).
Retrieves the current date and time
from the database. This SQC produces
4 variables: $AsOftoday & $AsOfNow,
the date and time in native database
format, and $reportDate and
$ReportTime, in standard report
format.
Contains generalized routines to
initialize currency edit mask and to
format numbers.
Retrieves the long and short names
from the Translate table for a specified
field name, field value, language &
effective date,
Contains print statements used as part
of the PeopleSoft standard heading
Contains the reset procedure & the
standard footing section
Contains the application program
interface procedures. These
procedures allow the SQR program to
communicate with the Process Monitor
and report manager inside the
PeopleSoft environment

Training Participation Guide (TPG)

Procedure Name

Init-DateTime
Format-dateTime
Format-NativeTime
Convert-To-DTU-Date
Convert-From-DTU-Date
Get-Current-DateTime

Init-Number
Format-Number
Format-Amt
ConvertCurrency
Read-Translate-Table

Reset
Begin-Footing
Define-prcs-vars
Get-Run-Control-Parms
Successful-EOJ

Page 39 of 50

SQR Programming
Using Load Look-up
Database tables often contain key columns such as a product code or customer
number. To retrieve a certain piece of information, you join two or more tables that
contain the same column. For example, to obtain a product description, you can join
the orders table with the products table, using the product_code column as the key.
With LOAD-LOOKUP, you can reduce the number of tables that are joined in one
SELECT. Use this command in conjunction with one or more LOOKUP commands.
The LOAD-LOOKUP command defines an array containing a set of keys and values
and loads it into memory. The LOOKUP command looks up a key in the array and
returns the associated value. In some programs, this technique performs better than
a conventional table joins.
You can use LOAD-LOOKUP in the SETUP section or in a procedure. If used in the
SETUP section, it is processed only once. If used in a procedure, it is processed each
time it is encountered.
LOAD-LOOKUP retrieves two fields from the database, the KEY field and the
RETURN_VALUE field. Rows are ordered by KEY and stored in an array. The KEY field
must be unique and contain no NULL values.
When the LOOKUP command is used, the array is searched (using a "binary" search)
to find the RETURN_VALUE field corresponding to the KEY referenced in the lookup.
The following example illustrates LOAD-LOOKUP and LOOKUP:
BEGIN-SETUP
LOAD-LOOKUP
NAME=PRODS
TABLE=PRODUCTS
KEY=PRODUCT_CODE
RETURN_VALUE=DESCRIPTION
END-SETUP
...
BEGIN-SELECT
ORDER_NUM (+1,1)
PRODUCT_CODE
LOOKUP PRODS &PRODUCT_CODE $DESC
PRINT $DESC (,15)
FROM ORDERLINES
END-SELECT
In this example, the LOAD-LOOKUP command loads an array with the product_code
and description columns from the products table. The lookup array is named prods.
The product_code column is the key and the description column is the return value.
In the SELECT paragraph, a LOOKUP on the prods array retrieves the description for
each product_code. This technique eliminates the need to join the products table in
the SELECT. If the ordlines and products tables were joined in the SELECT (without
LOAD-LOOKUP), the code would look like this:
BEGIN-SELECT

Training Participation Guide (TPG)

Page 40 of 50

SQR Programming
ORDER_NUM (+1,1)
ORDLINES.PRODUCT_CODE
DESCRIPTION (,15)
FROM ORDLINES, PRODUCTS
WHERE ORDLINES.PRODUCT_CODE = PRODUCTS.PRODUCT_CODE
END-SELECT
Which is faster, a database join or LOAD-LOOKUP? It depends on your program.
LOAD-LOOKUP improves performance in the following situations:

When it is used with multiple SELECTS.


When it keeps the number of tables being joined from exceeding three or
four.
When the number of entries in the LOAD-LOOKUP table is small compared to
the number of rows in the SELECT, and they are used often.
When most entries in the LOAD-LOOKUP table are used.

Training Participation Guide (TPG)

Page 41 of 50

SQR Programming
Process Scheduler Components:
Process Scheduler Manager is made up of several components. Process Scheduler
involves the interaction of the following separate components:
1. Process Type Definitions:
Process Type Definitions are the global definitions for processes. Use this option
to define or update process type definitions.
2. Process Definitions:
Process Definitions are the settings specific to a process. Use this option to define
or update process definitions.
3. Job Definitions:
Job Definitions enable you to group processes. Select this option to define or
update job definitions.
4. Recurrence Definitions:
These definitions describe the frequency of processes or jobs that run on a
recurring basis, such as weekly or monthly. Select this from the menu to define
or update recurrence definitions.
5. Server Definitions:
A server definition refers to an instance of the Process Scheduler Server Agent.
Select this menu option to define or update process server definitions.
6. Report Node Definitions:
Select this option to define the Report Distribution Node including URL, the home
directory, and FTP address. Use this to setup the parameters needed for the
Process Scheduler Server to transfer reports and log/trace files generated from a
process request to Report Manager.
7. Process System Settings:
Select this menu option to view or change the last process instance number, as
well as the system's default operating system.
8. Process Request:
A Process Request enables you to submit a job or process to run. This component
is commonly integrated into applications to support process requests made by
selecting Run from PeopleSoft applications. The Process Request page enables
you to specify such variables as where a process runs and in what format the
process output is generated.
Run Control
When we run a process via the Process Scheduler, we need to supply it with a
number of parameters like the Run Location, Output Destination, File / Printer name,
etc. This information is stored in the PeopleTools Run Control record
PSPRCSRUNCNTL.
Run control IDs are stored in a minimum of two tables:
1. Application Run Control record:

Training Participation Guide (TPG)

Page 42 of 50

SQR Programming
The application run control table stores information required to run a process,
such as from date, department ID, employee ID, and so on. All application
run control tables are keyed by user ID and run control ID.
2. PeopleTools Run Control record:
The PeopleTools Run Control table stores information required by PeopleSoft
Process Scheduler, such as output type, format, and destination.
To select an existing run control ID:
1. Select PeopleTools, Process Scheduler, System Process Requests.
2. The Sample Processes search page appears.
3. Enter part or all of an existing run control ID.
4. Click the Search button.
5. Select the required run control ID from the search results to display the
Process Request Dialog page.
Adding a new Process Definition:
To add a new process definition:
1.
2.
3.
4.

Select PeopleTools, Process Scheduler, Processes.


Select the required process type.
Enter the new process name.
Click the Add button.

The Process Definition page appears.


Complete the Process Definition page, including these fields and check boxes:

Process Type

The Process Type selected.

Training Participation Guide (TPG)

Page 43 of 50

SQR Programming
Name
Long
Description
Priority
Log client
request

SQR Runtime

API Aware

This name must match the file name of the process you are
defining. For example, if we are defining an SQR report named
ACCSQR.SQR, you must define the process name as ACCSQR.
This field is optional.
Select High, Medium, or Low to define the relative priority used by
the PeopleSoft Process Scheduler Agent to determine which process
to initiate first if multiple processes are queued to run on a server.
This option is selected, if you want to provide an audit trail for any
processes requested to run on a client workstation. This causes the
system to log the request to the Process Request table each time an
operator runs the process on their client workstation. Log client
request is selected by default for all API-aware processes, and
logging is always performed for all server-based requests.
If you select this option, the system appends SQT (Pre compiled
SQR Programs) to the process name in the parameter list on the
Process Definitions Options page, and uses the SQT Working
Directory specified in the Process Type Definition page.
Select this check box if this is an API-aware process. If this is
selected for any process that is not API-aware, PeopleSoft Process
Scheduler includes this process in the concurrent task count. This
can result in improper server load balancing. Selecting this option
does not mean that the process becomes API-aware. We must still
add API code to the process.

Process Definition Options page is used to specify that a process runs from a
specific location, server, component, or process group.

Server Name (Optional)


Specify a server on which the process should run. Specify the server name only to
restrict this particular process to this server definition (or if you have only one server
platform to submit your requests).

Training Participation Guide (TPG)

Page 44 of 50

SQR Programming
Leave blank to have the process requested for the first server or default operating
system that can process requests for the specified process class. This enables you to
balance the load between multiple process servers, because your request is initiated
by the first available server on the default operating system.
Recurrence Name
(Optional) These definitions describe processes or jobs that run on a recurring basis,
such as weekly or monthly. Select this menu to define or update recurrence
definitions. Some Recurrence options available are:
1. Daily: you can define the process to run every day.
2. RP_INIT: The Initialize Resume Processing process (RP_INIT) is designed to
run a process throughout the day.
3. M-F at 5 PM: If you need to run a process every weekday at 5 P.M.
4. Weekly Friday: you can define the process to run every Friday or weekly
every Monday, Wednesday and Friday.
Component
Attach the process to components. Adding a component to a process definition
causes that process definition to appear on the Process Scheduler Request page
when you select File, Run in that component, if you have security to run the process.
From Windows Client we use
button to run the Process. But from browsers using
PIA, there is a SubPage PRCSRUNCNTL_SBP which is used to run the process. This
SubPage can be used or modified in our Custom Components.
Here, a Component PRCSMULTI is selected which holds a Page PRCSSAMPLEPNL,
which in turn holds a SubPage named PRCSRUNCNTL_SBP. This SubPage has Run
button to run a report.
PRCSRUNCNTL_SBP SubPage in Application Designer:

Process Group
Make the process definition a member of the group. A process definition can be a
member of multiple process groups. Process groups are then assigned to security
profiles in PeopleSoft Security Administrator, which enables you to specify the
process requests that classes of users can run.
Override Options page is used to modify values that are passed to the
process.

Training Participation Guide (TPG)

Page 45 of 50

SQR Programming
Override Options:
Select a value if you have custom values to send through the parameter list,
command line, or working directory:
Append: Adds custom parameters to the end of the PeopleSoft string.
Override: Sends custom parameters in place of the PeopleSoft defaults.
Prepend: Adds custom parameters to the front of the PeopleSoft string.
Parameters: Enter the custom parameter values.
Destination Page:
The output source destinations are enforced for users who are not allowed to
override the output destination by their operator process profiles. If a user is allowed
to override it, the user run control destination is used in the process request.
Type:
Select the default destination type for this process:
None: Uses the user run control values.
Any: User can specify any valid option.
Default: Applicable to PS/nVision only.
Depending on the type of process, other selections include Email, File, Printer, and
Web. The value specified here overrides the value specified in the System SettingsProcess Output Type page. If the value specified here is deactivated, the value
designated as the default will be used.
Format:
Select the format for this process.
Destination Source:
Specify the output destination source for this process:
None: Use for processes for which you do not want to produce an output file
or report.
Process Definition: This request uses the output destination specified by the
process definition.
Process Type Definition: This request uses the output destination specified
by the process type definition.
User Specified: This is the default. The output destination for this request is
determined by the process run control designation.
For an SQR process, the destination source must be User Specified.
The Page Transfer or Log Transfer feature enables a user to go directly from the
Process Monitor to a designated page in the PeopleSoft application to view the results
from a successfully completed process. To enable users to go directly from the
Process Monitor to a page, specify the navigational route that an end user must
follow through the PeopleSoft menu interface.
Page Transfer Code
Select the type of transfer for this process:

Training Participation Guide (TPG)

Page 46 of 50

SQR Programming
None: Disables this feature for this process. The remaining fields become
unavailable when this value is selected.
Msg Log (message log): Enables the Log Transfer feature for this process.
Next Page: Enables the Page Transfer feature for this process.
Menu Name, Menu Bar Name, Menu Item, and Page Name
Select the navigation path that the user follows through the PeopleSoft menu
interface.
Menu Action
Select the menu action that the user can perform when the page is selected: Add,
Correction, Update, or Update All.
Notification page is used to send messages to a group (using a role ID) or
individuals (using a user ID) when a specific activity occurs with the process, such as
an error or a successful completion of the job.
After completing all these steps a new Process definition is created and be used to
run a Process, which can be invoked from Process Request Dialog page or from
custom pages.

Training Participation Guide (TPG)

Page 47 of 50

SQR Programming
The process which we created can be seen in the Process list which can be can be
scheduled to run the process.
Process Monitor
Process Monitor is a tool designed to track the status of all completed and pending
Process Scheduler requests. The Process Monitor not only allows us to check the
status of the process, but also:

To see the report run parameters


To delete the report from input or Output queue
To perform other related activities.

Process Monitor is comprised of two Pages:

Process List Page: The Process List page lets you to monitor the process
requests submitted by the user.
Server List Page: Server List page lets you to monitor the Process Scheduler
Server Agents within the system.

Process List Page allows us to view Processes submitted by a particular

User ID.
Type: such as Application Engine, Crystal, SQR.
Last: where you can specify an interval of time by which to limit the process
requests that appear in the list.
Server: You can just view processes run on a particular server, such as PSNT.
Run Status: to view by a specific status such as completed or queued.
View Job Items: This lets you view the individual items, or process requests,
that make up a PSJob.
Instance: Instance number is automatically generated.
Sequence: Within a PSJob, each individual process request has a defined
sequence in which it executes in relation to the others.
Run Status: Indicates the status of the process, such as Queued, Initiated,
or Cancelled.
Details: Displays the process details page.

Training Participation Guide (TPG)

Page 48 of 50

SQR Programming
Process details can be viewed by clicking Details button in the Process Monitor Page,
where you can view such details as request parameters and message logs.

Many of the items displayed in the Process Details page are display only. However,
you can use some controls to manipulate the program run.
Process:
The Process group box contains general information to help you identify the process
request. This is a display-only group that shows basic descriptive information about
this process.
Run:
The Run group box shows specific run information, such as the run control ID and
the run location. If the process runs on the server, the server name appears in the
Server field and any run recurrence that you select appears in the Recurrence field.

Training Participation Guide (TPG)

Page 49 of 50

SQR Programming

To add a run control ID:

To add a new value; from the search page click the Add a New Value page,
enter the new run control ID, and click Add.

The Process Request Dialog page shows the run control ID that you selected or
added for submitting your process request. It also includes links to Report Manager
and Process Monitor, so that you can check the progress of your job and view its
content immediately after it is posted. The Process Request Dialog page has two
additional pages that show your options for submitting requests if you do not run the
process from the browser:

Training Participation Guide (TPG)

Page 50 of 50

You might also like