Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Possible to skip records until a char string found?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Div Grad

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Fri Mar 14, 2008 12:45 am    Post subject: Possible to skip records until a char string found?
Reply with quote

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.

Thanks in advance!
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Mar 14, 2008 1:14 am    Post subject:
Reply with quote

Div gad,

Try this DFSORT job

Code:

//STEP0100 EXEC PGM=ICEMAN                           
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                       
AAA                                                   
BBB                                                   
CCC                                                   
KEEP NOW                                             
DDD                                                   
EEE                                                   
KEEP NOW                                             
FFF                                                   
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  INREC IFTHEN=(WHEN=INIT,                           
       OVERLAY=(81:SEQNUM,8,ZD)),                     
        IFTHEN=(WHEN=(1,8,CH,EQ,C'KEEP NOW'),         
       OVERLAY=(81:SEQNUM,8,ZD)),                     
        IFTHEN=(WHEN=NONE,                           
       OVERLAY=(89:SEQNUM,8,ZD,                       
                81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
                                                     
  SORT FIELDS=COPY                                   
  OUTFIL INCLUDE=(81,8,ZD,GE,1),BUILD=(01,80)         
/*                                                   
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Fri Mar 14, 2008 4:07 am    Post subject:
Reply with quote

Hi,
here is a FILEAID that will do the trick as well

Code:
//FILEAID1 EXEC PGM=FILEAID                   
//SYSPRINT DD SYSOUT=*                         
//DD01     DD *                               
AAA                                           
BBB                                           
CCC                                           
KEEP NOW                                       
DDD                                           
EEE                                           
KEEP NOW                                       
FFF                                           
//DD01O    DD SYSOUT=*                         
//SYSIN    DD *                               
$$DD01 SPACE STOP=(01,EQ,C"KEEP NOW")         
$$DD01 COPY                                   



Gerry
Back to top
View user's profile Send private message
Div Grad

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Fri Mar 14, 2008 9:51 pm    Post subject:
Reply with quote

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 want a file that looks like this

Code:

jjj
key1
aaa
bbb
ccc
key 1
ddd
eee
key 2
fff
ggg
hhh
key 3
iii
jjj
key 4
kkk
lll
key 5
mmm
nnn


to become something like this

Code:

jjj          0 0 0 0 0 01
key1         1 0 0 0 0 02
aaa          1 0 0 0 0 03
bbb          1 0 0 0 0 04
ccc          1 0 0 0 0 05
key 1        2 0 0 0 0 06
ddd          2 0 0 0 0 07
eee          2 0 0 0 0 08
key 2        2 1 0 0 0 09
fff          2 1 0 0 0 10
ggg          2 1 0 0 0 11
hhh          2 1 0 0 0 12
key 3        2 1 1 0 0 13
iii          2 1 1 0 0 14
jjj          2 1 1 0 0 15
key 4        2 1 1 1 0 16
kkk          2 1 1 1 0 17
lll          2 1 1 1 0 18
key 5        2 1 1 1 1 19
mmm          2 1 1 1 1 20
nnn          2 1 1 1 1 21


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.

Again, thanks in advance.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Mar 14, 2008 10:35 pm    Post subject: Reply to: Possible to skip records until a char string found
Reply with quote

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.
Back to top
View user's profile Send private message
Div Grad

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Sat Mar 15, 2008 12:10 am    Post subject:
Reply with quote

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.


So I would want this one file:

Code:

xxx
xxx
xxx
IDENTIFICATION
aaa1
aaa2
IDENTIFICATION
aaa3
aaa4
RESOURCES
bbb1
bbb2
bbb3
ENVIRONMENT
ccc1
PARAMETER
ddd1
WORKING DATA
eee1
PROCEDURE
fff1
fff2


To be split into the following files:


Code:

xxx
xxx
xxx

Code:

IDENTIFICATION
aaa1
aaa2
IDENTIFICATION
aaa3
aaa4

Code:

RESOURCES
bbb1
bbb2
bbb3

Code:

ENVIRONMENT
ccc1

Code:

PARAMETER
ddd1

Code:

WORKING DATA
eee1

Code:

PROCEDURE
fff1
fff2



The lines before the first section (the xxx's in my example), I would just want to throw away, they could split into a file that I'd end up not using.

Again, thanks in advance!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Mar 15, 2008 1:06 am    Post subject: Reply to: Possible to skip records until a char string found
Reply with quote

Div Grad,

The following DFSORT/ICETOOL jcl will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN       DD *           
XXX                       
XXX                       
XXX                       
IDENTIFICATION             
AAA1                       
AAA2                       
IDENTIFICATION             
AAA3                       
AAA4                       
RESOURCES                 
BBB1                       
BBB2                       
BBB3                       
ENVIRONMENT               
CCC1                       
PARAMETER                 
DDD1                       
WORKING DATA               
EEE1                       
PROCEDURE                 
FFF1                       
FFF2                       
//IDOUT    DD SYSOUT=*     
//WDOUT    DD SYSOUT=*     
//ENOUT    DD SYSOUT=*     
//REOUT    DD SYSOUT=*     
//PAOUT    DD SYSOUT=*     
//PROUT    DD SYSOUT=*     
//UNWANT   DD SYSOUT=*     
//OUT      DD DUMMY       
//TOOLIN   DD *                                           
  SPLICE FROM(IN) TO(OUT) WITHALL KEEPBASE KEEPNODUPS -   
      ON(81,8,CH) WITH(01,80) USING(CTL1)                 
//CTL1CNTL DD *                                           
  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))     
                                                         
  SORT FIELDS=COPY                                       
                                                         
  OUTFIL FNAMES=IDOUT,BUILD=(01,80),                     
  INCLUDE=(89,14,CH,EQ,C'IDENTIFICATION')
                 
  OUTFIL FNAMES=WDOUT,BUILD=(01,80),                     
  INCLUDE=(89,12,CH,EQ,C'WORKING DATA')
                   
  OUTFIL FNAMES=ENOUT,BUILD=(01,80),                     
  INCLUDE=(89,11,CH,EQ,C'ENVIRONMENT')
                   
  OUTFIL FNAMES=REOUT,BUILD=(01,80),                     
  INCLUDE=(89,09,CH,EQ,C'RESOURCES')
                     
  OUTFIL FNAMES=PAOUT,BUILD=(01,80),                     
  INCLUDE=(89,09,CH,EQ,C'PARAMETER')
                     
  OUTFIL FNAMES=PROUT,BUILD=(01,80),                     
  INCLUDE=(89,09,CH,EQ,C'PROCEDURE')
                     
  OUTFIL FNAMES=UNWANT,SAVE,BUILD=(01,80)                 
/*
Back to top
View user's profile Send private message
Div Grad

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Tue Mar 18, 2008 1:08 am    Post subject:
Reply with quote

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))

    SORT FIELDS=COPY

    OUTFIL FNAMES=IDOUT,BUILD=(01,80),
    INCLUDE=(89,14,CH,EQ,C'IDENTIFICATION')

    OUTFIL FNAMES=WDOUT,BUILD=(01,80),
    INCLUDE=(89,12,CH,EQ,C'WORKING DATA')

    OUTFIL FNAMES=ENOUT,BUILD=(01,80),
    INCLUDE=(89,11,CH,EQ,C'ENVIRONMENT')

    OUTFIL FNAMES=REOUT,BUILD=(01,80),
    INCLUDE=(89,09,CH,EQ,C'RESOURCES')

    OUTFIL FNAMES=PAOUT,BUILD=(01,80),
    INCLUDE=(89,09,CH,EQ,C'PARAMETER')

    OUTFIL FNAMES=PROUT,BUILD=(01,80),
    INCLUDE=(89,09,CH,EQ,C'PROCEDURE')

    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:

Code:

********************************* TOP OF DATA **********************************
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q
                   q    " 0 " 0 " 0 " 0 " 0 " 0         " 0 " 0                q




If anyone can explain why I am not getting the expected results, thanks in advance.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 18, 2008 1:23 am    Post subject: Reply to: Possible to skip records until a char string found
Reply with quote

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.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4649
Location: Raleigh, NC, USA

PostPosted: Tue Mar 18, 2008 1:38 am    Post subject: Reply to: Possible to skip records until a char string found
Reply with quote

Div Grad, what changed? Your other posts clearly showed that you have or had DFSORT.
Back to top
View user's profile Send private message
Div Grad

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Tue Mar 18, 2008 2:36 am    Post subject:
Reply with quote

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.

Sorry Everyone!
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 18, 2008 3:20 am    Post subject:
Reply with quote

Hello,

As the programs are written in IDEAL, you could use the IDEAL Source Transport utility and create a sequential file of the program.

You would then not need to be concerned with headers or other formatting considerations.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4649
Location: Raleigh, NC, USA

PostPosted: Tue Mar 18, 2008 8:54 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us