Input file is variable-length with two 'occurs depending on' segments like this:
01 VARIABLE-RECORD.
02 RECORD-KEY.
03 RECORD-KEY-VALUE-1 PIC X(10).
03 RECORD-KEY-VALUE-2 PIC 9(10).
02 OCCUR-COUNTS.
03 RECURRING-SEG-1-CT PIC S9(3)V COMP-3.
03 RECURRING-SEG-2-CT PIC S9(3)V COMP-3.
02 RECURRING-SEG-1.
03 RECURRING-SEG-1-DATA OCCURS 0 TO 48 TIMES
DEPENDING ON RECURRING-SEG-1-CT.
04 FIELD-1 PIC X(10).
04 FIELD-2 PIC X(8).
04 FIELD-3 PIC S9(9) COMP-3.
02 RECURRING-SEG-2.
03 RECURRING-SEG-2-DATA OCCURS 0 TO 48 TIMES
DEPENDING ON RECURRING-SEG-2-CT.
04 FIELD-4 PIC X(10).
04 FIELD-5 PIC X(8).
04 FIELD-6 PIC S9(9) COMP-3.
02 RECORD-KEY.
03 RECORD-KEY-VALUE-1 PIC X(10).
03 RECORD-KEY-VALUE-2 PIC 9(10).
02 OCCUR-COUNTS.
03 RECURRING-SEG-1-CT PIC S9(3)V COMP-3.
03 RECURRING-SEG-2-CT PIC S9(3)V COMP-3.
02 RECURRING-SEG-1.
03 RECURRING-SEG-1-DATA OCCURS 0 TO 48 TIMES
DEPENDING ON RECURRING-SEG-1-CT.
04 FIELD-1 PIC X(10).
04 FIELD-2 PIC X(8).
04 FIELD-3 PIC S9(9) COMP-3.
02 RECURRING-SEG-2.
03 RECURRING-SEG-2-DATA OCCURS 0 TO 48 TIMES
DEPENDING ON RECURRING-SEG-2-CT.
04 FIELD-4 PIC X(10).
04 FIELD-5 PIC X(8).
04 FIELD-6 PIC S9(9) COMP-3.
I am attempting to convert this variable-lenth input into a fixed-length output file. The output file needs to have enough space for 48 occurrences of both segments...if there are less than 48 then that area should be filled with spaces. The end result is a fixed file with the segments in fixed positions within the record. Like this:
01 VARIABLE-RECORD.
02 RECORD-KEY.
03 RECORD-KEY-VALUE-1 PIC X(10).
03 RECORD-KEY-VALUE-2 PIC 9(10).
02 OCCUR-COUNTS.
03 RECURRING-SEG-1-CT PIC S9(3)V COMP-3.
03 RECURRING-SEG-2-CT PIC S9(3)V COMP-3.
02 RECURRING-SEG-1.
03 RECURRING-SEG-1-DATA OCCURS 48 TIMES.
04 FIELD-1 PIC X(10).
04 FIELD-2 PIC X(8).
04 FIELD-3 PIC S9(9) COMP-3.
02 RECURRING-SEG-2.
03 RECURRING-SEG-2-DATA OCCURS 48 TIMES.
04 FIELD-4 PIC X(10).
04 FIELD-5 PIC X(8).
04 FIELD-6 PIC S9(9) COMP-3.
02 RECORD-KEY.
03 RECORD-KEY-VALUE-1 PIC X(10).
03 RECORD-KEY-VALUE-2 PIC 9(10).
02 OCCUR-COUNTS.
03 RECURRING-SEG-1-CT PIC S9(3)V COMP-3.
03 RECURRING-SEG-2-CT PIC S9(3)V COMP-3.
02 RECURRING-SEG-1.
03 RECURRING-SEG-1-DATA OCCURS 48 TIMES.
04 FIELD-1 PIC X(10).
04 FIELD-2 PIC X(8).
04 FIELD-3 PIC S9(9) COMP-3.
02 RECURRING-SEG-2.
03 RECURRING-SEG-2-DATA OCCURS 48 TIMES.
04 FIELD-4 PIC X(10).
04 FIELD-5 PIC X(8).
04 FIELD-6 PIC S9(9) COMP-3.
My approach was to write a syncsort to dynamically calculate the offsets in the input file based on the values in RECURRING-SEG-1-CT and RECURRING-SEG-2-CT, multiplied by the length of each segment. Here's what I've got:
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=FIXDFILE,
BUILD=(1:1,24,
25:25,(+23,MUL,(21,2,PD))
1128:(+24,ADD,(+23,MUL,(21,2,PD))),(+23,MUL,(23,2,PD)))
/*
SORT FIELDS=COPY
OUTFIL FNAMES=FIXDFILE,
BUILD=(1:1,24,
25:25,(+23,MUL,(21,2,PD))
1128:(+24,ADD,(+23,MUL,(21,2,PD))),(+23,MUL,(23,2,PD)))
/*
It's not working and i'm looking for some help! Getting a syntax error from syncsort:
SYSIN :
SORT FIELDS=COPY
OUTFIL FNAMES=FIXDFILE,
BUILD=(1:1,24,
*
25:25,(+23,MUL,(21,2,PD))
1128:(+24,ADD,(+23,MUL,(21,2,PD))),(+23,MUL,(23,2,PD)))
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
SORT FIELDS=COPY
OUTFIL FNAMES=FIXDFILE,
BUILD=(1:1,24,
*
25:25,(+23,MUL,(21,2,PD))
1128:(+24,ADD,(+23,MUL,(21,2,PD))),(+23,MUL,(23,2,PD)))
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
Any suggestions or help is greatly appreciated!!!!