Вы находитесь на странице: 1из 28

1. What is SQR? 2. How to Execute SQR programs 3. Create and Execute basic SQR Reports 4.

Define SQR Batch and Interface Processes (Inbound and Outbound) 5. Create and Execute Batch, Inbound and Outbound Interfaces. 6. How to create a SQR process and run it using Process Scheduler.

1. SQR-Structure Query Reporting


Basic structure of a SQR program

D:\J U\Pravat\ Personal\PeopleSoftRelated\SQR_Shell

2. How to Execute SQR programs


Execution of SQR from command window 1. By invoking the sqrw.exe directly.

2. By creating report shortcuts using sqrw.exe. Put the following command (change it as per your settings) into the Target box of the property sheet of sqrw.exe. P:\psoft8\HR88ORA\bin\sqr\ORA\BINW\sqrw.exe C:\Pravat\ELTPTrngJuly2006\inbound.sqr sysadm/sysadm@HR88T844 -oc:\temp\sqr.log -fc:\TEMP\ -iC:\Pravat\ELTPTrngJuly2006\;P:\Psoft8\HR88ORA\sqr\ -ZIFP:\psoft8\HR88ORA\sqr\pssqr.ini

3. By using other editors (UltraEdit) P:\psoft8\HR88ORA\bin\sqr\ORA\BINW\sqrw.exe %F sysadm/sysadm@hr88t844 -iC:\GM-SSN\sqc\ -fc:\temp\ -ZIFP:\psoft8\HR88ORA\sqr\pssqr.ini -oC:\GM-SSN\sqr.log -ziv -keep -EH_PDF -PRINTER:EP %F Execute the current window -f{file} output file location -ZIF{file} Sets the full path and name of the SQR initialization file, sqr.ini. -ZIV Invokes the SPF Viewer after generating the program.spf file. This flag implicitly invokes the -KEEP flag to create program.spf. In the case of multiple output files, only the first report file is passed to the viewer. -KEEP SQR Print and SQR Viewer can print this .spf file to different printers. -EH_PDF Associates a PDF icon with {report}.pdf in the navigation bar. This flag is applicable only when you specify the -PRINTER:EH or -PRINTER:EP flag. -PRINTER:EP EP: Enhanced HTML or PDF For more info refer to: URL: http://9.182.150.41:6760/PSOL/htmldoc A very basic SQR program

D:\Pravat\ ELTPTrngJ uly2006\Exam ple 1.SQR

3. Create and Execute basic SQR Reports


Simple Report

C:\Pravat\ELTP Trng J uly 2006\Report1.SQR

DECLARE-LAYOUT SQR maps its line and column positions on the page by using a grid determined by the LINE-HEIGHT and CHAR-WIDTH arguments. That is, SQR calculates the number of columns per row by dividing the LINE-WIDTH by the CHAR-WIDTH and calculates the number of lines by dividing the PAGE-DEPTH by the LINE-HEIGHT DECLARE-REPORT Issue the DECLARE-REPORT in the SETUP section. Page-size

Break Report A break is a change in the value of a column or variable. Records with the same value for example, records with the same value for statelogically belong to a group. When a break occurs, a new group begins. Break Report is used to:Add white space to reports. Avoid printing redundant data. Perform conditional processing on variables that change. Print subtotals. Skipping lines between groups

skiplines=n Multiple Breaks (Nested Break) When you have multiple breaks, you must arrange them in a hierarchy by using the LEVEL key word. This argument numbers breaks by level and specifies that the columns are printed in order of increasing break levels on-break level=1 on-break level=2

C:\Pravat\ ELTPTrngJ uly2006\Break.SQR

Page Breaks and Calculating Subtotals and Totals

C:\Pravat\ ELTPTrngJ uly2006\Break1.SQR

If a page break occurs within a group, you may want to reprint headings and the value of the break column at the top of the new page. To control the printing of the value, use PRINT=CHANGE/TOP-PAGE. With this qualifier, the value of the ON-BREAK column is printed when it changes and after every page break. In this example, the value of state is printed not only when it changes, but whenever the report starts a new page.

Setting Break Procedures with BEFORE and AFTER Call of procedures before and after each break on a column.
begin-select emplid (,1) on-break before=empl_name after=empl_count Understanding the Order of Events

You can define a hierarchy of break columns by using the LEVEL qualifier of ONBREAK. When a break occurs at one level (say LEVEL 1), it also forces breaks on variables with higher LEVEL (say LEVEL 2) qualifiers. The following select paragraph has breaks on three levels: begin-select state (,1) on-break level=1 city (,7) on-break level=2 zip (,45) on-break level=3 from customers order by state, city, zip end-select after=state_tot skiplines=2 after=city_tot skiplines=1 after=zip_tot

The breaks are processed as follows: 1. When zip breaks, the city_tot procedure is run. 2. When city breaks, first the zip_tot procedure is run, then the city_tot procedure is run, and one line is skipped (SKIPLINES=1). Both city and zip are printed in the next record. 3. When state breaks, the zip_tot, city_tot, and state_tot procedures are processed in that order. One line is skipped after the city_tot procedure is run, and two lines are skipped after the state_tot procedure is run. All three columns, state, city, and zip, are printed in the next record.

Order of BEFORE AND AFTER procedure processing

1. Process BEFORE procedures. BEFORE procedures are processed in ascending order by LEVEL before the first row of the query is retrieved. If no data is selected, BEFORE procedures are not run. 2. Select the first row of data. 3. Select subsequent rows of data. Processing of the select paragraph continues. When a break occurs on any column, it also initiates breaks on columns at the same or higher levels. Events occur in the following order: a. AFTER procedures are processed in descending order from the highest level to the level of the current ON-BREAK column. b. SAVE variables are set with the value of the previous ON-BREAK column. c. BEFORE procedures are processed in ascending order from the current level to the highest level.

d. If SKIPLINES was specified, the current line position is advanced. e. The value of the new group is printed (unless PRINT=NEVER is specified). 4. Process AFTER procedures. After the select paragraph is complete, if any rows were selected, AFTER procedures are processed in descending order by LEVEL.

Saving a Value When a Break Occurs Say you want to print the employee name and the count for each employee. Printing the corresponding name of the employee will not work because employee ID value will have changed by the time the AFTER procedure is called. The solution is to save the previous break value in a string variable. To do this, use the SAVE qualifier of ON-BREAK. For example:
begin-select emplid (,1) on-break after=tot_employees save=$old_emplid

You can then print the name corresponding to the =$old_emplid in the tot_employees procedure

Passing parameters, User input

C:\Pravat\ELTP Trng C:\Pravat\ELTP Trng J uly 2006\PassingParam eters.sqr J uly 2006\UserInput.sqr

4. Define SQR Batch and Interface Processes (Inbound and Outbound) Batch Process:
Batch processes reads database tables and do the processing on database tables. No file interaction is there.

Interface Process:

Inbound Process (The process reads a data file and do the processing with the values it reads from the data file) Outbound Process (The process reads database tables and populated relevant data to a file)

5. Create and Execute Batch, Inbound and Outbound Interfaces.


Batch:

C:\Pravat\ ELTPTrngJ uly2006\Batch.sqr

Inbound:

C:\Pravat\ ELTPTrngJ uly2006\Inbound.sqr

Syntax
OPEN {filename_lit|_var|_col} AS {filenum_num_lit|_var|_col} {FOR-READING|FOR-WRITING|FOR-APPEND} {RECORD=length_num_lit[:FIXED|:FIXED_NOLF|:VARY]} [STATUS=num_var]

Description Opens an operating system file for reading or writing. After a file is opened, it remains open until explicitly closed by the CLOSE command. A maximum of 256 files can be opened at one time. Parameters {filename_lit | _var | Specifies the file name. The file name can be literal, variable, or column. This _col} makes it easy to prompt for a file name at runtime.

{filenum_num_lit | Specifies a number that identifies the file in the application. All file commands _var | _col} use the file number to reference the file. File numbers can be numeric variables and literals. The number can be any positive integer less than 64,000. FOR-READING FOR-WRITING When a file is opened for reading, SQR procures all data sequentially. SQR does not allow for random access of information. When a file is opened for writing, a new file is created. If a file of the same name already exists, it can be overwritten (this depends on the operating system). When a file is opened in append mode, the current file contents are preserved. All data written is placed at the end of the file. SQR creates the file if one does not already exist. For existing files, make sure the attributes used are the same as those used when the file was created. Failure to do this can produce unpredictable results. For the VARY file type, this is the maximum size for a record. For the FIXED file type, this is the size of each record without the line terminator. For the FIXED_NOLF file type, this is the size of each record. This file type assumes that all records contained within the file are the same length. Terminate each record by a line terminator (system dependent). You can use this file type when writing or reading binary data. This file type specifies that all records contained within the file are the same length with no line terminators. When writing records, SQR pads short records with blank characters to ensure each record is the same length. This file type can be used when writing or reading binary data. This file type specifies that the records can be of varying length. Each record is terminated by a line terminator (system-dependent). Only records containing display characters (no binary data) can be used safely. When reading records, any data beyond the maximum length specified is ignored. This is the default file type. Sets the numeric variable to zero if the OPEN succeeds and to -1 if it fails. Without the STATUS argument, a failure on OPEN causes SQR to halt. By using a STATUS variable, you can control what processing should occur when a file cannot be opened.

FOR-APPEND

RECORD

FIXED

FIXED_NOLF

VARY

STATUS

Outbound

C:\Pravat\ELTP Trng J uly 2006\Outbound.sqr

6. How to create a SQR process and run it using Process Scheduler (Online). App designer Part
1. Complete the SQR code. 2. Create a new project. Add all the following definitions into the project 3. Create new runcontrol record (others fields along with OPRID and RUN_CNTL_ID as keys), save and build it 4. Create a new page 5. Insert the PRCSRUNCNTL_SBP subpage in to the new page created in step 3 6. Include the desired fields (here start_date and end_date) from the record (no need to include the OPRID and RUN_CNTL_ID fields) to the new page. Save the page 7. Create a new component and include the page, mention the search record (here it is PRCSRUNCNTL). Save the component 8. Create a new menu and create new bar and menu item. Attach the component under the new menu item. Save the menu

Online Part Create a folder and add the content reference to it.

Click on Add Folder

Click on Save
Note: If you dont see the folder created in the navigation panel, once log-off and again login.

Click on ELTP SQR Process

Click on Add Content Reference

Click on Save

Create a Permission List which will have access to component and pages.

Click on Add

Click on Edit Components

Click on Edit Pages

Check Authorized?, Add and Update/Display and then click on OK

Again Check OK

Click on Save

Create a Role and assign the above Permission List to it. Assign the role to the concerned user (here HR89USER)

Click on Add

Click on the Permission List Tab

Type ELTP_JUL_KOL_06 as the permission list name and click on the look up button

Select the ELTP_JUL_KOL_06 link

Click on Save Navigate to the following location

Type HR89USER and click on the Search button

Click on the Roles tab

Click on any of the + button

Type ELTP_JUL_KOL_06 as the permission list name and click on the look up button

Select the ELTP_JUL_KOL_06 link

Click on the Save button

Define the SQR Process


Navigate to the following location

Click on Add

Put any description you want to put in the Description field. Click on Process Definition Options

Select the Component and Process Groups as shown above, and click theSave button.

Testing

Navigate to the following location

Add a new Run Control ID and press Add button

Put some value for the Start and End dates. Click on Run

Select the Server Name as PSNT (for UNIX machine it is PSUNX). Check the process name is correct or not. Click on OK

Note the Process Instance Number (here it is 364) Click on Process Monitor Link

On successful completion the Run Status should be Success and the Distribution Status should be Posted. If error occurs Run Status should be Error and the Distribution Status should be Posted. If the Run Status/ Distribution Status are different press on the Refresh button. No click on the Details link.

Click on View Log/Trace

See the contents of the files ONLINE_364.PDF (Output file) ONLINE_364.out (log file, all the display and show statements go into this file) SQR_ONLINE_364.log (Parameter file)

Proj name: ELTP_SQR_06

C:\Pravat\ELTP Trng J uly 2006\Online.SQR