by BillyBoyo » Sun Nov 27, 2016 3:11 am
LENGTH OF WS-HOLIDAY-RECORD is seven. It need not, in IBM Enterprise COBOL, be subscripted - all the entries are fixed-length, so id doesn't matter if you use ( 1 ), ( 2 ), ( 3 ) or nothing. All the same.
Adding one to seven gets eight. The advantage of calculating using LENGTH OF (which is evaluated at compile-time for fixed-length fields) is that if someone changes the length of WS-HOLIDAY-RECORD, the code still works, "automatically".
The code is doing what was intended. It is an "offset move", a way of establishing a "pattern" across a table.
When COBOL's WORKING-STORAGE was more limited in size (1MB maximum) the "offset move" was the most effective way to initialise a table of packed-decimal values, or of a table with a more complicated structure.
For this example, with an exceedingly simple pattern (zeroes) I'd just MOVE ZERO TO WS-HOLI-TABLE and have done with it.
A better technique to use to efficiently initialise a table these days is to have a another table the same size (or larger), set your entire table to initial values (once) by your preferred method, and then MOVE the entire table to the second table. Then, when you need to re-initialise, MOVE the second to the first.