*---------*---------------*-----------------*----------------*---------------* | CODE | FACTOR 1 | FACTOR 2 | RESULT | INDICATORS | | | | | FIELD | | *---------*---------------*-----------------*----------------*---------------* | CABXX | Comparand | Comparand | Label | HI LO EQ | *---------*---------------*-----------------*----------------*---------------*
The CABxx operation compares factor 1 with factor 2. If the condition specified by xx is true, the program branches to the TAG operation associated with the label specified in the result field. Otherwise, the program continues with the next operation in the sequence. If the result field is not specified, the resulting indicators (positions 54-59) are set accordingly, and the program continues with the next operation in the sequence.
You can specify conditioning indicators. Factor 1 and factor 2 must contain a character literal, a numeric literal, a named constant, a figurative constant, a field name, a table name, an array element, or a data structure name. Both the factor 1 and the factor 2 entries must be character data, or both must be numeric.
The CABxx operation can specify a branch:
The CABxx operation cannot specify a branch from outside a subroutine to a TAG or ENDSR operation within that subroutine. Branching from one part of the RPG/400 logic cycle to another may result in an endless loop. You must ensure that the logic of your program does not produce undesirable results. The label specified in the result field must be associated with a unique TAG operation and must be a unique symbolic name.
Resulting indicators are optional. When specified, they are set to reflect the results of the compare operation. For example, the HI indicator is set when F1>F2, LO is set when F1<F2, and EQ is set when F1=F2.
See Compare Operations for the rules for comparing factor 1 with factor 2. Figure "CABxx Operations" illustrates uses of the CABxx operation.
*...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C* The field values are: C* FLDA = 100.00 C* FLDB = 105.00 C* FLDC = ABC C* FLDD = ABCDE C* C* Branch to TAGX. C FLDA CABLTFLDB TAGX C* C* Branch to TAGX. C FLDA CABLEFLDB TAGX C* C* Branch to TAGX; indicator 16 is off. C FLDA CABLEFLDB TAGX 16 C* C* Branch to TAGX; indicator 17 is off, indicator 18 is on. C FLDA CAB FLDB TAGX 1718 C* C* Branch to TAGX; indicator 19 is on. C FLDA CAB FLDA TAGX 19 C* C* No branch occurs. C FLDA CABEQFLDB TAGX C* C* No branch occurs; indicator 20 is on. C FLDA CABEQFLDB TAGX 20 C* C* No branch occurs; indicator 21 is off. C FLDC CABEQFLDD TAGX 21 C TAGX TAG
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.