I have a file with a header type record, followed by details records. Would like to check some date values in the first record and if they match I want to write out the whole file to an output file, if they don't match, don't want to write out anything.
I know how check date values in the first record for the include, not not sure what syntax to use to get the header record and any subsequent records to be written if the condition is true
The beginning of the file is as follows and has record length of 365, The data I have in the include only occurs in record 1, however if true I want to copy the whole file to the sortout
Code:
********************************* Top of Data **********************************
000000000000{131012000001................PCR42131023131012B1130929101 000000000
000020503021{131012B18510.. ............DUMMY, NAME A 03
000020503021{131012B18523..3336766001 SUBS SX C E B0..ΓΈ.4 D TX1
The statement to do the include would be
Code:
SORT FIELDS=COPY
INCLUDE COND=(49,2,CH,EQ,C'12',AND,
63,2,CH,EQ,C'12')
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
You can identify the header (I assume uniquely) with IFTHEN=(WHEN=GROUP then PUSH those values you want to test to extended fields on every record. Then use OUTFIL INCLUDE= for the values.
If you can't do it uniquely, you can make it unique by putting a sequence number on every record with IFTHEN=(WHEN=INIT and do the GROUP with the sequence number equal to 1.
Having some problem with the statement, turns out the file is a vb file, total length 369,
I am trying to look at the input file, and if the both dates have a month of '12' write it out to decdeco, if one month is 12 and the other is 01, then write to decjano
Here is my sysout, seems to be saying I am beyond the record, but thought I was pushing the 2 fields I need to 270 for 2, 272 for 2, can you see what is wrong?
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
OK. You have SyncSort, so your topic has been moved to the JCL forum.
For a variable-length record, the trick is to do the extension at the front of the record.
Code:
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,4X,5)),
The 1,4 is the RDW, from the input which is necessary always to put in a BUILD for a variable-length record. The 4X puts four blanks in the first four data positions. The 5, with no length, says "from position 5 to the end of the current record".
Then use 1,2 and 3,2 for your PUSH. Amend the INCLUDE='s for the 1,2 and 3,2.
Then in the BUILDs on the OUTFILs:
Code:
BUILD=(1,3,9)
Copying the RDW again (necessary on each BUILD for a variable-lenght record) then then the 5th data position (record position 9) to the end of the record.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
No, not really. All your variable-length records are now fixed-length-in-variable-clothing.
If one or more of the fields you want are within the variable part of the data on the record, you need an option to give you what you want. If there is an unexpected short record, you'll need to know what it is before blindly using it :-)
Trying do use your example of doing the push at the beginning, but getting a 16, inrec rdw error?
Code:
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 3A990, MODEL 2098 N03 LICEN
SYSIN :
OPTION COPY,VLSHRT
INREC IFTHEN(WHEN=INIT,BUILD=(1,4,4X,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(46,3,CH,EQ,C'PCR'),
PUSH=(1:20,2,3:53,2))
Wanted to thank you for your help, the final sort statement which worked is as follows, adjusting the values for putting the group by values at the beginning of the record.