| wobconsult 2005-09-21, 6:55 pm |
| We have a situation where we have a "bunch" of BMS/GT Maps that had
been generated by this product, with many map copybooks created with an
OCCURS "whatever" for multiple screen detail-lines.
Normally, we dynamically calculate the maximum "OCCURS", providing a
group-level existed on top of the "OCCURS" line. But in this case, we
don't have that ability and we tried to come up with a method, short of
writing an Assembler sub-program to pass addresses and do the math.
However, we came across a "strange" way to arrive at the maximum
"OCCURS", using FUNCTION SUM and an unorthodoxed initialization method.
We defined an unsigned binary-fullword in WS (let's call it
WS-SUB-MAX), as PIC 9(08) BINARY. A portion of the MAP copybook would
look something like this -
03 BMSGT001-LINE OCCURS 15 TIMES.
05 MAP-DESCR-LEN PIC S9(04) BINARY.
05 MAP-DESCR-ATTR PIC X(01).
05 MAP-DESCR-DATA PIC X(65).
Then, to arrive at the maximum occurs and after initializing the entire
MAP copybook to HIGH-VALUES in HOUSEKEEPING (this was the strange
part), we issued -
COMPUTE WS-SUB-MAX = FUNCTION SUM(MAP-DESCR-LEN (ALL)).
After this calculation, WS-SUB-MAX equals 15, which is the maximum
occurs. We then re-initialized the MAP copybook to LOW-VALUES and
continued. Additionally, we tried the same approach with several other
MAPS that had maximum occurs of other than 15 and the result was always
correct.
Could anyone shed some light on how this works? We've looked at the
Assembler expansion (compiling with NOOPT to see all of the dirty
details of FUNCTION SUM) and we're still scratching our heads.
The environment is VSE/ESA.
Thanks,
Bill
|