Nuadha wrote:Sorry, I should say "less flexible" rather than clumsy
Each record with it's sub record is based on this template:
01 XB-SUB-RECORD.
05 XB-SUBRECORD-HEADER.
07 XB-SUBRECORD-NAME PIC X(08).
07 XB-SUBRECORD-VERSION PIC X(03).
07 XB-SUBRECORD-DATA-LENGTH PIC S9(04) COMP.
05 XB-SUBRECORD-DATA OCCURS 1 TO 700 TIMES
DEPENDING ON SUBRECORD-DATA-LENGTH.
A "deblocking" system in our COBOL modules already exists that does what I'm trying to do, but there's talk of change to the record lengths, and as I'm currently developing a new utility, I was looking for a way of handling what I'm trying to do above without having to change COBOL in the future, i.e. make it less dependent on fixed lengths (of the subrecords).
01 the-mother-record.
any-id-stuff-for-the-mother-record here.
03 FILLER.
10 FILLER OCCURS 0 TO whatever-your-max-is TIMES
DEPENDING ON W-DISPLACEMENT-FROM-START-OF-RECORD.
03 MINI-RECORD.
05 XB-SUBRECORD-HEADER.
07 XB-SUBRECORD-NAME PIC X(08).
07 XB-SUBRECORD-VERSION PIC X(03).
07 XB-SUBRECORD-DATA-LENGTH PIC S9(04) COMP.
05 XB-SUBRECORD-DATA OCCURS 1 TO 700 TIMES
DEPENDING ON SUBRECORD-DATA-LENGTH.
Now you only have one ODO to amend. Starting from zero (after any fixed portion of the main record) until fixed portion + variable already moved + fixed of mini + variable of mini is equal to the record length of the main record.
MOVE MINI-RECORD TO DEBLOCKED-RECORD (presumably also ODO, so set that size first).
Should always work as long as the records adhere to the definition you've already given. I'd check the subrecord-name each time and also that the version has a reasonable value and that the subrecord-data-length does not go over the end of the record, so basically checking that the file is consistent as far as you are able.