When explicit subscripting is used, the procedure logic must ensure that the proper occurrence of the repeating group view is accessed at any given time.
The current occurrence is identified by its subscript. The value of a repeating group view's subscript is a number that corresponds to its position in the repeating view.
For example, consider a circus application in which the names and relative sizes of the circus's elephants are stored in a repeating group view. It might look like this:
|
Elephant Name |
Size |
|
DUMBO |
puny |
|
HUMONGO |
large |
|
KING FORTINBRAS THE BRAVE |
huge |
|
LEON |
medium |
If the repeating group view's subscript is set to 1, the occurrence for dumbo is current. If it is set to 4, the occurrence for LEON is correct.
Subscript values are set using the SUBSCRIPT option of the SET action. Each explicitly indexed repeating group view has a single subscript called SUBSCRIPT OF repeating-group-view. Assuming that the elephant list is stored in the repeating group view Elephants, the following action points to the occurrence for KING FORTINBRAS THE BRAVE:
SET SUBSCRIPT OF Elephants TO 3
When iterating through an explicitly subscripted repeating group view, the procedure logic must increment the subscript explicitly and must test for the end of the group explicitly. In the example shown in the following sample code causes the size of each elephant in the repeating group view to be set to elephantine.
Explicit Subscripting
SET SUBSCRIPT OF elephants TO 1
WHILE
SUBSCRIPT OF elephants IS LESS THAN OR EQUAL TO LAST OF elephants
SET elephant size TO elephantine
SET SUBSCRIPT OF elephants TO SUBSCRIPT OF elephants +1
Had the repeating group view Elephants been defined as implicitly subscripted, the statement in the following sample code would accomplish the same result.
Implicit Subscripting
CHECK HOLIDAY
IMPORTS: Entity View incoming customer
EXPORTS: Entity View work status
LOCALS: Entity View work date
Entity View order_item
SET work date request TO HOLIDAY TEST
USE date_services WHICH IMPORTS incoming customer
work date
WHICH EXPORTS work status
IF work status flag IS EQUAL TO H
FOR EACH elephants
EXIT STATE IS shipment_requested_on_a_holiday
SET elephant_size TO “elephantine”
Note: Using implicit subscripting eliminates the need to initialize, maintain, and test the subscript value.
Certain action diagram constructs apply only to explicitly indexed repeating group views:
The special attributes SUBSCRIPT OF, LAST OF, and MAX OF are used in numeric expressions.
SUBSCRIPT OF and LAST OF can be the target of a SET statement.
|
Copyright © 2013 CA.
All rights reserved.
|
|