The LINE and COL parameters delimit the upper left and lower right corners of the area to be searched. This area is called a Search area. When Control-M/Analyzer scans the data source line by line for the specified STRING, only lines and columns within the Search area are examined.
When a string is specified without a comparison operator (.GT., .LT., .GE., .LE., or .NE.), the entire Search area is examined. However, when a string (or another string to which it is joined by a Boolean operator) is specified with a comparison operator, only the beginning of the Search area (starting at FROM COL with a length equal to the number of characters in the specified string) is examined. For more information on these topics see "Comparison Operators" and "Boolean Operators" above.
Note: The start of the page is determined by machine or ASA codes, if available, or by page length definition and line counting.
LINE and COL can contain the following types of values:
Table 273 WHEN Structure LINE and COLUMN Values
Value |
Description |
---|---|
Absolute Values |
Explicit line numbers (based on the start of the dataset or the start of the current page, depending on the MODE), and explicit column numbers. Example WHEN LINE 003-020 COL 050-070 The ON statement MODE parameter specifies whether Absolute Values are based on the start of the dataset or the start of the page. Line and column number prefixes can be specified to override the default set by MODE. (See "Relative Values" and "WHEN Relative Values" below.) See Compound WHEN Statements for information about how the search process is performed when the MODE parameter is set to PG and absolute line numbers are specified in the LINE parameter. |
Relative Values |
Relative line numbers can be specified with the following prefixes:
Examples WHEN LINE PG+003 - PG+020 COL 050 - 070 WHEN LINE DS+003 - DS+020 COL 050 - 070 |
WHEN Relative Values |
Line and column numbers can be relative to the location where a search string, specified by a higher level WHEN statement, was found. The higher level WHEN, whose criteria were met, must be within the same WHEN block as the specified relative LINE and COL values. Because several WHEN statements may exist within the same WHEN block, the desired WHEN statement level must be identified. Each WHEN is numbered in ascending order (indicated by m in the format below), beginning with the number one. (Level zero cannot be specified in statement WHEN.) The appropriate WHEN statement can be referenced by specifying the hierarchical level using the following prefixes:
These prefixes cannot be used to refer to WHEN statements of other WHEN blocks. However, these prefixes can be used in the STOP criteria for the same WHEN block. Examples WHEN LINE L01+003 - L01+020 COL 050 - 070 WHEN LINE 003 - 020 COL C01+050 - C01+070 |
Note: When working in MODE=DS (dataset), line number "999" denotes the end of the report (for example, LINE 001-999 means all lines of the report).
It is possible to reference a string a few pages prior to the current page by using negative numbers. The number of pages retained (kept) for this purpose is set in the RTEBUF installation parameter. For additional information, see the discussion about installing Control-M/Analyzer in the INCONTROL for z/OS Installation Guide.
The search for STOP criteria always begins on the line after the line where the corresponding WHEN criteria were found, even if the STOP LINE parameter specifies a prior line.
STRING Operators
A string must be specified when no operator is used and immediately after each .GT., .LT., .GE., .LE., .NE., and .WI. operator.
The string for operator .WI. is a mask containing one or more ? symbols. Each ? represents a single "wild character" that may be a number, letter or symbol. For example, ??/??/?? can be used as the mask for a date in this format.
Operator .AL. instructs Control-M/Analyzer to perform subsequent DO statements for every line in the LINE/COL range (as if every line matched the WHEN criteria, without regard to the string). No string is searched for or compared. Therefore, no string is specified. However, the position found in the line is automatically set to the FROM column value (the first value in the COL range). For subsequent DO EXTRACT statements, the position within the line found as a result of using operator .AL. is 1.
Operators .SR. and .ER. instruct Control-M/Analyzer to perform subsequent DO statements once at the start or end of the report (as if the first or last line of the report matched the WHEN criteria, without regard to the string). No string is searched for or compared; therefore, no string is specified.
Operators .SP. and .EP. instruct Control-M/Analyzer to perform subsequent DO statements at the start or end of each page (as if the start or end of each page matched the WHEN criteria, without regard to the string). No string is searched for or compared. Therefore, no string is specified.
AutoEdit Substitution
Control-M/Analyzer AutoEdit and Local variables can be embedded in WHEN and STOP criteria. The variables are resolved (replaced) at time of rule execution. For additional information on AutoEdit processing see Control-M/Analyzer Variables.
Single vs. Multiple Occurrences of a String
System variable SYSSRCHALL determines whether a line will be searched for all occurrences or for only the first occurrence of the string specified in a WHEN statement. When SYSSRCHALL=0 (the default value), only the first occurrence on a line is found. When SYSSRCHALL=1, the search continues until every occurrence on the line has been found and the DO statements are performed each time an occurrence is found. See Summary of System Variables for a description of this system variable.
Example 3
The report printed below illustrates the uses of statement WHEN. For each salesperson, the report lists invoiced sales and year-to-date totals for sales, commissions paid, commissions owed, and the commission payroll amount.
The report is formatted as follows:
Note: A column numbering line has been provided at the top and bottom of the sample report for your convenience. This line is not an actual report line.
Figure 282 Data for WHEN Structure – Example 3
-+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+-
INTRAC INC. SALES OPERATIONS DEPARTMENT DATE 28/04/00 TIME 23:50 PAGE 1
S A L E S C O M M I S S I O N S D E T A I L FROM 01/01/99 TO 30/04/99
SALESPERSON HARVEY J. JONES (197)| INVOICE # | INVOICE DATE| AMOUNT | STATUS
+--------------------------------------------------------------------------------------------
| CJ39394 | 02/02/00 | 2040.00 |COLLECTION|
| CJ98443 | 03/03/00 | 245.00 | |
| MJ24545 | 05/04/00 | 10344.40 | |
| RJ10030 | 01/02/00 | 5329.39 | |
| RJ12233 | 02/02/00 | 5000.00 | |
| RJ30021 | 03/02/00 | 16670.10 | |
| RJ32991 | 02/03/00 | 30300.44 | |
| RJ33939 | 03/03/00 | 900.25 | |
| RJ38001 | 05/04/00 | 1000.23 | |
| RJ93043 | 06/04/00 | 415.89 | |
+--------------------------------------------------------------------------------------------
TOTAL SALES - THIS MONTH 72245.70 |PAID IN FULL
ADJUSTMENTS -5800.70
YTD SALES (INCLUDING THIS MONTH) -127879.00
YTD COMMISSIONS PAID 0.00
YTD COMMISSIONS OWED -5115.00
COMMISSION PAYROLL AMOUNT 5115.00
-+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+-
Year-to-date commissions paid, year-to-date commissions owed, and commission payroll amount for each salesperson are extracted from this report. These numbers are compared to determine if the data in the report are balanced.
The string YTD COMMISSIONS PAID is found once for each salesperson in the report. Each time the string is found, the DO EXTRACT statement extracts the three commission figures. For each salesperson, the sum of the year-to-date commissions paid and the commission payroll amount should equal the year-to-date commissions owed. This formula indicates whether the figures are balanced.
Figure 283 WHEN Structure – Example 3
LIBRARY : CTB.PROD.RULES RULE : ARWARN02
COMMAND ===> SCROLL===> CRSR
+-----------------------------------------------------------------------------+
EXECUTE INPUT UPON C
ON SYSOUT PROCST PGMST STEP01 DDNAME SYSUT2 JOBNM
MODE PG LINECT 0000 DATASTAMP
WHEN LINE 001 - 060 COL 001 - 025 STOP AND/OR
STRING = YTD COMMISSIONS PAID
DO EXTRACT = YTDPAID
LEVEL 0 LINE +000 COL 0068 - 0078 PROCESS TYP
DO EXTRACT = YTDOWED
LEVEL 0 LINE +001 COL 0068 - 0078 PROCESS TYP
DO EXTRACT = CURRENT
LEVEL 0 LINE +002 COL 0068 - 0078 PROCESS TYP
DO BLOCK = CHECK ARG C
DO
WHEN LINE - COL - STOP AND/OR
STRING =
DO
===========================================================================
EXECUTE ENDJOB UPON C
ON DATA
IF ERRORCOUNT>0 C
DO PRINT = %%BLANK F C
PLEASE FILL IN RULE DEFINITION. 14.58.28
Example 4
A sysout of a report is provided below to illustrate the uses of statement WHEN. The report shows a sample banking statement with fields for check number, account number, bank number, transaction date, and transaction amount.
Every debit line begins with D.
Every credit line begins with C.
Note: Column numbering lines have been provided at the top and the bottom of the sample report for your convenience. These lines are not actual report lines.
Figure 284 Data for WHEN Structure – Example 4
----+----1----+----2----+----3----+----4----+----5----
D 0001042 4489/54 663 05/04/00 + 5000.00
C 0001231 6297/53 660 09/10/00 + 250.00
D 0000411 3242/32 659 07/08/00 + 10500.50
C 0000012 4487/34 659 05/06/00 + 670.24
C 0001333 8834/18 663 12/10/00 + 1000.45
C 0001031 3233/10 663 12/12/00 + 1000450.75
C 0001173 3233/32 659 05/10/00 - 150.00
D 0001122 4353/01 663 05/10/00 + 904.99
C 0000099 1252/10 659 06/04/00 - 100.80
D 0001050 3341/33 663 05/01/00 - 350.55
D 0001283 9893/34 663 26/05/00 - 50.00
D 0001001 1234/56 660 18/05/00 + 3000.00
D 0001023 3422/39 663 10/08/00 + 250.25
C 0000835 4200/10 663 05/05/00 - 250.25
D 0001560 2229/09 660 08/12/00 + 2000000.00
----+----1----+----2----+----3----+----4----+----5----
Each line that starts with C is located and all the credits are added to Database variable DB_CREDIT. Each line that starts with D is located and all the debits are added to Database variable DB_DEBIT. Summation is performed during the extraction because the TYP parameter is set to SU.
Figure 285 WHEN Structure – Example 4
LIBRARY : CTB.PROD.RULES RULE : BANKSTAT
COMMAND ===> SCROLL===> CRSR
+-----------------------------------------------------------------------------+
OWNER M43 GROUP BANKING
UPDATED 08/08/00 - 15:17:14 BY M43A
DESC TOTAL CREDITS AND DEBITS OF BANK STATEMENT
OPTIONS
===========================================================================
EXECUTE GETOWED UPON C
ON SYSOUT PROCST PGMST STEP12 DDNAME ACCREP JOBNM
MODE DS LINECT 0000 DATASTAMP
WHEN LINE 001 - 999 COL 002 - 002 STOP AND/OR
STRING = C
DO EXTRACT = DB_CREDIT
LEVEL LINE +000 COL 0004 - 0010 PROCESS TYP SU
DO
WHEN LINE 001 - 999 COL 002 - 002 STOP AND/OR
STRING = D
DO EXTRACT = DB_DEBIT
LEVEL LINE +000 COL 0004 - 0010 PROCESS TYP SU
DO
WHEN LINE - COL - STOP AND/OR
STRING =
PLEASE FILL IN RULE DEFINITION. 15.21.56
The report on the following page illustrates additional uses of statement WHEN. The report shows the status of accounts receivable for a company. It is formatted as follows:
Note: Column numbering lines have been provided at the top and the bottom of the sample report for your convenience. These lines are not actual report lines.
Examples 5, 6 and 7 are based on this sample report.
Figure 286 Data for WHEN Structure – Examples 5, 6, and 7
---+----1----+----2----+----3--——+----4----+----5----+----6----+----7----+----8----+----9----
ACCOUNTS RECEIVABLE DEPARTMENT DATE 28/12/99 PAGE 000001
C L I E N T H I S T O R Y D E T A I L FROM 01/01/99 TO 05/05/99
|ACCOUNT MAIN ACCOUNTING CONS. (MAC) |INVOICE|INVOICE DATE|AMOUNT |AMOUNT DUE|STATUS
+--------------------------------------------------------------------------------------------
| |CJ98443| 03/03/99 | 245.00| 0.00 |
| |MJ24545| 05/04/99 |10344.40| 0.00 |
| |RJ10030| 01/02/99 | 5329.39| 0.00 |
| |RJ12233| 02/02/99 | 5000.00| 0.00 |
| |RJ30021| 03/02/99 |16670.10| 0.00 |
| |RJ32991| 02/03/99 |30300.44| 0.00 |
| |RJ33939| 03/03/99 | 900.25| 0.00 |
| |RJ38001| 05/04/99 | 1000.23| 0.00 |
| |RJ93043| 05/04/99 | 415.89| 0.00 |
+--------------------------------------------------------------------------------------------
| TOTALS | | |70205.70| 0.00 | PAID IN FULL
ACCOUNTS RECEIVABLE DEPARTMENT DATE 28/12/99 PAGE 000002
C L I E N T H I S T O R Y D E T A I L FROM 01/01/99 TO 05/05/99
|ACCOUNT GENERAL COMP. SYSTEMS (GCS)|INVOICE|INVOICE DATE|AMOUNT |AMOUNT DUE|STATUS
+--------------------------------------------------------------------------------------------
| | 100322| 02/01/99 | 1000.00| 1000.00|
| | 100400| 02/01/99 | 500.00| 500.00|
| | 100405| 02/01/99 | 500.00| 500.00|
| | 100520| 02/02/99 | 333.34| 333.34|
| | 100560| 02/02/99 | 3000.00| 3000.00|
| | 100561| 02/02/99 | 250.00| 250.00|
| | 100678| 02/02/99 | 1000.00| 1000.00|
| | 200001| 01/03/99 | 250.00| 250.00|
| | 200012| 01/03/99 | 333.33| 333.33|
| | 200300| 01/04/99 | 500.00| 500.00|
| | 200456| 01/04/99 | 500.00| 500.00|
| | 202533| 05/04/99 | 1000.00| 1000.00|
| | 300003| 12/04/99 | 250.00| 250.00|
| | 340203| 26/04/99 | 333.33| 333.33|
+--------------------------------------------------------------------------------------------
| | | | | |CONTINUE
ACCOUNTS RECEIVABLE DEPARTMENT PAGE 000003
C L I E N T H I S T O R Y D E T A I L FROM 01/01/99 TO 05/05/99
|ACCOUNT GENERAL COMP. SYSTEMS (GCS)|INVOICE|INVOICE DATE|AMOUNT |AMOUNT DUE|STATUS
+--------------------------------------------------------------------------------------------
| | 343211| 26/04/99 | 500.00| 500.00 |CONTINUED
| | 350032| 04/05/99 | 1000.00| 1000.00 |
| | 520033| 05/05/99 | 500.00| 500.00 |
| | 540050| 05/05/99 | 2000.00| 2000.00 |
| | 540051| 05/05/99 | 1000.00| 1000.00 |
| | 540052| 05/05/99 | 250.00| 250.00 |
+--------------------------------------------------------------------------------------------
| TOTALS | | |15000.00| 15000.00 | TOTAL DUE:
15000.00
ACCOUNTS RECEIVABLE DEPARTMENT DATE 28/12/99 PAGE 000004
C L I E N T H I S T O R Y D E T A I L FROM 01/01/99 TO 05/05/99
|ACCOUNT NATIONAL BANK |INVOICE |INVOICE DATE|AMOUNT |AMOUNT DUE|STATUS
+--------------------------------------------------------------------------------------------
| |B7003003| 02/02/99 | 1800.00| 300.00|
| |B7003420| 03/03/99 | 2700.00| 2700.00|
| |B7004009| 05/04/99 | 1500.00| 1500.00|
| |B7018700| 05/05/99 | 500.00| 500.00|
+--------------------------------------------------------------------------------------------
| TOTALS | | | 5000.00| 5000.00| TOTAL DUE:
300.00
---+----1----+----2----+----3--——+----4----+----5----+----6----+----7----+----8----+----9----
Example 5
The financial status of client General Comp. Systems (GCS) is determined.
Two WHEN statements, logically connected by the AND parameter, are specified. These two WHEN statements form one compound WHEN statement.
When both strings are located, the DO statements in this WHEN block are processed. In this example, the DO statements are executed only once. Control-M/Analyzer does not continue searching for string TOTALS because the last DO statement specified is DO TERMINAT.
Figure 287 WHEN Structure – Example 5
LIBRARY : CTB.PROD.RULES RULE : GCSSTAT
COMMAND ===> SCROLL===> CRSR
+-------------------------------------------------------------------------------+
======= >>>>>>>>>>>>>>> TOP OF RULE DEFINITION PARAMETERS <<<<<<<<<<<<<<< =======
OWNER M18B GROUP ACCOUNTS
UPDATED 09/09/99 - 15:30:05 BY M18B
DESC REPORT THE STATUS OF GENERAL COMP. SYSTEMS
OPTIONS
=============================================================================
EXECUTE REPGCS UPON C
ON SYSOUT PROCST PGMST STEP01 DDNAME SYSUT2 JOBNM
MODE PG LINECT 0060 DATASTAMP
WHEN LINE 004 - 004 COL 002 - 050 STOP AND/OR A
STRING = ACCOUNT GENERAL COMP. SYSTEMS (GCS)
WHEN LINE 006 - 060 COL 002 - 010 STOP AND/OR
STRING = TOTALS
DO EXTRACT = NAME
LEVEL 1 LINE +000 COL +008 - +034 PROCESS TYP
DO EXTRACT = STATUS
LEVEL 2 LINE +000 COL +092 - +116 PROCESS TYP
DO PRINT = STATUS OF COMPANY %%NAME F C
DO PRINT = IS %%STATUS F C
DO TERMINAT = OK COD 0000
PLEASE FILL IN RULE DEFINITION. 12.23.19
Example 6
Building on the previous example, a summary report (that provides a list of company names and their financial status) is created.
Two WHEN statements, that are similar to the WHENs of the previous example, are specified. In this example, the search for a new client should resume each time a new page is reached (because each client starts on a new page). STOP criteria are added to the highest WHEN. These STOP criteria search for operator .SP. (start of page) that identifies a new page.
As a result of this definition, Control-M/Analyzer searches for the string ACCOUNT again on every new page. Control-M/Analyzer finds the name of the current client, and locates the string TOTALS until the end of the report is reached.
Figure 288 WHEN Structure – Example 6
LIBRARY : CTB.PROD.RULES RULE : SUMREP
COMMAND ===> SCROLL===> CRSR
+------------------------------------------------------------------------------+
OWNER M18B GROUP ACCOUNTS
UPDATED 09/09/99 - 15:30:05 BY M18B
DESC SUMMARIZE THE ORIGINAL REPORT
OPTIONS
============================================================================
EXECUTE REPORT UPON C
ON SYSOUT PROCST PGMST STEP01 DDNAME SYSUT2 JOBNM
MODE PG LINECT 0060 DATASTAMP
WHEN LINE 004 - 004 COL 002 - 015 STOP Y AND/OR A
STRING = ACCOUNT
STOP LINE 001 - 006 COL 002 - 010
STRING = .SP.
WHEN LINE 006 - 060 COL 002 - 015 STOP AND/OR
STRING = TOTALS
DO EXTRACT = NAME
LEVEL 1 LINE +000 COL +008 - +034 PROCESS TYP
DO EXTRACT = STATUS
LEVEL 2 LINE +000 COL +092 - +116 PROCESS TYP
DO PRINT = %%NAME-%%STATUS F C
DO
PLEASE FILL IN RULE DEFINITION. 14.43.36
Example 7
The average invoice amount for each company is calculated by specifying three WHEN statements, connected by AND parameters. The first two WHEN statements specify STOP criteria. These three WHEN statements form one WHEN block.
The third WHEN statement locates the actual invoice amounts. Control-M/Analyzer retrieves amounts from exactly one line after the first line of dashes. Processing finishes when the second line of dashes is reached.
Figure 289 WHEN Structure – Example 7
LIBRARY : CTB.PROD.RULES RULE : AVERAGES
COMMAND ===> SCROLL===> CRSR
+------------------------------------------------------------------------------+
EXECUTE CALCAVG UPON C
ON SYSOUT PROCST PGMST STEP01 DDNAME SYSUT2 JOBNM
MODE PG LINECT 0060 DATASTAMP
WHEN LINE 005 - 005 COL 002 - 011 STOP Y AND/OR A
STRING = ACCOUNT
STOP LINE 006 - 060 COL 002 - 015
STRING = TOTALS
WHEN LINE 006 - 060 COL 001 - 020 STOP Y AND/OR A
STRING = ————
STOP LINE 007 - 060 COL 001 - 020
STRING = ————
WHEN LINE L02+001 - 060 COL 070 - 081 STOP AND/OR
STRING = .AL.
DO EXTRACT = FULLNAME
LEVEL 1 LINE +000 COL +008 - +034 PROCESS TYP
DO EXTRACT = SHRTNAME
LEVEL 1 LINE +000 COL +031 - +033 PROCESS TYP
DO BLOCK = CHKNAME ARG SHRTNAME,FULLNAME
DO EXTRACT = AVG%%SHRTNAME C
LEVEL 0 LINE +000 COL +000 - +011 PROCESS TYP AV
PLEASE FILL IN RULE DEFINITION. 14.09.00
Example 8
The input for this example is a bank customer report. The account balance (variable AMOUNT) is extracted from "detail lines" that contain a ‘C’ (for Credit) or ‘D’ (for Debit) in column 2. The extracted quantities are summed by record type (C or D). The detail lines can be identified and the account balance can be extracted and summed with one WHEN statement.
The DO EXTRACT statements illustrated below first extract the record type (C or D), and then sum the AMOUNT by record type. This is done by dynamically incorporating the record type (C or D) as part of the variable name (AMOUNT%%TYPE).
Figure 290 WHEN Structure – Example 8
LIBRARY : CTB.ALL.RULES RULE : WHEN01
COMMAND ===> SCROLL===> CRSR
+-----------------------------------------------------------------------------+
OWNER M55 GROUP INTRAC
UPDATED 08/08/00 - 17:45:92 BY M55
DESC COMPOUND WHEN CRITERIA
OPTIONS
===========================================================================
EXECUTE INPUT UPON C
ON SYSOUT PROCST PGMST DDNAME BANKREP JOBNM
MODE PG LINECT DATASTAMP
WHEN LINE 001 -060 COL - 002 - 002 STOP AND/OR
STRING = C.OR.D
DO EXTRACT = TYPE
LEVEL 0 LINE +000 COL 0002 - 0002 PROCESS TYP
DO EXTRACT = AMOUNT%%TYPE
LEVEL LINE +000 COL 0060 - 0070 PROCESS BFNUM TYP SU
DO
WHEN LINE - COL - STOP AND/OR
STRING =
DO
===========================================================================
EXECUTE UPON C
PLEASE FILL IN RULE DEFINITION. 17.47.18
Example 9
The input for this example is an employee report. The employee number, salary and vacation days are extracted from detail lines that contain any digit in column 9. (Column 9 contains the first digit of the employee number.)
The required operations can be accomplished with one WHEN statement. The WHEN statement searches for any character that is less than or equal to 9 and greater than or equal to zero.
Figure 291 WHEN Structure – Example 9
LIBRARY : CTB.ALL.RULES RULE : WHEN01
COMMAND ===> SCROLL===> CRSR
+-----------------------------------------------------------------------------+
OWNER M55 GROUP INTRAC
UPDATED 08/08/00 - 17:45:92 BY M55
DESC COMPOUND WHEN CRITERIA
OPTIONS
===========================================================================
EXECUTE INPUT UPON C
ON SYSOUT PROCST PGMST DDNAME BANKREP JOBNM
MODE PG LINECT DATASTAMP
WHEN LINE 001 - 060 COL 009 - 009 STOP AND/OR
STRING = .LT.9 .AND. .GT.0
DO EXTRACT = EMP_NUM
LEVEL 0 LINE +000 COL 0009 - 0019 PROCESS TYP
DO EXTRACT = SALARY
LEVEL LINE +000 COL 0060 - 0070 PROCESS TYP
DO EXTRACT = VACATION
LEVEL LINE +000 COL 0050 - 0055 PROCESS TYP
DO BLOCK = CHECK ARG C
DO
WHEN LINE - COL - STOP AND/OR
STRING =
PLEASE FILL IN RULE DEFINITION. 17.47.18
Parent Topic |