Beruflich Dokumente
Kultur Dokumente
Supports PeopleCode
Doesn’t Support.
Commands.
A.EMPLID (+1, 1)
BEGIN-FOOTING 3
Footing Section Let $Line_NBR_Footing = 'Line Number in Footing Section: '
42. What is the use of Footing Section? CONCAT #Current-Line WITH $Line_NBR_Footing
Useful to create Page Footings. PRINT $Line_NBR_Footing (3,1)
The BEGIN-FOOTING command is followed by END-FOOTING
a number, which indicates the number of lines reserved for 'Line Number in Heading Section: ' 13
the Footing.
Srinivas – at 10th Line and 1st Column
43. What are the main Arguments we can pass thru
'Line Number in Program Section: ' 12
Footing Section?
'Line Number in Footing Section: ' 2
For-Reports: By default Footing Section will be applicable
to all the reports. By using the Declare-Report and For- Program Section
Report we can assign separate Footings for each report.
44. Can we use Paragraphs in Footing Section? 53. Is Program Section mandatory in every SQR?
No We can’t. Yes, every program should have Program Section. Otherwise
45. Can we use Show and Display commands in it will be called as SQC so we can’t run as standalone
Footing section? program.
Yes. We can use. 54. What is the use of Program Section?
46. Can we call Procedure Section in Footing It’s the mandatory Section useful to identify the Beginning
Section? and Ending of the Program.
Yes. 55. What is the other name of Program Section
47. How many areas can a page divided into? In earlier SQR versions the Program Section used to call as
Report section.
A page can be subdivided into 3 logical areas.
56. Can we use Paragraphs in Program Section?
The Top area of the page is the Heading,
which is the place where we normally print the Report Document Paragraph can’t be allowed in Program Section.
Title and the Date. Other 2 Paragraphs Select and SQL are allowed.
The Bottom area of the page is the Footing, Procedure Section
which is the place where we normally print the Page
Numbers. 57. What is the use of Procedure Section?
The Middle part of the page is called the Useful to break the program into modules, So that we can
Body, which is the place where we print the Report Data. easily debug and maintain.
48. What is the use of the PAGE-NUMBER command? 58. Is Procedure Section mandatory?
The PAGE-NUMBER command prints the Current Page No. If the program logic is not complex we can write the
number. code in Begin-Program it self.
49. What is the use of the LAST-PAGE command? 59. Can we have multiple Procedure Sections in a
The LAST-PAGE command prints the Last Page Number. single SQR?
50. Code to print Page Number? Yes, but each procedure should be with unique name.
PAGE-NUMBER (1,1) 'PAGE ' 60. Can we use Paragraphs in Procedure Section?
LAST-PAGE () ' OF ' All the 3 Paragraphs are allowed in Procedure Section.
Print Command is not necessary for these 2 Commands. We 61. What are the commands used to call a
can also get the page number thru #page-count command Procedure?
but print command is required for this. DO is the command to call the procedure.
BEGIN-HEADING 1
And thru On-Error, We can specify the
PRINT 'VALUE OF I #PAGE-COUNT PAGE-NUMBER' (1,1) Procedure Name.
END-HEADING And thru On-Break. Before and After we can
BEGIN-PROGRAM
specify the Procedure Name.
LET #I = 1 By declaring the Procedures thru Declare-
WHILE #I <= 200 Procedure.
PRINT #I (,1) edit 999 BEFORE-REPROT, AFTER-REPROT, BEFORE-PAGE, AFTER-PAGE.
LET #I = #I + 1 62. How to declare Procedures?
PRINT #PAGE-COUNT (,+15) edit 9
BEGIN-SETUP
PAGE-NUMBER (,+12) 'PAGE '
DECLARE-PROCEDURE
LAST-PAGE () ' OF '
FOR-REPORTS = REPORT_NAME
POSITION (+1)
BEFORE-REPORT = PROCEDURE_NAME
END-WHILE
AFTER-REPORT = PROCEDURE_NAME
END-PROGRAM
BEFORE-PAGE = PROCEDURE_NAME
51. Assume there is no data to be printed in AFTER-PAGE = PROCEDURE_NAME
Procedure or Program section then will be heading END-DECLARE
and footing sections get processed? END-SETUP
No, if there is no data to be printed in Procedure and 63. How many types of Procedures can SQR
Program Sections then Heading and Footing sections will not Supports?
be executed.
Local and Global.
52. What would be the output to the below Program? 64. What is the by default scope set to Procedures?
BEGIN-HEADING 2 By defaults all the Procedures are Global which are visible
Let $Line_NBR_Heading = 'Line Number in Heading Section: ' through out the program.
CONCAT #Current-Line WITH $Line_NBR_Heading 65. How to make the Procedures as Local?
PRINT $Line_NBR_Heading (2,1) We have to explicitly declare it as local using the LOCAL
END-HEADING keyword.
BEGIN-PROGRAM 66. Assume a Select Query is defined in a Local
PRINT 'Srinivas – at 10th Line and 1st Column' (10,1) Procedure. Can we access all selected Columns in
other procedures? defined.’
No, When a query is defined in a Local Procedure, all And No Commas required between the Columns. If we use
selected column names are considered as Local and can't be also SQR will not give any error.
used in any other Procedures. Ex:
67. How to call Global Variables in Local Procedures? BEGIN-PROGRAM
To call Global Variables in Local Procedures we have to add BEGIN-SELECT LOOPS = 10
Process Scheduler
124. What's the Process to run SQR thru Process
Execution of SQR Scheduler?
114. How many ways we can run the SQR Program? Create SQR.
1. SQRW. Make it as API Aware by including all 3
Mandatory SQCs and two procedures STDAPI-INIT at the
2. Process Scheduler.
beginning, STDAPI-TERM at the ending of the program.
3. Command Line.
Place the SQR in SQR Directory mentioned in
4. Thru PeopleCode – Create Process Request. the Configuration Manager.
5. Call System Create Run Control Record / Page /
6. Push Button. Component if required.
Create New Process: Go to PeopleTools –
SQRW Process Scheduler – Process.
115. What are the Steps required to run SQR thru Specify the Run Control Component Name.
SQRW? Save.
Open SQRW executable file If required we can also give the Command
C:\PT8.45\bin\sqr\MSS\BINW\sqrw.exe Line Parameters in Override tab.
Specify the SQR Name. Navigate thru the Run Control Component –
You can see the attached SQR. Select and Run. 133. Is it required to Create a Process Definition to
125. How to pass Run Control Values while running run SQR thru CreateProcessRequest Function?
SQR thru Process Scheduler? Yes, We have to create a Process Definition otherwise it
Create Run Control Record. will throw an error stating that ‘An entry must be provided
in the process definition table before this process can be
Create Run Control Page by including Run
scheduled to run.’
Control Sub page ().
Create Run Control Component. Call System
Create Process Definition. And assign the Run
control Component Name. 134. Sample Programs about Call System?
126. What type of files will be generated when we run Create a SQR in C drive and name it as 2.SQR.
SQR thru Process Scheduler? BEGIN-PROGRAM
SHOW 'PROGRAM 2 STARTED'
Log file and Out File.
SHOW 'SRINIVAS'
127. What are the commands used to run SQR thru Create another SQR in C drive and name it as 1.SQR.
Command Line? BEGIN-PROGRAM
SHOW 'PROGRAM 1 STARTED'
We have to mention the
LET $CMD = 'C:\PT8.45\BIN\SQR\MSS\BINW\SQRW.EXE C:\2.SQR A/SA/SA'
SQRW executable file path , CALL SYSTEM USING $CMD #STATUS
SQR name with full path, SHOW 'PROGRAM 1 ENDED'
Database name, END-PROGRAM
UserID, Run 1.SQR thru SQRW, which calls the 2.SQR too.
Password,
Push Button
EX: C:\PT8.45\bin\sqr\MSS\BINW\sqrw.exe
c:\Program1.sqr HC/sa/sa –ZIV 135. Procedure to run SQR thru Push Button?
If required Command Line Flags. Insert a Push Button in page.
-F<Output File Path> Go to Push Button Properties, Select the Destination –
Process. Then Process Options will be enabled.
-S
Select Type as either SQR Process or SQR Report
128. Assume a Program Runs based on Run Control
Input Value. When you run the Same SQR thru Select the SQR name.
Command Line, How can we pass the Input Value? Navigate to the Particular Page in PIA.
Thru ASK and INPUT. Click on Push Button.
129. What steps needs to be followed in order to run 136. Can we run Application Engine Programs thru
the Same SQR Program which requires input values SQR?
thru Process Scheduler as well as SQRW?
! ADD 100 TO &COMPRATE ! This Statement will give an error as Column LET #LOCAL_NUMBER1 = 1
Variables are Read-Only, we can’t perform any operations. Move it to any user SHOW 'IN PROCEDURE1 - #LOCAL_NUMBER1: ' #LOCAL_NUMBER1
defined variables and perform any operations. END-PROCEDURE
Useful to mix the static text with the database values. OUTPUT:
155. Are SQR Variables Case Sensitive?
DEMO OF LOCAL/GLOBAL VARIABLES
No. $name is same as $NAME. IN PROCEDURE1 - #LOCAL_NUMBER1: 1.000000
And there are no restrictions on Variable name length. It IN PROCEDURE2 - #LOCAL_NUMBER2: 2.000000
can be of any length. IN PROCEDURE3 - #LOCAL_NUMBER3: 3.000000
IN PROCEDURE4 - #LOCAL_NUMBER4: 4.000000
156. What would be the default values assigned to
IN PROCEDURE4 - #LOCAL_NUMBER5: 5.000000
Numeric Variables?
IN PROCEDURE6 - #GLOBAL_NUMBER: 6.000000
Zero. IN PROCEDURE7 - #LOCAL_NUMBER1: 0.000000
157. What would be the default values assigned to IN PROCEDURE7 - #LOCAL_NUMBER2: 0.000000
String and Date Variables? IN PROCEDURE7 - #LOCAL_NUMBER3: 3.000000
NULL. IN PROCEDURE7 - #LOCAL_NUMBER4: 4.000000
158. How to pass an argument value back to its IN PROCEDURE7 - #LOCAL_NUMBER5: 0.000000
6. Unstring: Useful to copy some portion of a string 2. Rename – It rename the old file name with New
into one of more variables. file name and returns 0 when success otherwise returns non
Zero.
BEGIN-PROGRAM
LET $INPUT_DATA = 'SRINIVAS,55849,HEWITT,GURGAON,INDIA' Ex:
UNSTRING $INPUT_DATA BY ',' INTO $NAME $EMPLID $COMPANY $LOCATION $COUNTRY BEGIN-PROGRAM
SHOW 'NAME: ' $NAME !RETURNS SRINIVAS LET $FILE1 = 'C:\TEMP\IBM.TXT'
SHOW 'EMPL ID: '$EMPLID !RETURNS 55849 LET $FILE2 = 'C:\TEMP\CSC.TXT'
SHOW 'COMPANY: ' $COMPANY !RETURNS HEWITT LET #STATUS = RENAME($FILE1, $FILE2)
SHOW 'LOCATION: ' $LOCATION !RETURNS GURGAON SHOW #STATUS
SHOW 'COUNTRY: ' $COUNTRY !RETURNS INDIA END-PROGRAM
END-PROGRAM If no file Path mentioned then new file will be created in the
SQR Directory.
7. Uppercase: Converts a String variable to
Uppercase. 3. Exists – Returns 0 if the file exists in the specified
location otherwise returns non Zero.
LET $NAME = 'srinivas'
Ex:
UPPERCASE $NAME
BEGIN-PROGRAM
SHOW $NAME !Returns SRINIVAS
LET $FILE1 = 'C:\TEMP\IBM.TXT'
8. LowerCase: Converts a String variable to LET #STATUS = EXISTS($FILE1)
Lowercase. SHOW #STATUS
END-PROGRAM
LET $NAME = ‘SRINIVAS’
LOWERCASE $NAME
179. Sample Code to delete a file?
SHOW $NAME !Returns srinivas LET $FILE = C:\TEMP\TEMP.TXT
LET #FILE_EXISTS = EXISTS($FILE)
9. Encode: Encodes the value. Only values <001> to
IF #FILE_EXISTS = 0
<255> may be encoded.
SHOW 'DELETING EXISTING FILE (' $FILE ')....'
Ex: LET #DEL_FILE = DELETE($FILE)
IF #DEL_FILE != 0
183 is for Bullet
SHOW 'ERROR IN DELETING EXISTING DAT FILE ... '
124 is for Dash STOP QUIET
33 is for Exclamation. END-IF
END-IF
ENCODE '<183>SRINIVAS' INTO $NAME1 !RETURNS ·SRINIVAS
ENCODE '<33>SRINIVAS' INTO $NAME2 !RETURNS !SRINIVAS
Date Functions
173. Difference between Extract and Unstring/Let?
The EXTRACT command uses 0 as the first position. The 180. What are the Date Functions Available in SQR?
LET/SUBSTR command uses 1 as the first position. DateAdd, DateDiff, DateNow, DateToStr, StrToDate.
174. DATE-TIME: Gives the current Date and Time of Local 1. DateAdd: Returns the New Data after adding
System. Specified Units.
175. USE: Uses the mentioned database rather using the BEGIN-PROGRAM
215. About SKIPLINES Qualifier? IBM IND 01/01/2002 444 DDD 50000
IBM ROI 01/01/2000 555 EEE 30000
Specifies how many lines to skip when the value changes.
IBM ROI 01/01/2000 666 FFF 75000
216. About PROCEDURE Qualifier?
IBM ROI 01/01/2000 777 GGG 15000
Specifies the procedure to be invoked when the value
CSC USA 01/01/2000 888 HHH 20000
changes.
CSC USA 01/01/2001 888 HHH 25000
217. About AFTER / BEFORE Qualifiers?
CSC USA 01/01/2002 888 HHH 35000
CSC USA 01/01/2000 999 III 100000 234. SKIPLINES & ORDER BY
CSC IND 01/01/2000 123 JJJ 100000 BEGIN-SELECT
CSC IND 01/01/2001 123 JJJ 200000 COMPANY (,1) ON-BREAK SKIPLINES = 1
COUNTRY (,+5)
CSC IND 01/01/2002 123 JJJ 300000
PAY_END_DT (,+5)
IF EXISTS (SELECT 'X' FROM SYSOBJECTS WHERE TYPE = 'U' AND NAME = 'ABC') EMPLID (,+5)
DROP TABLE ABC; NAME (,+5)
CREATE TABLE ABC (COMPANY CHAR(5), COUNTRY CHAR(5), PAY_END_DT SALARY (,+5)
PSDATE, EMPLID CHAR(5), NAME CHAR(5), SALARY DECIMAL(7));
INSERT INTO ABC VALUES ('IBM','USA','01/01/2000','111','AAA',10500 ); POSITION (+1)
INSERT INTO ABC VALUES ('IBM','USA','01/01/2001','111','AAA',15000 ); FROM ABC ORDER BY PAY_END_DT
INSERT INTO ABC VALUES ('IBM','USA','01/01/2000','222','BBB',25000 ); END-SELECT
INSERT INTO ABC VALUES ('IBM','IND','01/01/2000','333','CCC',15000 );
INSERT INTO ABC VALUES ('IBM','IND','01/01/2001','333','CCC',20000 );
INSERT INTO ABC VALUES ('IBM','IND','01/01/2002','444','DDD',50000 ); Output:
INSERT INTO ABC VALUES ('IBM','ROI','01/01/2000','555','EEE',30000 );
INSERT INTO ABC VALUES ('IBM','ROI','01/01/2000','666','FFF',75000 );
INSERT INTO ABC VALUES ('IBM','ROI','01/01/2000','777','GGG',15000 ); IBM USA Jan 01 2000 12:00AM 111 AAA 10500
INSERT INTO ABC VALUES ('CSC','USA','01/01/2000','888','HHH',20000 ); USA Jan 01 2000 12:00AM 222 BBB 25000
INSERT INTO ABC VALUES ('CSC','USA','01/01/2001','888','HHH',25000 ); IND Jan 01 2000 12:00AM 333 CCC 15000
INSERT INTO ABC VALUES ('CSC','USA','01/01/2002','888','HHH',35000 ); ROI Jan 01 2000 12:00AM 555 EEE 30000
INSERT INTO ABC VALUES ('CSC','USA','01/01/2000','999','III',100000); ROI Jan 01 2000 12:00AM 666 FFF 75000
INSERT INTO ABC VALUES ('CSC','IND','01/01/2000','123','JJJ',100000); ROI Jan 01 2000 12:00AM 777 GGG 15000
INSERT INTO ABC VALUES ('CSC','IND','01/01/2001','123','JJJ',200000);
INSERT INTO ABC VALUES ('CSC','IND','01/01/2002','123','JJJ',300000); CSC USA Jan 01 2000 12:00AM 888 HHH 20000
USA Jan 01 2000 12:00AM 999 III 100000
232. SKIPLINES IND Jan 01 2000 12:00AM 123 JJJ 100000
BEGIN-SELECT IND Jan 01 2001 12:00AM 123 JJJ 200000
COMPANY (,1) ON-BREAK SKIPLINES = 1 USA Jan 01 2001 12:00AM 888 HHH 25000
COUNTRY (,+5) IBM IND Jan 01 2001 12:00AM 333 CCC 20000
PAY_END_DT (,+5) USA Jan 01 2001 12:00AM 111 AAA 15000
EMPLID (,+5) IND Jan 01 2002 12:00AM 444 DDD 50000
NAME (,+5)
CSC USA Jan 01 2002 12:00AM 888 HHH 35000
SALARY (,+5)
POSITION (+1) IND Jan 01 2002 12:00AM 123 JJJ 300000
FROM ABC
END-SELECT 235. LEVEL & SKIPLINES & SAVE & AFTER
LET #COMPANY_TOTAL = 0
Company will be printed only once and is not repeated.
LET #COUNTRY_TOTAL = 0
Skiplines argument provides a line break between each break. BEGIN-SELECT
COMPANY (,1) ON-BREAK LEVEL = 1 SKIPLINES = 1 SAVE = $COMPANY
Output: AFTER = COMPANY_TOTAL
COUNTRY (,+5) ON-BREAK LEVEL = 2 SKIPLINES = 1 SAVE = $COUNTRY
AFTER = COUNTRY_TOTAL
IBM USA Jan 01 2000 12:00AM 111 AAA 10500
USA Jan 01 2001 12:00AM 111 AAA 15000 PAY_END_DT (,+5)
USA Jan 01 2000 12:00AM 222 BBB 25000 EMPLID (,+5)
IND Jan 01 2000 12:00AM 333 CCC 15000 NAME (,+5)
IND Jan 01 2001 12:00AM 333 CCC 20000
SALARY (,+5)
IND Jan 01 2002 12:00AM 444 DDD 50000
ROI Jan 01 2000 12:00AM 555 EEE 30000 POSITION (+1)
ROI Jan 01 2000 12:00AM 666 FFF 75000 LET #COUNTRY_TOTAL = #COUNTRY_TOTAL + &SALARY
ROI Jan 01 2000 12:00AM 777 GGG 15000 FROM ABC
END-SELECT
CSC USA Jan 01 2000 12:00AM 888 HHH 20000
USA Jan 01 2001 12:00AM 888 HHH 25000 END-PROCEDURE
USA Jan 01 2002 12:00AM 888 HHH 35000
USA Jan 01 2000 12:00AM 999 III 100000 BEGIN-PROCEDURE COMPANY_TOTAL
IND Jan 01 2000 12:00AM 123 JJJ 100000
IND Jan 01 2001 12:00AM 123 JJJ 200000 LET $COMPANY = ltrim(rtrim($COMPANY,' '),' ')
IND Jan 01 2002 12:00AM 123 JJJ 300000 PRINT 'Total Amount for the Company ' (+1,1)
PRINT $COMPANY (,+1)
233. SKIPLINES & LEVEL PRINT #COMPANY_TOTAL (,+1)
BEGIN-SELECT LET #COMPANY_TOTAL = 0
COMPANY (,1) ON-BREAK SKIPLINES = 2 POSITION (+1,1)
COUNTRY (,+5) ON-BREAK LEVEL = 2 SKIPLINES = 1 END-PROCEDURE
PAY_END_DT (,+5)
EMPLID (,+5) BEGIN-PROCEDURE COUNTRY_TOTAL
NAME (,+5) LET $COMPANY = ltrim(rtrim($COMPANY,' '),' ')
SALARY (,+5) LET $COUNTRY = ltrim(rtrim($COUNTRY,' '),' ')
POSITION (+1) PRINT '-' (,65,9) FILL
FROM ABC LET $DESC = $COMPANY || ' - ' || $COUNTRY || ' Total: '
END-SELECT PRINT $DESC (+1,45)
PRINT #COUNTRY_TOTAL (,65)
Output: POSITION (+1,6)
LET #COMPANY_TOTAL = #COMPANY_TOTAL + #COUNTRY_TOTAL
IBM USA Jan 01 2000 12:00AM 111 AAA 10500 LET #COUNTRY_TOTAL = 0
Jan 01 2001 12:00AM 111 AAA 15000 END-PROCEDURE
Jan 01 2000 12:00AM 222 BBB 25000
Output:
IND Jan 01 2000 12:00AM 333 CCC 15000
Jan 01 2001 12:00AM 333 CCC 20000
Jan 01 2002 12:00AM 444 DDD 50000
IBM USA Jan 01 2000 12:00AM 111 AAA 10500
ROI Jan 01 2000 12:00AM 555 EEE 30000 Jan 01 2001 12:00AM 111 AAA 15000
Jan 01 2000 12:00AM 666 FFF 75000 Jan 01 2000 12:00AM 222 BBB 25000
Jan 01 2000 12:00AM 777 GGG 15000
---------
IBM - USA Total: 50500.00
CSC
USA Jan 01 2000 12:00AM 888 HHH 20000 IND Jan 01 2000 12:00AM 333 CCC 15000
Jan 01 2001 12:00AM 888 HHH 25000
Jan 01 2002 12:00AM 888 HHH 35000 Jan 01 2001 12:00AM 333 CCC 20000
Jan 01 2000 12:00AM 999 III 100000 Jan 01 2002 12:00AM 444 DDD 50000
---------
IND Jan 01 2000 12:00AM 123 JJJ 100000
IBM - IND Total: 85000.00
Jan 01 2001 12:00AM 123 JJJ 200000
Jan 01 2002 12:00AM 123 JJJ 300000
ROI Jan 01 2000 12:00AM 555 EEE 30000 PRINT ‘150000.50’ (1,1) EDIT :$MASK1 !IT RETURNS $1.50.000.50
Jan 01 2000 12:00AM 666 FFF 75000 PRINT ‘SRINIVAS’ (+1,1) EDIT :$MASK2 !IT RETURNS SRI-NI-VAS
Jan 01 2000 12:00AM 777 GGG 15000 242. What are the formatting Commands can be
--------- allowed with Print Command?
IBM - ROI Total: 120000.00
BOLD: To print the data in Bold.
Total Amount for the Company IBM 255500.00 BOX: To print a graphical box around the printed data.
CENTER: To print the data from the centre of the
CSC USA Jan 01 2000 12:00AM 888 HHH 20000 page. When we use this command the position qualifier is
Jan 01 2001 12:00AM 888 HHH 25000 ignored.
Jan 01 2002 12:00AM 888 HHH 35000
UNDERLINE: To print the data with underline
Jan 01 2000 12:00AM 999 III 100000
characters.
---------
CSC - USA Total: 180000.00 FILL: To fill a specified character or string in the page.
EX: print '*' (1,1,79) fill
IND Jan 01 2000 12:00AM 123 JJJ 100000 SHADE: To print shaded graphical box around the
Jan 01 2001 12:00AM 123 JJJ 200000 printed data.
Jan 01 2002 12:00AM 123 JJJ 300000
NOP: To hide a field temporarily from printing.
---------
CSC - IND Total: 600000.00 DATE: we can’t use this with the numeric columns or
variables.
Total Amount for the Company CSC 780000.00 MATCH: Compares a field to a list of key values and if
a match is found, prints corresponding string at specified
line and column.
236. For the above program add PRINT = NEVER Qualifier MONEY: indicates that the column or variable is to be
for COMPANY field then output would be same with small formatted using the MONEY-EDIT-MASK from the current
change – COMPANY will not be printed. locale.
NUMBER: NUMBER indicates that the column or
variable is to be formatted using the NUMBER-EDIT-MASK
from the current locale.
Print Command ON-BREAK:
237. What is the use of Print Command? CODE-PRINTER:
Useful to print the data on the page at a specified position. WRAP: wraps text at word spaces. Additional text is
238. What are the position parameters available with moved to a new line. After a string wraps, the current
Print Command? position is one character to the right of the last character
in the column.
Print <Variable Name> (X, Y, Z).
EX: Print &comment (48,20,0) wrap 50 3
X: Specifies the Line (Row) Number of the Page.
EDIT: The field is edited before it is printed.
Y: Specifies the Column Number of the Page.
Edit Mask Types:
Z: Specifies the number of positions allocated for the
field. 1. Numeric edit:
239. About Implicit Printing? Special characters available in the Numeric edit mask:
Implicit printing is nothing but printing the data without 8, 9, 0, B, $, V, MI, PR, PS, NA, NU, E, (DOT). , (COMMA).
using the Print command by placing position parameters 8 - Zero fill to the right of the decimal point, trim leading
immediately after the column name. blanks.
Sample Program: 9 - Zero fill to the right of the decimal point, space fill to
Begin-Program the left.
Do Printing 2. Date edit
End-Program Special characters available in the Date edit mask:
Begin-Procedure Printing YYYY, RR, Q, WW, DDD, MONTH, RM, CC, BC or AD, (HH,
MT, SS), NNNNNN, AM or PM, |.
Begin-Select
3. Text edit
EMPLID (1,1)
Special characters available in the Text edit mask:
NAME (1,15)
X: It place the character in the
FROM ABC
output
End-Select
For example: move ‘123456789’ to $zip
End-Procedure
Print $zip (1,1) edit xxxxx-xxxx
240. About Explicit Printing?
Output: 12345-6789
Explicit Printing is nothing but Print the data using Print
b: It inserts the blank space in the
Command.
output
Sample Program:
For example: move ‘123456789’ to $zip
Begin-Program
Print $zip (1,1) edit (xxx)bxxx-xxxx
Do Printing
Output: (123) 456-789
End-Program
~ (Tilde): It skips a character in the
Begin-Procedure Printing output.
Begin-Select For example: move ‘123456789’ to $zip
EMPLID Print $zip (1,1) edit xxx~~~xxx
NAME Output: 123789
Print 'the Employee Id Is:' $EMPID (1,25) And we can use any character as a text constant in the
Print 'the Employee Name Is:' $NAME (2,25) output.
End-Select For example: move ‘srinu’ to $name
End-Procedure Print $name (1, 1) edit name:bxxxxx
241. Can we use Edit Mask Dynamically? Output: name. srinu
Yes. We can. 243. How do you make a zero value blank on a report?
MOVE '$9,99,999.99' TO $MASK1 BEGIN-PROGRAM
MOVE ‘XXX-XX-XXX’ TO $MASK2 PRINT #A (1,1) EDIT B
SHOW #A EDIT B
END-PROGRAM
244. Sample Program Formatting Commands.
BEGIN-PROGRAM
PRINT 'NOP' (+1,1) NOP
PRINT 'CENTER' (+1,1) CENTER
PRINT 'BOLD' (+1,1) BOLD
PRINT 'UNDERLINE' (+1,1) UNDERLINE
PRINT 'BOX' (+1,1) BOX
PRINT 'SHADE' (+1,1) SHADE
PRINT '*' (+1,1,35) FILL
PRINT '1234567890' (+1,1,35) FILL
PRINT '-' (+1,1,35) FILL
END-PROGRAM
Report Types
248. How many types of Reports we can generate thru
SQR?
1. Cross-Tabular Reports
2. Form Reports
3. Master/Detail Reports
4. Letters or Documents
245. Sample Program on Number Edit Masks 5. Multiple-reports
BEGIN-PROGRAM 6. Mailing Labels
PRINT 'NUMBER EDIT MASKS' (+2,1) BOLD BOX SHADE
PRINT 1570.50 (+1,1) EDIT $9999.99 Cross-Tabular Reports
PRINT 1570.147 (+1,1) EDIT $9999.99
PRINT 1570.143 (+1,1) EDIT $9999.99 Cross-tabular reports are matrix- or
PRINT 123456.7845600 (+1,1) EDIT 999999.9999 spreadsheet-like reports.
PRINT 123456.7845600 (+1,1) EDIT 888888.8888 These reports are useful to display Summary
END-PROGRAM numeric data.
Mostly Arrays will be useful to generate
Cross-Tabular Reports.
Markers are the command mainly used with Letters. DECLARE-REPORT REPORT1
Document Marker is used to mix data with the LAYOUT = REPORT1_LAYOUT
letter and Starts with ‘@’ symbol. ...
END-DECLARE
Sample Program
DECLARE-REPORT REPORT2
Begin-Program
LAYOUT = REPORT2_LAYOUT
Do MAIN
...
End-Program
END-DECLARE
Begin-Procedure MAIN END-SETUP
Begin-Select
EMPLID While writing the heading we have to use
NAME for-reports.
STATE BEGIN-HEADING 10 FOR-REPORTS = (REPORT1)
COUNTRY ...
POSTAL END-HEADING
DO Write_Letter
BEGIN-HEADING 20 FOR-REPORTS = (REPORT2)
From PS_PERSONAL_DATA WHERE EMPLID IN (SELECT TOP 5 B.EMPLID FROM
PS_PERSONAL_DATA B WHERE B.STATE <> '' AND B.POSTAL <> '') ...
End-Select END-HEADING
End-Procedure
New-Report command used to create
Begin-Procedure Write_Letter new reports and we have to give the report path.
Begin-Document (1, 1)
USE-REPORT REPORT1
&EMPLID
LET $REPORT1 = 'C: \TEMP\REPORT1.PDF
&NAME
NEW-REPORT REPORT1
@STATE_COUNTRY_POSTAL
.b USE-REPORT REPORT2
.b LET $REPORT2 = 'C: \TEMP\REPORT2.PDF
$current-date NEW-REPORT REPORT2
Dear Sir or Madam:
.b Before writing any data, mention the
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX report name with Use-Report command.
XXXXXXXXXXXXXXX
USE-REPORT REPORT1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PRINT 'FULL TIME EMPLOYEES DETAILS' (1, 1)
XXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX USE-REPORT REPORT2
.b PRINT 'PART TIME EMPLOYEES DETAILS' (1, 1)
.b
Sincerely, Mailing Labels
XXXXXXXXXXXXXXX
XXXXXXXXXXXX 252. What is the use of Mailing Labels?
XXXXXXXX Useful to print the data across the page.
End-Document In normal reports lot of space in a page will be wasted.
Position () @STATE_COUNTRY_POSTAL 253. What are the Commands mainly used with
Print &STATE () mailing labels?
Print ', ' ()
COLUMNS – Useful to enable the Column.
Print &COUNTRY ()
Print ' ' () NEXT-COLUMN – Moves the cursor to the
Print &POSTAL () edit xxxxx-xxxx next column.
USE-COLUMN 0 – Reinitialize the cursor with #end-file command identifies end of file. At end of file it
what ever the value specified in the use-column. In this returns 1.
situation it reinitialized with Zero position. 262. What is the use of WRITE Command?
ALTER-PRINTER – Alter the printer Writes the data into a file.
environment at run time such as fonts, font size. WRITE 1 FROM 'SRINIVAS' '|' '111' '|' '999'
Ex: WRITE 1 FROM 'SRINIVAS' ',' '111' ',' '999'
ALTER-PRINTER WRITE 1 FROM 'SRINIVAS':5 ',' '111':5 ',' '999':5
FONT=4 ! HELVETICA WRITE 1 FROM $NAME $EMPLID $SALARY
POINT-SIZE = 4 WRITE 1 FROM $NAME:10 $EMPLID:10 $SALARY:10
FONT-TYPE = FIXED WRITE 1 FROM $NAME $COMMA $EMPLID $COMMA $SALARY
PITCH = 4 263. How to WRITE the data into file?
DECLARE-LAYOUT – Change the paper Specify the File Path and File name.
environment. Specify the file number.
Next-Listing – Open the file for writing purpose.
254. Sample Program about Mailing Labels? Write the data using Write Command.
BEGIN-PROGRAM
OPEN 'C:\CNU\OUTPUT.TXT' AS 1 FOR-WRITING RECORD=50
STATUS=#OPENSTAT
IF #OPENSTAT != 0
Flat Files SHOW 'ERROR WHILE OPENING FILE!!'
STOP QUIET
255. What is the use of flat files? END-IF
6. TIMEMATH.SQC: Includes set of date arithmetic 19. SQLERR.SQC: For SQR Error handling purpose.
procedures related to Time. #sql-status and $sql-error will be populated.
329. Can we trim date variable? PS - WILL GIVE THE LIST OF ALL BACK GROUND PROCESS RUNNING
MESG
Yes, we can perform ltrim and rtrim on date variables.
TALK
LET $DATE = LTRIM(RTRIM($CURRENT-DATE,' '),' ')
WRITE
SHOW $DATE
/*
330. How to Convert -Ve Number To +Ve Number? VAR="HEWITT"
LET #X = -5 ECHO $VAR
SHOW #X */
LET #X = #X - (2*#X)
334. Code find some text in a folder and create a file with
SHOW #X
search found values.
UPDATE PS_JOB SET COMPRATE = COMPRATE -(2*COMPRATE) WHERE
COMPRATE < 0 $ CD /EXPORT/HOME/A55849
$ MKDIR DATA
331. Code to find out Week Number.
$ CD /APPS/PSOFT/HRCURRENT/SQR
LET #WEEK =
$ GREP -I "LOCATION"
CEIL((DATEDIFF(&CHECK_DT,STRTODATE(EDIT(&CHECK_DT,'YYYY') || '-01-
*.*>>/EXPORT/HOME/A55849/DATA/OUTPUT_GREP.TXT
01' ,'YYYY-MM-DD'),'DAY')/7))
$ CD /EXPORT/HOME/A55849
332. Code to check whether the given value is Integer
$ CD DATA
or not?
If (#Number - Floor(#Number) = 0) $ LS -LRT
Display 'The Number Is An Integer'
Else
Display 'The Number Is Not An Integer'
End-If
333. Shall Script Commands?
CD / - MOVE TO PRVIOUS PATH
CD ~/<FOLDER NAME> -PARENT DIRECTORY THEN FOLDER
LS -LR - REVERS ORDER
LS -F - WILL PUT * IN FRONT OF EXECUTABLE FILE
CAT > <FILE NAME>
CNTL Z
CP <SOURCE NAME> <DESTINATION NAME>
CP <FILENAME PATH>/
RM <FILE NAME>
RM -I <FILE NAME>
RM -R <DIRECTORY NAME>
RM -IR <DIRECTORY NAME>
MV <FILE NAME> <NEW FILE NAME> - RENAMING FILE NAME