Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division...
-
Upload
francine-cummings -
Category
Documents
-
view
255 -
download
0
Transcript of Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division...
![Page 1: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/1.jpg)
Branching Techniques for Managing WebFOCUS Applications
Joel StarkmanDirector, FOCUS DivisionInformation Builders, Inc.
October, 2011
Copyright 2011, Information Builders. Slide 1
![Page 2: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/2.jpg)
Managing Flow
A procedure can be navigated by:
Unconditional branching ( ) – transfer control to a label
Conditional branching ( ) – transfer control to a label depending on the outcome of a test
Looping – perform a set of commands repeatedly
![Page 3: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/3.jpg)
‑label [TYPE text]‑label [TYPE text]
Branching to a Label
The –label command creates a physical reference point in the code as a target of a –GOTO or –IF statement
user‑defined name, up to 64 characters. No blanks, nor the name of any Dialogue Manager command except ‑QUIT or ‑EXIT
Optional – sends a message to the client
![Page 4: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/4.jpg)
Unconditional Branching
An “unconditional branch” via –GOTO always transfers control to the specified label
.
.
.-GOTO label.. (any executable code). (any Dialogue Manager code).-label [TYPE text].. .
![Page 5: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/5.jpg)
Unconditional BranchingExample
Skip over the TABLE request by
jumping to the –SKIPOVER label
-GOTO SKIPOVERTABLE FILE SALESPRINT UNIT_SOLD RETURNSBY PROD_CODE BY CITYEND ‑RUN ‑SKIPOVER‑TYPE Skipped over the report
![Page 6: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/6.jpg)
The Plant Sales Report
Management would like us to modify a report that currently allows an analyst to select the plant and a specific year.
The modified report should display all years for specific plant in a sales summary report sorted by product.
Before: After:
![Page 7: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/7.jpg)
Run the Procedure
The WebFOCUS Auto Prompting facility opens
![Page 8: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/8.jpg)
Activate the Unconditional Branching
Change the source code:
![Page 9: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/9.jpg)
Activate the Unconditional Branching
Change the source code:
![Page 10: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/10.jpg)
Run the Procedure
![Page 11: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/11.jpg)
View the DM and FOCUS Commands
View the effect of the –SET &ECHO=ALL; command
![Page 12: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/12.jpg)
View the DM and FOCUS Commands
skipped
![Page 13: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/13.jpg)
Conditional Branching
expression any valid expression on which to make the decision
label1passes control to label1 when expression is true (THEN is optional)
CONTINUE drops to the command after the ending semicolon (;)
ELSE GOTO label2 passes control to label2 when expression is false
ELSE IF/THEN/ELSE compound ‑IF inside the outer ‑IF (with its own labels)
-IF expression [THEN] GOTO label1|CONTINUE - [ELSE IF/THEN/ELSE[;]] - [ELSE GOTO label2|CONTINUE];
-IF expression [THEN] GOTO label1|CONTINUE - [ELSE IF/THEN/ELSE[;]] - [ELSE GOTO label2|CONTINUE];
Conditional branching transfers control to one of several labels, based on the evaluation of an expression
![Page 14: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/14.jpg)
Conditional Branching Example
‑IF &OPTION EQ 'S' GOTO PRODSALES;‑PRODRETURNSTABLE FILE SALESPRINT PROD_CODE UNIT_SOLDBY STORE_CODEEND‑EXIT‑PRODSALESTABLE FILE SALESSUM UNIT_SOLDBY PROD_CODEEND
Pass control to ‑PRODSALES if &OPTION equals ‘S’ ,
otherwise pass control to the next line
Not needed inthis simple case
![Page 15: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/15.jpg)
Compound –IFExample
‑IF &OPTION EQ 'R' THEN GOTO PRODRETURNS ELSE
‑ IF (&OPTION EQ 'S') GOTO PRODSALES ELSE‑ GOTO QUIT;‑*‑PRODRETURNSTABLE FILE SALESPRINT PROD_CODE UNIT_CODEBY STORE_CODEEND‑GOTO QUIT‑PRODSALESTABLE FILE SALESSUM UNIT_SOLDBY PROD_CODEEND‑QUIT
![Page 16: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/16.jpg)
Compound IF Alternative Syntax
The previous nested –IF expression:
‑IF &OPTION EQ 'R' THEN GOTO PRODRETURNS ELSE ‑ IF (&OPTION EQ 'S') GOTO PRODSALES ELSE‑ GOTO QUIT;
may be written as separate expressions (clearer?):
‑IF &OPTION EQ 'R' THEN GOTO PRODRETURNS; ‑IF &OPTION EQ 'S' THEN GOTO PRODSALES;‑GOTO QUIT
Semicolons endeach statementSemicolons endeach statement
![Page 17: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/17.jpg)
The Branch Report
Constance Paine needs our help in fixing a procedure that should allow an analyst to choose between summing sales by Store Name or by Region.
![Page 18: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/18.jpg)
Open the Procedure
Code targets for Dialogue Manager additions
![Page 19: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/19.jpg)
Using GUI Tools for adding DM
GUI tools for adding Dialogue Manager Commands
![Page 20: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/20.jpg)
Adding Conditional Branching
The Dialogue Manager -IF wizard
![Page 21: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/21.jpg)
Adding Conditional Branching
The Dialogue Manager -IF wizard
![Page 22: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/22.jpg)
Adding a Label
Add a Dialogue Manager Label
![Page 23: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/23.jpg)
Adding Unconditional Branching
Add a -GOTO
![Page 24: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/24.jpg)
Verify Your Work
The Logical View
![Page 25: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/25.jpg)
The Plant Sales Report
Management would like a report that allows an analyst to select the plant and either a specific year or all years for a sales summary report sorted by product.
![Page 26: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/26.jpg)
Run the Procedure
Need to add the ‘ALL’ option
![Page 27: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/27.jpg)
Add the Conditional Branching
Add the ALL option to &YEAR
![Page 28: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/28.jpg)
Activate the Conditional Branching
Activate the conditional branching statements
![Page 29: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/29.jpg)
Activate Conditional Branching
Add the –SET command and the page heading reference
![Page 30: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/30.jpg)
Run the Procedure
The page heading text reflects your changes
![Page 31: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/31.jpg)
Change the Selection Criteria
There were zero records for the Boston plant in 1999
You never want to see this error
![Page 32: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/32.jpg)
Activate the Error Message
Activate the Dialogue Manager commands
&LINESreserved &variable
(one of many)Contains number of output lines
in the previous TABLE
&LINESreserved &variable
(one of many)Contains number of output lines
in the previous TABLE
-INCLUDEInserts code from errorout.fex
and executes it as if it wasactually coded here
-INCLUDEInserts code from errorout.fex
and executes it as if it wasactually coded here
![Page 33: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/33.jpg)
Open the Procedure
The ERROROUT procedure contains HTML statements bracketed by –HTMLFORM BEGIN and –HTMLFORM END
![Page 34: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/34.jpg)
Run the Procedure
WebFOCUS now displays an error message
That’s better!
might want to useSET EMPTYREPORT=ON
instead of a message
![Page 35: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/35.jpg)
Looping with -REPEAT
Copyright 200B, Information Builders. Slide 35
![Page 36: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/36.jpg)
Looping
A series of commands can be performed repeatedly by using looping with the ‑REPEAT command
-REPEAT has three variations:
• For a specific number of times
• While a condition is true
• For a calculated number of times
(with a referenceable counter)
![Page 37: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/37.jpg)
LoopingAlternate Loop Control
–REPEAT is a convenient substitute for using a –SET with a variable that acts like a counter to control a loop
Example:
-SET &N=0‑START‑SET &N=&N+1;–TYPE REPETITION &N‑IF &N GT 5 GOTO NOMORE;‑GOTO START‑NOMORE TYPE EXCEEDED REPETITION LIMIT‑EXIT
Could be written in one line:‑IF &N LE 5 GOTO START;
![Page 38: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/38.jpg)
Looping a Specific Number of Times
‑REPEAT label n TIMES‑REPEAT label n TIMES
end-of-loop marker
the number of times
to execute the loop
![Page 39: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/39.jpg)
Looping a Specific Number of Times
For example:
‑REPEAT LAB1 2 TIMES‑TYPE INSIDE LOOP‑LAB1 -TYPE OUTSIDE LOOP
The output is:
INSIDE LOOPINSIDE LOOPOUTSIDE LOOP
![Page 40: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/40.jpg)
Looping While a Condition is True
‑REPEAT label WHILE condition‑REPEAT label WHILE condition
end-of-loop marker
condition under which to
re-execute the loop each time
![Page 41: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/41.jpg)
Looping While a Condition is TrueExample
-SET &INPUT = ‘ ‘;-SET &GOT_ONE = 0;-SET &A = 0;‑REPEAT LABEL WHILE &GOT_ONE EQ 0-SET &A = &A + 1;‑TYPE LOOP &A‑READ fromfile &INPUT.10.-SET &GOT_ONE = &IORETURN;‑LABEL -SET &A = &A – 1;-TYPE GOT &A RECORDS
‑REPEAT label WHILE condition‑REPEAT label WHILE condition
For a 2-record file, the output shows:
LOOP 1LOOP 2LOOP 3GOT 2 RECORDS
Another reservedsystem & variables
![Page 42: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/42.jpg)
Looping a Calculated Number of Times
‑REPEAT label FOR &variable [FROM fromval] [TO toval] [STEP s]
‑REPEAT label FOR &variable [FROM fromval] [TO toval] [STEP s]
end-of-loopmarker
Loop counter, tested at start of each execution of the loop
start value of &variable (default is 1) end value of &variable
(default is 1,000,000)
increments &variable by a constant ‘s’. may be positive or negative; default increment is 1
![Page 43: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/43.jpg)
Looping a Calculated Number of TimesExample
‑REPEAT LABEL1 FOR &A FROM 3 TO 7 STEP 2
‑TYPE INSIDE &A‑LABEL1-TYPE OUTSIDE &A
The output is:
INSIDE 3
INSIDE 5
INSIDE 7
OUTSIDE 9
‑REPEAT label FOR &variable [FROM fromval] [TO toval] [STEP s]
‑REPEAT label FOR &variable [FROM fromval] [TO toval] [STEP s]
![Page 44: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/44.jpg)
LoopingPrematurely Stop a Loop
A loop terminates when:
•it is executed in its entirety
•a –QUIT or –EXIT command is issued
•a –GOTO is issued to a label outside of the loop
-REPEAT LOOP 5 TIMES-TYPE HELLO-GOTO OUTSIDELOOP-LOOP-OUTSIDELOOP-TYPE AFTER LOOP
See:HELLOAFTER LOOP
![Page 45: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/45.jpg)
The Product Report
Management would like a report that reads and counts the products captured in an external SAVE file.
Should looklike this
![Page 46: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/46.jpg)
The Process
To accomplish this task, follow these steps:
1.Capture the report output in a SAVE file ‘PRODHOLD’
2.Use a procedure called PRODLOOP that:
• loops to read data from the PRODHOLD file
• displays an incremental counter for each record
• displays the total records in the file
![Page 47: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/47.jpg)
The SAVE File
Select PRODHOLD as a SAVE file
![Page 48: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/48.jpg)
-* File PRODLOOP.FEX-* -SET &ECHO=ALL;-INCLUDE PRODHOLD-RUN-SET &NUMPROD = &LINES;-SET &BLANK = ‘ ‘;-*-TYPE ***********************************-TYPE Total Number of Products - &NUMPROD-TYPE ***********************************-TYPE-*-EXIT-REPEAT LOOP1 FOR &CNTR TO &NUMPROD-SET &PRODCODE = ‘A234’;-SET &PRODNAME = ‘A23456789012345678901234567890’;-READ PRODHOLD &PRODCODE &PRODNAME-IF &IORETURN NE 0 GOTO AFTERLOOP ;-TYPE &CNTR &BLANK &PRODCODE &PRODNAME-LOOP1-AFTERLOOP-EXIT
The PRODLOOP Procedure
Generate the data extract
Capture &LINES from the report
Display # of lines
Repeat &NUMPROD times
Declare length of &var’s
Read a line, 0=got one
reserved &variable
-SET &PRODCODE = ‘ ‘;-SET &PRODNAME = ‘ ‘;-READ PRODHOLD &PRODCODE.4. &PRODNAME.30.
OR
![Page 49: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/49.jpg)
Run the Procedure
The report output
Columns are notaligned properly
![Page 50: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/50.jpg)
Edit the Procedure
Change the procedure
-* File PRODLOOP.FEX-* -SET &ECHO=ALL;-INCLUDE PRODHOLD-RUN-SET &NUMPROD = &LINES;-SET &BLANK = ‘ ‘;-*-TYPE ***********************************-TYPE Total Number of Products - &NUMPROD-TYPE ***********************************-TYPE-*-EXIT-REPEAT LOOP1 FOR &CNTR TO &NUMPROD-SET &PRODCODE = ‘A234’;-SET &PRODNAME = ‘A23456789012345678901234567890’;-READ PRODHOLD &PRODCODE &PRODNAME-IF &IORETURN EQ 0 GOTO AFTERLOOP ;-SET &FIRST = IF &CNTR GT 9 THEN ‘&CNTR.EVAL’ ELSE ‘0&CNTR.EVAL’;-TYPE &FIRST &BLANK &PRODCODE &PRODNAME-LOOP1-AFTERLOOP-EXIT
-SET &FIRST = IF &CNTR GT 9THEN ‘&CNTR.EVAL’ELSE ‘0&CNTR.EVAL’;
![Page 51: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/51.jpg)
Run the Procedure
The columns have been aligned
![Page 52: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/52.jpg)
Review: Managing Flow
Unconditional branching,transfer control to a label –GOTO label
Conditional branching, transfer control to a label based on a conditional expression
–IF expression GOTO label1 ELSE [IF…] GOTO label2;
Repeat a set of commands,via several looping criteria options -REPEAT label n TIMES
-REPEAT label WHILE cond-REPEAT label FOR &var FROM x TO y STEP z-label
![Page 53: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/53.jpg)
Thank You
![Page 54: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/54.jpg)
Copyright 20011 Information Builders. Slide 54
End of presentationPress esc to exit
![Page 55: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/55.jpg)
Copyright 200B, Information Builders. Slide 55
Conventions Used in this Workshop
Business Situation
Notes
Key
Alert
Summary
![Page 56: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/56.jpg)
The &ECHO Command
&ECHO= FunctionalityON Displays FOCUS commands that are expanded and
stacked for execution.
ALL Displays both Dialogue Manager and FOCUS commands that are expanded and stacked for execution.
OFF Suppresses both Dialogue Manager and FOCUS commands that are expanded and stacked for execution.
NONE Prevents procedure code from being displayed (echoed). Once the value of &ECHO has been set to NONE, it cannot be changed during the session or connection.
{-DEFAULT|‑SET|EX &ECHO = {ON|ALL|OFF|NONE}
![Page 57: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/57.jpg)
The Procedure
1.The –INCLUDE incorporates the PRODHOLD procedure, which generates the PRODHOLD external file.2.The –SET commands assign values to the variables needed for the report. For example, &NUMPROD, which is based on &LINES (a statistical variable), the total number of output lines generated from the PRODHOLD procedure.3.The –TYPE commands act as a page heading to display the total number of products.
![Page 58: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/58.jpg)
View the Variables
Add -? &PROD to display the variables that begin with ‘PROD’ and their corresponding values
![Page 59: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/59.jpg)
Termination Commands
Command Description
-EXIT Forces a procedure to end. All stacked commands are executed and the procedure exits.
If the current procedure was called by another procedure, the calling procedure continues processing. Use –EXIT for terminating a procedure after processing a final branch that completes the desired task. The last line of a procedure implies a –EXIT.
–EXIT can also be inserted strategically into procedure by a developer to assist the debugging of a complicated set of instructions.
![Page 60: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/60.jpg)
Termination Commands
Command Description
-QUIT Forces an immediate exit from a procedure. Remnant stacked commands are not executed.
If the current procedure was called by another procedure, control returns directly to the client application, not the calling procedure.
-QUIT can be the target of a branch.
-QUIT FOCUS [n] Where n is the application return code value, which can be a constant or an integer value (the default value is 0).
In Developer Studio, terminates the procedure without executing stacked commands, exits WebFOCUS, and returns to either the calling program or the operating system.
Upon exiting WebFOCUS, the value of the return code is returned to the calling program, if one exists. This can be useful in programming since the value of the status code can be interrogated to indicate the state when WebFOCUS was exited.
-QUIT FOCUS can be the target of a branch.
![Page 61: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/61.jpg)
The PRODLOOP Procedure (continued)
The –REPEAT command performs a repetitive section of code that begins with –REPEAT and ends with the –LOOP label
The section repeats for &NUMPROD times (in this case, 17)
The –SET commands define the length of the variables
The –READ command reads each line from the PRODHOLD file and the –TYPE displays each line after it has been read
The process repeats at –LOOP1 for &NUMPROD (17) times
![Page 62: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/62.jpg)
Run the Procedure
The page heading reflects the selection for ‘ALL’
INCORRECT
![Page 63: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/63.jpg)
Testing the Attributes of a Variable(existence, type, length, pre-evaluation)
‑IF &name.attribute expression GOTO label...;
property type; one of: .EXIST the presence of a value for a variable .LENGTH the non-blank length of the variable .TYPE the formatting type of the variable (A or I) .EVAL substitute the value of a variable immediately,
then act on the Dialogue Manager command
property type; one of: .EXIST the presence of a value for a variable .LENGTH the non-blank length of the variable .TYPE the formatting type of the variable (A or I) .EVAL substitute the value of a variable immediately,
then act on the Dialogue Manager command
dot is required between &name and attribute
dot is required between &name and attribute
user-suppliedvariable
user-suppliedvariable
![Page 64: Branching Techniques for Managing WebFOCUS Applications Joel Starkman Director, FOCUS Division Information Builders, Inc. October, 2011 Copyright 2011,](https://reader033.fdocuments.net/reader033/viewer/2022061516/5697bfd61a28abf838cadd88/html5/thumbnails/64.jpg)
Testing the Attributes of a Variable Examples
-IF &OPTION.EXIST GOTO LAB1 ELSE GOTO… ;
-IF &OPTION.LENGTH LE 3 GOTO LAB2 ELSE GOTO…;
-IF &OPTION.TYPE EQ A GOTO LAB3 ELSE GOTO …;
-IF &OPTION.EVAL LT 99 GOTO LAB4 ELSE GOTO …;
Better use for .EVAL-SET &SKIP= IF … THEN ‘-GOTO LAB5’ ELSE ‘-*’;&SKIP&SKIP.EVAL WHY?
ignoredworks