Sie sind auf Seite 1von 81

SQR

What is SQR (Structured Query


Reporting).
Reporting Tool.
3rd Party Tool. It belongs to BRIO
company.
This is independent of RDBMS and
OS.
SQR Supports all SQL Statements
(DML,DDL,DCL).

SQL in PeopleSoft
Some ways in which SQL is applied in PeopleSoft environment.
The three types of SQL commands that are used in SQR are:
Category

Command

QML (Query Manipulation Language)

SELECT command

DML (Data Manipulation Language)

INSERT, UPDATE, DELETE Commands

DDL (Data Definition Language)

CREAT, DROP Commands

Uses of SQR
Used for Reporting.
Background SQL Processing.
Used for Interfacing.
Move data from legacy
System to PeopleSoft System.
Move data from one module
to Other Module.

Conditions to use SQR


All SQR commands are case insensitive.
Command names, arguments are separated by at
least one space, tab or Carriage Return character.
An exclamation (!) point begins a single line
comment that extends to end of line.
Each new command must begin in a new line.
Best practice recommends SQL be entered in all
CAPS. All SQR commands are in lower case.

SECTIONS
A basic structure of a SQR Program
consists:
SETUP
PROGRAM
PROCEDURE
HEADING
FOOTING
The only section required is the Program
Section.

SETUP SECTION

The setup section contains


commands that determine the over all
characteristics of the program. Then it
must be placed at the beginning of the
program. The setup section is processed
during the program compilation stage.
No procedural logic is allowed in the
section.

The setup section can include the


following commands.
ASK
CREATE-ARRAY (Allowed in other places
also)
DECLARE-IMAGE
DECLARE-LAYOUT
DECLARE-PRINTER
DEECLARE-VARIABLE
LOAD-LOOOKUP
BEGIN-SQL (Allowed in other places also)

Example:
Begin-setup
declare-layout default
paper-size =(8.5,11)
left-margin =1
right-margin =1
top-margin =1
bottom-margin =1
End-declare
End-setup

Begin-SQL
Insert ;
update;
delete;
End-SQL

PROGRAM SECTION
This is the most important section
that defines the Beginning & End of
the program. This is the only
mandatory section. Generally we
use this section to control the
general flow of processing by calling
different procedures.

PROCEDURE SECTION
This is an optional section and one of the
most important section in SQR. This can be
used to break the program in to
manageable and easy to maintain pieces.
There can be any no. of procedures in an
SQR program and they can be invoked by
using the DO command.
PARAGRAPHS
SELECT
SQL
DOCUMENT

Procedures
Begin-procedure procedure_name
[paragraphs]
[commands]
End-Procedure <procedure_name>
-----------------------------------------------------------------------Procedure name after End-Procedure is
optional (Not recommended)
Procedure is a list of commands and/or
paragraphs that are referenced by a
corresponding do command.
Procedure names must be unique.

HEADING SECTION

This is an optional section and can be


used to print the heading
Begin-Heading #
End-Heading
FOOTING SECTION

This is an optional section and can be


used to print the Footing.
Begin-Footing #
End-Footing

Sections and Paragraphs


BEGIN SQL

BEGINSELECT

BEGINDOCUMENT

BEGIN-SETUP

YES

NO

NO

BEGINPROGRAM

YES

YES

YES

BEGINPROCEDURE

YES

YES

BEGINHEADING

NO

NO

BEGINFOOTING

NO

NO

YES
NO
NO

Printing in SQR
2 types of printing
1. Explicit printing.
2. Implicit printing.
Explicit printing
Print {variable | literal} ([line] [,[column] [,[length]]])

E.g: print ename (1,1,10)


Implicit printing
E.g: begin-select
Name
(,1)bold
Phone
(,30)
position (+1)
FROM ps_personal_data
End -select

Print Format options

Center
Wrap
Edit
Fill
Box
Shade
Bold
Underline

Edit masks
Edit argument is the most powerful
among all print commands. When this
argument is codedthe field is edited
before it is printed.
3 Types of Edits:
1. Text Edit.
2. Numeric Edit.
3. Date Edit.

Text edit masks


Allows formatting of string data.
X mask prints corresponding character from the print string.
B mask embeds space in the corresponding position of the print string.
Numeric edit masks

The 9 mask is used to print numbers. It fills to the right of the


decimal point with 0s and fills to the left of the decimal with
spaces.
The 0 mask is added to the front of a 9 mask to left fill with
leading zeroes.
Eg: 0999 mask will print 10 as 0010

The $ mask will print numbers with leading currency symbol


($). If you use a single $, it prints in a fixed position. If you use
2 or more $, it prints as floating symbol.
There are a wide variety of numeric edit masks available.
Refer to Peoplebooks and SQR Language Reference

Date edit masks


YY prints year in 2 digits. YYYY prints in 4 digit (Assumes current
century or decade)
DDD Day of year (1 366)
DD Day of the month (1 31)
D Day of the week (1 7), Sunday is the first day of the month
DAY Name of the day
J Julian day
AM/PM AM/PM Indicator
HH Assumes a 24 hr clock
HH12 Hour of the day (1 12)
HH24 Hour of the day (0 23)
MONTH Name of the month
MON Abbreviated name of month
MI Minute (0 59)
SS Second (0 59)

Assignment statement
SQR supports move and let for assigning variables.
Move command is used to copy data from one variable
to the other. Edit mask can be used in conjunction with
move statement.
Eg: move $source_data to $target_Data [edit mask]

Let command is used to assign the vaue of a literal,


variable or result of an expression to a user defined
variable.
Eg: let #tot=#base_amt * #exch_rate

Benchmark tests show that move command is more


efficient for assignment statements.

Operators
The following table lists operators in descending order of
precedence.
Operators of the same precedence are processed in the
sequence they appear in the expression, from left to right.
Use parentheses to override the normal precedence rules.

SQR variables and


commands

User defined variables

Variables are global


No advance declaration is required
Runtime variables are initialized by SQR assignment statements or procedure calls.

Substitution variables
Supply values at compile time.
Defined at the beginning of the SQR program using #definestatement.
Use the variable inside {}.

Variables declared in the setup section holds their values


globally (entire SQR).
Variables declared in the local procedure holds their values
only in the local procedure
Global Variables (declared in the setup section) can be
referred in a local procedure by using _.
Eg: #_Number, $_Date , $_Name.

SQR variables and commands

variables (Reserved) with values maintained and updated by


SQR:
#current-column Current column position within the page
grid.
$current-date The current date/time stamp of the host
machine.
#current-line The absolute line position within the page (Not
report area)
#end-file EOF indicator. Set to 1 if EOF
#page-count Current page number
#sql-count Number of rows affected by a DML statement
$sql-error Text message from DBMS upon execution of an SQL
command
#sql-status Numeric return code from the DBMS upon
execution of SQL

Local v/s global procedures


PeopleSoft makes extensive use of
procedures in SQR.
By default, all SQR procedures are global in
nature.

Begin-procedure update-course local


Begin-procedure GetStateName($country, $statein, :
$statename)

To indicate an argument may pass information back to


the calling procedure, a colon : is preceded. This is
done only in the argument list. When using the variable
within the procedure, the colon is not used .

Functions
Type of Functions
Numeric
File-related
Date
String
Miscellaneous Functions

Numeric Functions
Numeric functions.

These are helpful when you need to perform


complex calculations in your program.
abs
Returns the absolute value of num_value. This
function returns a value of the same type as
num_value. num_value can be decimal, float, or
integer literal, column, variable, or expression.
Example: let #dabsvar = abs(#dvar)
Other examples: Exp, floor, power, round,
sign, sqrt.

File-related Functions
These are helpful in performing file maintenance
These functions returns either a zero (0) to indicate success
or the value returned from the operating system to indicate
an error.
Delete
Deletes the file filename.
Syntax: stat_var = delete(filename)
filename = text literal, column, variable, or expression.
stat_var = decimal, float, or integer variable.
Example: let #fstatus = delete($filename)
Exists
Determines if the file, filename, exists.
Syntax: stat_var = exists(filename)
Example: let #fstatus = exists($filename)

Rename
Renames old_filename to new_filename.
Syntax: stat_var = rename(old_filename,
new_filename)
Example: let #fstatus =
rename($old_filename, $new_filename)

Date Functions
dateadd
Returns a date after adding (or subtracting) the specified units to
the date_value.
Example: let $date = dateadd($startdate, day, 7.5)
datedif
Returns the difference between the specified dates expressed in
units_value. The function returns a float value.
Syntax:
dst_var = datediff(date1_value, date2_value, units_value)
Example: let #diff = datediff($date1, $date2, hour)
datenow
Returns the current local date and time from the client machine.
Syntax:
dst_var = datenow()
Example: let $date = datenow()

datetostr
Converts the date date_value to a string in the format format_mask.
Syntax: dst_var = datetostr(date_value [, format_mask])
date_value = date variable or expression.
format_mask = text literal, column, variable, or expression.
Example:
let $formdate = datetostr($date, Day Mon DD, YYYY)
let $localedate = datetostr($date, DATE)
strtodate
Converts the string source_value in the format format_mask to a
date type.
Syntax: dst_var = strtodate(source_value [, format_mask])
source_value = text literal, column, variable, or expression.
format_mask = text literal, column, variable, or expression which
describes the exact format of the source_value.
dst_var = date variable.
Example: let $date = strtodate($str_date, Mon DD, YYYY)
let $date = strtodate($str_date, DATE)

STRING FUNCTIONS
Concatenation :
Let command is one of the most commonly used.
Eg: let $address=$city || , ||$state||,||zip

String command : Allows you to concatenate two or more


fields using common delimiter.
Eg: string $city $state $zip by , into $address

Extraction
Many methods to extract a portion of a string. Most common
are:
Substr function Allows you to extract starting at a specific
position and for a set of number of characters.
Eg: let $city=substr($address,1,2)
unstring function divides the string into two or more text
using a specified delimiter
Eg: unstring address by , into $city $state $zip

Other commonly used formatting commands:


Edit
Sets format for the variable
Let $phone=edit($phone, (xxx) xxx-xxxx) !
Formatting a phone no.

Upper/Lower
Sets the source to uppercase/lowercase and store in
target
Let $name=upper($name)
Let $name=lower($name)

To_char
Converts an integer variable to a string variable
Let $total=to_char(#total)

isblank
Returns a value of one (1) if source_val is an empty string, null string, or
composed entirely of whitespace characters; otherwise, returns a value
of zero(0).
Syntax: dst_var = isblank(source_value)
source_value = date or text literal, column, variable, or expression.
dst_var = decimal, float, or integer variable.
Example: let #blank = isblank(&description)
isnull
Returns a value of one (1) if source_val is null; otherwise, returns a value
of zero (0).
Syntax: dst_var = isnull(source_value)
source_value = date or text literal, column, variable, or expression.
dst_var = decimal, float, or integer variable.
Example: let #null = isnull($date)

String functions
length Returns the number of characters in source_value.
Syntax: dst_var = length(source_value)
source_value = date or text literal, column, variable, or
expression.
dst_var = decimal, float, or integer variable.
Example: let #length = length(&description)
lower Converts the contents of source_value to lowercase
and returns the result.
Syntax: dst_var = lower(source_value)
source_value = date or text literal, column, variable, or
expression.
dst_var = text variable.
Example: let $lower = lower(&description)

String Fucntions
lpad

Pads the source_value on the left to a length of length_value using pad_value


and returns the result.
Syntax: dst_var = lpad(source_value, length_value, pad_value)
source_value = date or text literal, column, variable, or expression.
length_value = decimal, float, or integer literal, column, variable, or
expression. The value is always converted to integer.
pad_value = text literal, column, variable, or expression.
dst_var = text variable.
Example: let $lpad = lpad($notice, 25, .)

ltrim

Trims characters in source_value from the left until a character is not in


set_value and returns the result.
Syntax: dst_var = ltrim(source_value, set_value)
source_value = date or text literal, column, variable, or expression.
set_value = text literal, column, variable, or expression.
dst_var = text variable.
Example: let $ltrim = ltrim(&description, .)

substr
Extracts the specified portion source_value. The extraction begins at
offset_value (origin is 1) for a length of length_value characters.
Syntax:
dst_var = substr(source_value, offset_value, length_value)
source_value = date or text literal, column, variable, or expression.
offset_value = decimal, float, or integer literal, column, variable, or
expression. The value is always converted to integer.
length_value = decimal, float, or integer literal, column, variable, or
expression. The value is always converted to integer.
dst_var = text variable.
Example: let $piece = substr(&record, 10, #len)
unstring function divides the string into two or more text using a
specified delimiter
Eg: unstring address by , into $city $state $zip

to_char
Converts source_value to a string, using maximum
precision.

Syntax:

dst_var = to_char(source_value)
source_value = decimal, float, or integer literal, column, variable,
or expression.
dst_var = text variable.
Example: let $string = to_char(#number)

to_number
Converts source_value to a number. This function returns a
float value.
Syntax: dst_var = to_number(source_value)
source_value = decimal, float, or integer literal, column,
variable, or expression.
dst_var = decimal, float, or integer variable.
Example: let #value = to_number($number)

upper
Converts the contents of source_value to uppercase and returns the result.
Syntax:
dst_var = upper(source_value)
source_value = date or text literal, column, variable, or expression.
dst_var = text variable.
Example: let $upper = upper(&description)

nvl
Returns y_value if the x_value is null otherwise returns x_value.
If x_value is numeric, y_value must also be numeric; otherwise, date and
textual arguments are compatible.
In any case, the x_value determines the type of expression returned. The return
value of the function depends on which value is returned.
Syntax:
dst_var = nvl(x_value, y_value)
x_value = Any literal, column, variable, or expression.
y_value = Any literal, column, variable, or expression.
dst_var = Any variable.
Example: let $city = nvl(&city, -- not city --)

Control Statements
Do
- Used to call Procedures.
If - conditional execution
Evaluate - Case/switch structure
While - Looping construct
Break - Exit from evaluate/while command
Exit-Select - exit from a select paragraph
Goto - Branch to a label
Stop - Halt the program abruptly

DO

DO is used to call or invoke a procedure.


Syntax:
Do procedure_name [(param_list)]

Page commands
New-page
This command sends the current page buffer to the output devise and
begins a new one.
A new-page will automatically occur if page overflow occurs.
----------------------------------------------------------------------------------------------------Example:
Begin-select
A.COURSE (+1, 1, 5)
if #current-line > 60
new-page
end-if
End-select

PAGE-NUMBER
This function places the current page number on the
page.

LAST-PAGE
This function places the last page number on the page.
Using LAST-PAGE causes SQR to delay printing until the
last page has been processed so that the number of the
last page is known.
-----------------------------------------------------------------------------Begin-footing 1
PAGE-NUMBER (1,35) Page
LAST-PAGE () of .
End-footing
Output will be like Page 12 of 25.

ON-BREAK This option causes the specified action to


take place when the value of a certain output field
changes This can be used for both explicit and implicit
printing.
Purpose:
1) To reduce the data redundancy and to improve the
performance.
2) A very powerful SQR feature that allows you to
control the data manipulation.

Used specifically to:


(a)Suppress duplicates
(b)Product subtotals
(c)Produce sub-headings
(d)Control the flow of the SQR

Different Qualifiers used in On-Break Option:


1) PRINT Specifies when the break field will
be printed.
i. Change: The break field will be printed only
when the value is changed. This is a default
change.
ii. Always: The break field will be printed for
each detail group.
iii.Change/Top Page : The break field will be
printed when its value is changed plus and
top of each page.
iv.Never: The break field will not be printed.

2.SKIPLINES Specifies how many lines to skip when


the value changes.

3.PROCEDURE - Specifies the procedure to be invoked


when the value changes. This qualifier cannot be used
with either the AFTER or BEFORE qualifiers.

4.AFTER and BEFORE procedures Specifies

procedures to invoke either after or before the value


changes. If no rows are fetched, neither procedure is
executed. The AFTER and BEFORE can be used only within
a SELECT paragraph.

5.SAVE Indicates a string variable where the


previous value of a break field will be stored.

6.LEVEL Specifies the level of the break for reports


containing multiple breaks.

Example:
begin-select
state (,1) on-break skiplines=1
city (,7)
name (,24)
phone (,55)
position (+1) ! Advance to the next line
from customers
order by state, city, name
end-select

The output is shown below.

Break Processing with Enhancements


begin-procedure state_tot
print ' Total Customers for State: ' (+1,1)
print #state_total () edit 999,999
position (+3,1)
let #cust_total = #cust_total +
#state_total
let #state_total = 0
end-procedure

begin-select
state (,1) on-break print=change/top-page
after=state_tot
name (,11)
addr1 (+1,11)
city (+1,11)
phone (,+2) edit (xxx)bxxx-xxxx
next-listing skiplines=1 need=4
let #state_total = #state_total + 1
from customers
order by state, name
end-select
if #cust_total > 0
print ' Total Customers: ' (+3,1)
print #cust_total () edit 999,999
end-if

The output is shown below.

Advanced Printing in SQR


Sample code
begin-program
do list_customers
end-program
begin-procedure list_customers
begin-select
state () on-break before=state_heading print=never level=1
city (,1) on-break level=2
name (,18)
phone (,49)
position (+1) ! Advance to the next line
from customers
order by state, city, name
end-select
end-procedure
begin-procedure state_heading
print 'State: ' (+1,1) bold ! Advance a line and print 'State:'
print &state (,8) bold
! Print the state column here
print 'City' (+1,1) bold ! Advance a line and print 'City'
print 'Name' (,18) bold
print 'Phone' (,49) bold
print '-' (+1,1,58) fill
position (+1)
! Advance to the next line
end-procedure

Passing input to the Program

We use ASK and INPUT commands to pass inputs to the


SQR program
ASK: Ask is a compile time command. This can be issued
only in setup section. No field formatting is possible.
Syntax: Begin-Setup
ASK BU Enter Business Unit
End-Setup
INPUT : Input Command can be used in all the sections
other than the setup section. It is a runtime command.
Syntax: Begin-Program
Input $BU Maxlen =5 Enter BU
End-Program

Lookup Tables
Load lookup is a array which can be used to retrieve information from multiple tables
and improve the program performance. It can be used to specify the table joins.
Load lookup command creates an internal memory array and populates this array
with keys and corresponding column values from the specified tables.
This can be used either in setup section or in any procedure section.
Load lookup retrieves two fields from the database:
1)Key Field
2)Return Value.
----------------------------------------------------------------------------------------------------Syntax: Load-Lookup
name={lookup name}
table={database name}
key={key value}
return_value={return key}
where={where criteria}
Name=Name of the lookup table.
Table=The name of the database table/view on which the lookup is created
Key=The key field of the table that is to be used to lookup on data in that table

Limitations of Load Lookup


If report is small, number of rows to
join is small, a lookup table is NOT
the way to go.
Load lookup loads up the entire
table in memory, applies the criteria
on the where clause while returning
data.

ARRAY
Array is a collection of similar groups of fields in the
program memory where in each group can be referred
to by its relative position number in the array.
Arrays are created during the compile stage, before
the program is executed.
CREATE-ARRAY
NAME=array_name
SIZE=nn
{FIELD=name.type[:occurs]
[={init_value_txt_lit | num_lit}]}
NAME Name of the array
SIZE No of elements in array
FIELD Each field or column in the array
Type char,interger,date etc

Example
CREATE-ARRAY
NAME=emps
SIZE=10
FIELD=EMPLID:char:11
FIELD=SALARY:number:12
FILED=PHONE:char:14
Maximum no of arrays in a program is 128
Maximum no of fields per array is 200

The following commands work with arrays

Create-Array
Clear-Array
Get
Put
Array-Add
Array-Subtract
Array-Multiply
Array-Divide

SQC:
The frequently used procedures can be grouped by their functionality
and saved as .SQC file, which can be used in any SQR program.
SQC is likely a library of frequently used procedures. There are
approximately 700 PeopleSoft built in SQC.
#include setenv.sqc Sets SQL platform specific environments
#include setup31.sqc Setup section for Portrait mode
#include setup32.sqc Setup section for Landscape mode
#include reset.sqc
Reset printer Prints End of Report in last
page
#include curdttm.sqc Current date and time
#include datetime.sqc Routines for Date and time formatting
#include number.sqc Routine to format numbers
#include prcsapi.sqc Update process request API
#include prcsdef.sqc Update process request variable declaration
#include setup32.sqc - To print landscape and portrait form.
SQRW:
Pshome\bin\sqr\MSS\BINW\sqrw.exe

Load Look Up

Array

Size can be increased dynamically.

Size cant be increased dynamically

Load Look Up supports only


character.

Array supports any data type.

By using single command we can


create the buffer and populate data.

We have to use different commands


to create and populate the data in to
Array.

We can populate data only from one


table.

We can insert tour own values also.

Load-Lookup have only two fields.

Arrays we have n no. of fields.

Multiple Reports
Depending on the reports we generate we use no. of
layouts.
We can direct each report to different printer
Multiple reports can be generated using a single SQR
program with the help of DECLARE-REPORT and USEREPORT commands.
By using USE-REPORT command we have to bipass
the data in to particular reports.
We have to use the FOR-REPORT command foe
different headings and Footings.
DECLARE-REPORT report_name
LAYOUT=layout_name
PRINTER-TYPE=printer_type
END-DECLARE

Examples
declare-layout customer_layout
paper-size=(a4)
left-margin=12.7 mm
right-margin=25.4 mm
end-declare
declare-layout summary_layout
paper-size=(14, 11)
left-margin=1
right-margin=1
end-declare
declare-report customer_detail
layout=customer_layout
printer-type=postscript
end-declare
declare-report customer_summary
layout=summary_layout
printer-type=postscript
end-declare

The DECLARE-REPORT and DECLARE-LAYOUT commands


must be issued in the SETUP section.
The DECLARE-REPORT command can be used to declare one
or more reports to be produced in the application.
Reports can share the same layout and the same printer
declarations or each report can use its own layout or printer
definitions if the report has unique characteristics.
SQR allows you to specify the Heading and Footing sections of
each report using the For-Report argument in the Begin-Heading
and Begin-Footing commands

Eg: begin-footing 2 for-reports=(customer, summary)


print Company Confidential (1,1,0) center
page-number (2,37,0)
end-footing

USE-REPORT report_name
For programs with multiple reports, allows the user to switch
between reports.
All subsequent PRINT commands will write to the same report
until the next USE-REPORT command encounters.
The USE-REPORT command can be used to specify to which
report file(s) the subsequent report output is to be written. An
application can contain several USEREPORT statements to control
several reports.
Examples
use-report customer_detail
use-printer-type PostScript
print (1, 1) Customer Name:
print () $customer_name

INTERFACING:
You can use sequential files to
Import data from other systems into your database
tables.
Unload data from your database tables into sequential
files, and use the files as interfaces to external systems.
Sort your data using the operating system commands
or utilities.
Input/Output Commands:

OPEN - Opening a file


READ - Reading from a file
WRITE - Writing to a file
CLOSE - Closing a file

Opening a file :
Before accessing a file, it must be opened.
OPEN {filename} AS {num} {FOR-READING | FOR-WRITING
| FOR-APPEND} {RECORD=length_num[:FIXED | :VARY]}
{STATUS=num_var}
LET $filename='C:\USER\SQR\deductions.txt'
OPEN $filename AS 1 FOR-READING RECORD=80
STATUS=#file1_status
#file1_status=0 Successfully opened

Reading a File:
READ {file_number} INTO {any_var:length}
[STATUS=read_status_num_var]
READ 1 INTO $Input_Record:80
READ 1 INTO $last_name:20 $first_name:10 $address:50
#end-file End of File
SQR internal variable #end-file is set to 1 when there are no more
records to read

Writing a File:
WRITE {file_number} FROM {text_var | num_var |
date_var} [STATUS=write_staus_num_var]
WRITE 1 FROM $Record:80 STATUS=#write_stat
WRITE 2 FROM $last_name:20 , $first_name:10 ,
$address:50
Closing a File: CLOSE 1

OUT-BOUND
BEGIN-PROGRAM
Let $writeFile = C:\temp\TEST_FILE.txt
Open $writeFile AS 1 for-Writing Record =100 STATUS =#fileStat
IF #fileStat ! =0
PRINT ERROR IN OPENING FILE (2,1)
ELSE
DO WRITE-DATA
CLOSE 1
END-IF
END-PROGRAM
BEGIN-PROGRAM WRITE-DATA
BEGIN-SELECT
EMPLID
DEPTID
NAME
WRITE 1 FROM &DEPITD : 6 &EMPLID :11 &NAME :50
FROM PS_EMPLOYMENT
END-SELECT
END-PROCEDURE

INBOUND:
BEGIN-PROGRAM
Let $writeFile = C:\temp\TEST_FILE.txt
Open $writeFile AS 1 for-Writing Record =100 STATUS =#fileStat
IF #fileStat ! =0
PRINT ERROR IN OPENING FILE (2,1)
ELSE
WHILE 1
READ 1 into $line:40
unstring $line by , into $deptid $emplid $name
do insertion
If #end-file
BREAK
END-IF
END-WHILE
END-IF
CLOSE 1
END-PROGRAM
BEGIN-PROCEDURE INSERTION
BEGIN-SQL
INSERT INTO PS_TEST
(DEPTID,EMPLID,NAME)
VALUES ($DEPTID, $EMPLID , $NAME)
END-SQL
END-PROCEDURE

Debugging SQR:
Display statement
Show statement
#Debug command and Command line
flags

ERROR HANDLING
Compile Stage:
Begin-SQL ON-ERROR
Skip/warn/Stop
Execution Stage:
Begin-Select ON-ERROR Procedure
Name
Begin-SQL ON-ERROR Procedure
Name
-O <path> : Log file.log Error or
Success.
-E <path> : Error File.err Error &

PeopleSoft Process Scheduler


Designed to enable you to initiate online/background (also
called batch) process requests from the PeopleSoft Internet
Architecture (PIA) to run on the process server.
Jobs can be scheduled to run on any date or time internal
by the minute.
Recurring jobs can be scheduled to run automatically at
specific intervals you designate.
Within PeopleSoft, the following SQR processes are
supported.
SQR Process
SQR Report

Steps to add a SQR Process


Design / create new project
Select fields for user input
Determine Run control record
Build the record
Determine the run control page
Place the page on a component
Register the component
Add a process definition
Grant access to the process group
Test !!

SQR Process through PIA.


To make SQR API aware:
Use STDAPI.sqc
Procedures:
Do STDAPI-INIT
Do Main
Do STDAPI-TERM
Use SETENV.sqc
$prcs_oprid
$prcs_run_cntl_id

DYNAMIC SQR:
Where the substitution variable is resolved during
runtime, you can replace the entire where clause as
substitution variable and still it is called static SQL.
Eg:
Let $Where_C=Where A.COURSE_DATE=||
$Course_Dt
Begin-Select
A.COURSE
A.DESCR
FROM PS_TRAINING A
[$where_C]
End-Select

Compile Stage
All #Include external source file (SQC) are inserted into
the source.
All #commands are evaluated. The #DEFINE text
substitution variables are placed into the program
source.
The SETUP section is processed, including allocation
and population of memory arrays created by the LoadLookup and Array commands.
Work buffers are allocated.
Optimization of the SQL data access path is
determined.
Syntax of SQR source program is checked.
Execution Stage
Processes data for the Body section
Processes HEADING section
Processes FOOTING section
Writes entire page buffer to file.

SQR & PeopleSoft


Process Request Parameters

SQR Command line


Flags & Arguments

Printer

Process Scheduler

SQR Program

Flat File

Process Monitor
Program Run Status
Information

Program Run Status


Information

SQR can be run in 2 ways.


1. In windows
2. Through process scheduler for People Soft Applications.

Command Line Flags:


-I -- specifies the list of directories that SQR will search when
processing the #include directive if the include file does not exist in
the current directory and no path was specified for the file.
-o -- directs the log messages to the specified file.
-f -- location for the output file.
-keep This flag will allow to create SPF output in addition to LIS
output.
-zif sets the full path and name of the SQR initialization file
PSSQR.INI
-cb forces the use of communication box.
-ziv Creates a .spf file and invokes the SQR viewer to display the file.
There are additional SQR parameters also(refer SQR users guide)

Different Types of Files in SQR:


.SQR = Source Code File.
.LIS = List File / Output File.
.SPF = Portable Format File.
.SQC = Function library.
.SQT = Run Time File.
.ERR - Only when error occurs.
.LOG Errors/ Success.
.CSV , .XML , .DAT Output files.

Types of Reports:
Tabular Report -: Getting Data from single Table.
Master Detail Report : Used to get data from
more than one table.
Form Report: Special kind of report like payslip
for each & every row of data in the table we
have a new page.
Mailing Lables: Effective use paper space.
Letters & Documents: Used for the same.
Cross Tabular Reports : Used for calculations in
row wise as well as in column wise.
Graphical Reports: Like bar charts, PIE diagrams
etc..

Exercise - 1
1)Create a table (Organisation, Department id, Emp id,
name, Emp.type, Base Salary, HRA, Allowances, Over
time)*
2)Create a fixed length record file with about 20 rows of data
for the above table.
3)Write a sqr program that would read through your file and
insert into the table you created in step 1
Exercise 2
4)Read data from the above table
5)Write it out a salary report (calculating the total pay), by
emp.type. i.e., first all permanent employees then
contractors.
6)For each organisation/department change, the report
should be printed on a fresh page.
7)Also, create a comma separated file of all contractors

Thanks for
Being Patience

Das könnte Ihnen auch gefallen