Peter,
this could be a more useful version:
//ST020 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
H 05 COMMENT: "05" IS SIGNIFICANT DATA COLUMNS
D 12345 XYZ ABC DEF
D 45678 GHI JKL MNO
H 10
D 1234567890 ABCDEFGHIJKL
D 9876543210 MNOPQWRSTUVWXYZ
/*
//SORTOUT DD DSN=&SK,DISP=(,PASS),SPACE=(TRK,(1,1,),RLSE)
//SYMNAMES DD *
LLREC,80 LLREC
LLREC1,+80 LLREC WITH + SIGN
S1,X'7D'
/*
//SYSIN DD *
INCLUDE COND=(1,1,CH,EQ,C'H')
INREC FIELDS=(3,2,
3,2,ZD,ADD,+3,TO=ZD,LENGTH=2,
LLREC1,SUB,3,2,ZD,TO=ZD,LENGTH=2,
LLREC1,SUB,+0,TO=ZD,LENGTH=2)
SORT FIELDS=(1,2,BI,A)
SUM FIELDS=NONE
OUTFIL FNAMES=SORTOUT,REMOVECC,
OUTREC=(2X,C'IFTHEN=(WHEN=(81,2,CH,EQ,C',S1,
1,2,S1,C'),BUILD=(1,',3,2,C',',5,2,C'X)),',80:X),
TRAILER1=(' IFTHEN=(WHEN=NONE,BUILD=(1,',7,2,'))')
/*
//ST030 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
H 05 COMMENT: "05" IS SIGNIFICANT DATA COLUMNS
D 12345 XYZ ABC DEF
D 45678 GHI JKL MNO
H 10
D 1234567890 ABCDEFGHIJKL
D 9876543210 MNOPQWRSTUVWXYZ
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),
PUSH=(81:3,2))
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),
BUILD=(1,80)),
// DD DSN=&SK,DISP=(OLD,DELETE)
ST020 analyze only "H" records and builds one "build" statement per every
found length.
At the end (trailer1) inserts the WHEN=NONE statement needed to obtain the
right lrecl in output.
I assumed the value in the H records is always > 3.
Pls, let me know if it worked.
Best regards.
Max
Il giorno mer 8 gen 2020 alle ore 09:50 Massimo Biancucci <[email protected]>
ha scritto:
> Peter,
>
> I don't know how long is your record, assuming it's 80 and that the LL
> field in H record is between 1 and .... 99, this could be a solution:
>
> //SYSIN DD *
> INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),
> PUSH=(81:3,2))
> SORT FIELDS=COPY
> OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),
> BUILD=(1,80)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'01'),
> OVERLAY=(04:76X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'02'),
> OVERLAY=(05:75X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'03'),
> OVERLAY=(06:74X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'04'),
> OVERLAY=(07:73X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'05'),
> OVERLAY=(08:72X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'06'),
> OVERLAY=(09:71X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'07'),
> OVERLAY=(10:70X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'08'),
> OVERLAY=(11:69X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'09'),
> OVERLAY=(12:68X)),
> IFTHEN=(WHEN=(81,2,CH,EQ,C'10'),
> OVERLAY=(13:67X))
> /*
>
> I stopped writing the IFTHEN at length 10, you can code the other
> statements.
>
> It's possible to "pre-analyze" the "H" records and dynamically generate
> only the needed IFTHEN statements.
>
> This is the output:
>
> H 05 COMMENT: "05" IS SIGNIFICANT DATA COLUMNS
> D 12345
> D 45678
> H 10
> D 1234567890
> D 9876543210
>
> Hope this helps.
>
> Best regards.
> Max
>
> Il giorno mer 8 gen 2020 alle ore 01:34 Farley, Peter x23353 <
> [email protected]> ha scritto:
>
>> I have a fixed-record-length data file which has "subsections" starting
>> with a "data characteristics" record (call it a "subsection header"). One
>> of the fields in the "subsection header" is a 2-byte zoned decimal "data
>> length" value which identifies the number of SIGNIFICANT columns in the
>> "data" portion of the records following the "subsection header".
>>
>> What I would like to do is to blank out the NON-significant data columns
>> in the data records that follow each "subsection header". The data records
>> have suffered from some "data pollution" where non-significant data has
>> been accidentally stored beyond the significant data columns.
>>
>> Each "subsection header" may have a different "significant data" length
>> value for the following data records.
>>
>> Example INPUT data (column 1 = record type [H = header, D = data], data
>> starts in column 3 in each record):
>>
>> H 05 COMMENT: "05" IS SIGNIFICANT DATA COLUMNS
>> D 12345 XYZ ABC DEF
>> D 45678 GHI JKL MNO
>> H 10
>> D 1234567890 ABCDEFGHIJKL
>> D 9876543210 MNOPQWRSTUVWXYZ
>>
>> Example OUTPUT data (column 1 = record type [H = header, D = data], data
>> starts in column 3):
>>
>> H 05 COMMENT: "05" IS SIGNIFICANT DATA COLUMNS
>> D 12345
>> D 45678
>> H 10
>> D 1234567890
>> D 9876543210
>>
>> Obviously I can write a pretty simple script or program to accomplish
>> this "data cleaning" operation, but I wondered if it would be possible
>> using just SORT.
>>
>> The data volume is in the range of about 100K-200K records per file if
>> that matters.
>>
>> TIA for any ideas you can offer.
>>
>> Peter
>> --
>>
>>
>>
>> ----------------------------------------------------------------------
>> For IBM-MAIN subscribe / signoff / archive access instructions,
>> send email to [email protected] with the message: INFO IBM-MAIN
>>
>
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN