which was brilliant for splitting a massive file (150,000,000 records) into 4 files.
What I would like to know is if there is a simple method of displaying the first/last keys for each file (based on positions 22,32 for the KEYBEGIN).
NOTE that this is something of a nice-to-have, so a scan through the files twice would make the job not worth doing. _________________ Michael
Joined: 26 Nov 2002 Posts: 12373 Topics: 75 Location: San Jose
Posted: Mon Nov 14, 2016 9:42 am Post subject: Re: Print first and last Keys as part of INCLUDE
misi01 wrote:
What I would like to know is if there is a simple method of displaying the first/last keys for each file (based on positions 22,32 for the KEYBEGIN).
Misi01,
It is quite simple to get the minimum key and the maximum key. Do you want the minimum key as the first record and maximum key as the last record in the same files that you are splitting?
or do you need to write them to a separate file? with the min and max keys as report? _________________ Kolusu
www.linkedin.com/in/kolusu
Joined: 02 Dec 2002 Posts: 628 Topics: 176 Location: Stockholm, Sweden
Posted: Tue Nov 15, 2016 1:56 am Post subject: Thanks Kolusu
Doesn't have to be anything fancy. As long as the results don't go to the output files (SYSOUT, SYSPRINT or whatever are fine).
Something along the lines of (here's my guestimate of the code, tried adding bold text within the code, but that doesn't seem to work)
Code:
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(22,32),PUSH=(1001:ID=8))
OUTFIL FNAMES=D799301,INCLUDE=(1001,8,ZD,LE,750000),BUILD=(1,1000)
print 'D799301, first id 'id=1', last id = 'id=750000
OUTFIL FNAMES=D799302,INCLUDE=(1001,8,ZD,GT,750000,AND,
1001,8,ZD,LE,2000000),BUILD=(1,1000)
OUTFIL FNAMES=D799303,INCLUDE=(1001,8,ZD,GT,2000000,AND,
1001,8,ZD,LE,3000000),BUILD=(1,1000)
OUTFIL FNAMES=D799304,SAVE,BUILD=(1,1000)
A further OUTFIL. You know the ID of the first and last group in each OUTFIL, except for the SAVE. so an INCLUDE= for the known numbers. BUILD to just have the information you want. Then with reporting functions NODETAIL,REMOVECC and SECTIONS with TRAILER3 and a TRAILER1 to get the last group on the "SAVE" OUTFIL.
You also would need to change the "SAVE" OUTFIL, because you are now INCLUDEing two records from what was on that OUTFIL SAVE, so they will no longer be there... is that clear? SAVE gets you everything which doesn't appear on another OUTFIL. If you then make something which would otherwise appear on the SAVE appear on another OUTFIL, it will no longer appear on the SAVE.
Can change SAVE to GT,3000000.. Entirely safe to do so, as they are sequentially allocated numbers.
OUTFIL FNAMES=KEYRPT,NODETAIL,REMOVECC,BUILD=(80X),
SECTIONS=(1010,1,
HEADER3=('D79930',1010,1,C', FIRST ID = ',22,32),
TRAILER3=('D79930',1010,1,C', LAST ID = ',22,32,/))
//*
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum