I have a file that breaks into two parts, I want to drop the first part and keep only the second. I can recognize where the division in the file is by a unique character string showing up in a certain column. When I see that string, for the first time, in the specified column in the file I want to keep that line and all following lines. I will want to drop all the prior lines.
Say I had an 80 byte file where I wanted to keep all records once I found the string 'keep now' in column 1. I would want this
Code:
aaa
bbb
ccc
keep now
ddd
eee
keep now
fff
to become this:
Code:
keep now
ddd
eee
keep now
fff
I can't use a skiprec command because where the 'keep now' string occurs in the file will vary. This string also has the ability to occur multiple times in the file in the specified column but it is the first occurance that indicates where the split should be.
Skolusu - Thanks your solution worked perfectly. Now I'm greedy and want more. I see how the numbering is being put into columns 81 through 89 to count occurences of the keyword and then the INCLUDE portion of the statement then only keeps records where the count is 1 or more.
The file I am trying to break apart has say five sections. I know where a section starts by the presence of a keyword in column 1. This section ends and the next section starts when the new keyword is encountered. I tried expanding your example to add more columns of count data so that I could then break apart the file by looking at the count columns. I tried for an hour or so to code the OVERLAY statements but couldn't do it.
I emphasize I need results something like the above, doesn't have to be exactly this way. As long as it comes out in a way that'll allow me to use the include statement to break out the sections. For example in the above I could find section 2 as being those records with counter 2 being greater than zero and counter three being 0.
The example you gave me was for breaking out one section. If I could see how to do two sections I think I'd be able to expand to 'n' sections myself.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Div Grad,
Do you need counts just so that want to break the contents ? you dont have to add a count for each key, you can do it all with 1 count itself. Let us know what exactly you want to do. Show us examples of sample input and output datasets along with DCb properties.
Skolusu - Yes I just want to break the file into parts, the counts themselves aren't important other than as an aid in breaking up the file into bits.
What I'm trying to break apart is a print formatted listing of a program written in IDEAL. The listing comes out with the sections always in the following order:
IDENTIFICATION
RESOURCES
ENVIRONMENT
PARAMETER
WORKING DATA
PROCEDURE
I know when I've hit the start of a section when I see the keyword in column one. I know I've hit the end of the section, and the start of the next, when I see the next keyword show up in column 1.
I'm working with a file formatted for printing, with page headers at the top of each page showing the keyword (section name) so I can encounter one individual keyword many times in a row before hitting the next new keyword. For example if the parameter section was six pages long then I'd know where the parameter section started by the first occurance of the word 'parameter' but then I would see five more occurances of this word before I finally hit the words 'working data' and knew the next section started.
For some reason this is not working for me. I finally resorted to cut/pasting in the example given and running that unaltered but I still get unexpected results. I get the following outputs:
TOOLMSG
Code:
********************************* TOP OF DATA ***********************
SYT000I SYNCTOOL RELEASE 1.5.1 - COPYRIGHT 2004 SYNCSORT INC.
SYT001I INITIAL PROCESSING MODE IS "STOP"
SYT002I "TOOLIN" INTERFACE BEING USED
SPLICE FROM(IN) TO(OUT) WITHALL KEEPBASE KEEPNODUPS -
ON(81,8,CH) WITH(01,80) USING(CTL1)
SYT020I SYNCSORT CALLED WITH IDENTIFIER "0001"
SYT031I NUMBER OF RECORDS PROCESSED: 000000000000022
SYT026I NUMBER OF SELECTED RECORDS: 000000000000022
SYT030I OPERATION COMPLETED WITH RETURN CODE 0
SYT004I SYNCTOOL PROCESSING COMPLETED WITH RETURN CODE 0
******************************** BOTTOM OF DATA *********************
DFSMSG
Code:
1 SYNCSORT FOR Z/OS 1.2.1.0NI U.S. PATENTS: 4210961, 5117495 (C) 2005 SYNCSORT INC. DATE=2008/077 TIME=15.23.43
SUNGARD z/OS 1.7.0
PRODUCT LICENSED FOR CPU SERIAL NUMBER *****, MODEL **** *** LICENSE/PRODUCT EXPIRATION DATE: 02 APR 2011
CTL1CNTL :
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(01,14,CH,EQ,C'IDENTIFICATION',OR,
01,12,CH,EQ,C'WORKING DATA',OR,
01,11,CH,EQ,C'ENVIRONMENT',OR,
01,09,CH,EQ,C'RESOURCES',OR,
01,09,CH,EQ,C'PARAMETER',OR,
01,09,CH,EQ,C'PROCEDURE'),
OVERLAY=(81:SEQNUM,8,ZD,89:1,14)),
IFTHEN=(WHEN=NONE,
OVERLAY=(89:SEQNUM,8,ZD,
81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
OUTFIL FNAMES=UNWANT,SAVE,BUILD=(01,80)
PARMLIST :
OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=IN,SORTDD=CTL1,SORTOUT=OUT,DYNALL
OC,CMP=CLC,NOVLSHRT,EQUALS
SORT FIELDS=(00081,0008,CH,A)
MODS E35=(SYNCT#35,4096,,N)
WER428I CALLER-PROVIDED IDENTIFIER IS "0001"
WER108I IN : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER257I INREC RECORD LENGTH = 102
WER238I POTENTIALLY INEFFICIENT USE OF INREC
WER110I OUT : RECFM=FB ; LRECL= 102; BLKSIZE= 102
WER110I IDOUT : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER110I WDOUT : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER110I ENOUT : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER110I REOUT : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER110I PAOUT : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER110I PROUT : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER110I UNWANT : RECFM=FB ; LRECL= 80; BLKSIZE= 80
WER055I INSERT 22, DELETE 22
WER405I OUT : DATA RECORDS OUT 22; TOTAL RECORDS OUT 22
WER405I IDOUT : DATA RECORDS OUT 0; TOTAL RECORDS OUT 0
WER405I WDOUT : DATA RECORDS OUT 0; TOTAL RECORDS OUT 0
WER405I ENOUT : DATA RECORDS OUT 0; TOTAL RECORDS OUT 0
WER405I REOUT : DATA RECORDS OUT 0; TOTAL RECORDS OUT 0
WER405I PAOUT : DATA RECORDS OUT 0; TOTAL RECORDS OUT 0
WER405I PROUT : DATA RECORDS OUT 0; TOTAL RECORDS OUT 0
WER405I UNWANT : DATA RECORDS OUT 22; TOTAL RECORDS OUT 22
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
WER054I RCD IN 22, OUT 22
WER169I RELEASE 1.2 BATCH 0454 TPF LEVEL 1.0
WER052I END SYNCSORT - RJMPRINT,STEP0100,,DIAG=8E00,40C4,A28E,00EE,C672,68EA,A6C8,2662
The only file that gets populated is the UNWANT file and it comes out as:
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Div Grad,
My Job works fine with DFSORT. You are using Syncsort. DFSORT and Syncsort are competitive products. I'm a DFSORT developer. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
Oops, I recently changed jobs and have moved from a dfsort shop to a syncsort shop without realizing it. I'd specify icetool in the jcl but synctool was being swapped in without my realizing it. I generally just look at the output file and not the other files generated by the run.
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
Div Grad wrote:
Oops, I recently changed jobs and have moved from a dfsort shop to a syncsort shop without realizing it. I'd specify icetool in the jcl but synctool was being swapped in without my realizing it.
No problem. I just wanted to make a point for everyone reading this. It's important if you switch jobs to note what products are installed and what versions they are running. I always insist on my first day that they provide me with a detailed and up-to-date list of all the add-on and third-party products installed.