MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Selection of records within provided header and footer.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Mon Jun 28, 2004 3:45 am    Post subject: Selection of records within provided header and footer. Reply with quote

Hi Gurus

This must have been covered before but I am not sure what my search string should be to retrieve the required info.

Here's the problem definiton.

In the provided input file (below) I have a multiple occurances of this structure:

Header - Sequence number
Detail
Footer - Sequence number

I need to select this sturcture for a given sequence number (it is unique for a structure and is same for header and footer).

Code:
HEAD 001187 20040628100111
DT1
DT2
DT3
FOOT 001187 20040628100111
HEAD 001188 20040628100111
DT1
DT2
DT3
FOOT 001188 20040628100111


Provided the input transmission number as 001188 I should retieve the structure:

Code:
HEAD 001188 20040628100111
DT1
DT2
DT3
FOOT 001188 20040628100111


I guess we need to do it this way:

1. Get the count of first occurance of 001188
2. Get the count of next occurance of 001188
3. Retrieve the records using this count.

But I am not sure of the syntax to retrieve this count.

Please let me know if you need more info.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Jun 28, 2004 5:09 am    Post subject: Reply with quote

Relaxing,

Try this. I assumed that your input file is 80 bytes and is of FB recfm.I also assumed that your exactly have 3 detail records. We first add a seqnum at the end. We generate a dynamic control card with startrec and endrec.

Code:

//STEP0100  EXEC  PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*     
//DFSMSG    DD SYSOUT=*     
//IN        DD *             
HEAD 001187 20040628100111   
DT1                         
DT2                         
DT3                         
FOOT 001187 20040628100111   
HEAD 001188 20040628100111   
DT1                         
DT2                         
DT3                         
FOOT 001188 20040628100111   
//OUT       DD SYSOUT=*     
//TOOLIN    DD *             
  COPY FROM(IN) USING(CTL1) 
  COPY FROM(IN) USING(CTL2) 
//CTL1CNTL  DD *                                           
  INREC FIELDS=(1,80,SEQNUM,8,ZD)                         
  OUTFIL FNAMES=CTL2CNTL,                                 
  INCLUDE=(1,4,CH,EQ,C'HEAD',AND,6,6,CH,EQ,C'001188'),     
  OUTREC=(C' OUTFIL FNAMES=OUT,STARTREC=',81,8,           
          C',ENDREC=',+4,ADD,81,8,ZD,EDIT=(TTTTTTTT),80:X)
//CTL2CNTL  DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Mon Jun 28, 2004 5:36 am    Post subject: Reply with quote

Kolusu

Thanks for the reply.
Unfortunately the detail lines are dynamic and not limited to 3. Is there a way to get the count (of record) for last occurance of the sequnce number? Then we can use this count.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Jun 28, 2004 7:52 am    Post subject: Reply with quote

Relaxing,

The following job will take care of the variable detail records.

Code:

//STEP0100  EXEC  PGM=ICETOOL                             
//TOOLMSG   DD SYSOUT=*                                   
//DFSMSG    DD SYSOUT=*                                   
//IN        DD *                                           
HEAD 001187 20040628100111                                 
DT1                                                       
DT2                                                       
DT3                                                       
FOOT 001187 20040628100111                                 
HEAD 001188 20040628100111                                 
DT1                                                       
DT2                                                       
DT3                                                       
DT4                                                       
DT5                                                       
DT6                                                       
DT7                                                       
FOOT 001188 20040628100111                                 
//C1        DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//C2        DD DSN=&C2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT       DD SYSOUT=*                                   
//TOOLIN    DD *                                           
  COPY FROM(IN) USING(CTL1)                               
  COPY FROM(IN) USING(CTL2)                               
//CTL1CNTL  DD *                                           
  INREC FIELDS=(1,80,SEQNUM,8,ZD)                         
  OUTFIL FNAMES=C1,                                       
  INCLUDE=(1,4,CH,EQ,C'HEAD',AND,6,6,CH,EQ,C'001188'),     
  OUTREC=(C' OUTFIL FNAMES=OUT,STARTREC=',81,8,C',',80:X) 
  OUTFIL FNAMES=C2,                                       
  INCLUDE=(1,4,CH,EQ,C'FOOT',AND,6,6,CH,EQ,C'001188'),     
  OUTREC=(19X,C'ENDREC=',81,8,80:X)                       
//CTL2CNTL  DD DSN=&C1,DISP=OLD,VOL=REF=*.C1               
//          DD DSN=&C2,DISP=OLD,VOL=REF=*.C2               
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Mon Jun 28, 2004 8:40 am    Post subject: Reply with quote

Thanks a lot Kolusu..The result is great. I tried understanding the code but I cannot make much headway...
When you have the time could you please elaborate this..?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Jun 28, 2004 8:59 am    Post subject: Reply with quote

Relaxing,

Very simple job.

We first add a seqnum at the end of every record using INREC.so now the record will look like

Code:

---+----1----+----2----+----3----+----8----+----5----+
HEAD 001187 20040628100111             00000001
DT1                                    00000002
DT2                                    00000003
DT3                                    00000004
FOOT 001187 20040628100111             00000005
HEAD 001188 20040628100111             00000006
DT1                                    00000007
DT2                                    00000008
DT2                                    00000009
DT2                                    00000010
DT2                                    00000011
DT2                                    00000012
DT3                                    00000013
FOOT 001188 20040628100111             00000014


once we have the seqnum then using INCLUDE On OUTFIL , we are writting 2 files(C1 & C2). C1 to have the header seqnum and file c2 to have the footer seqnum.

If we wanted to select records from a particular record we use the startrec and endrec parms to select the desired records.

If you had to select the 001188 records we would have coded as follows

Code:

 OUTFIL FNAMES=OUT,STARTREC=00000006,ENDREC=00000014


We are also doing the same, but the only difference is that we are dynamically generating the start rec and end rec parms.

C1 will be as follows
Code:

 OUTFIL FNAMES=OUT,STARTREC=00000006,


C2 will be as follows
Code:

                   ENDREC=00000014 


Now we concatenate these 2 files together and it is the CTL2CNTL which looks like this
Code:

OUTFIL FNAMES=OUT,STARTREC=00000006,
                   ENDREC=00000014   


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Mon Jun 28, 2004 9:31 am    Post subject: Reply with quote

Thanks a lot Kolusu...
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Jun 28, 2004 10:47 am    Post subject: Reply with quote

Here's another way of doing this with DFSORT usng Symbols:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//C1 DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(2,2)),DISP=(,PASS)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
* Add seqnum at end of record
  INREC FIELDS=(1,80,81:SEQNUM,8,ZD)
* SORTIN->T1:  Write records with seqnums
  OUTFIL FNAMES=T1
* SORTIN->C1: * Generate DFSORT Symbols statements as follows:
* N1,+ssssssss
* N2,+eeeeeeee
* where ssssssss is the seqnum of the start record and
*       eeeeeeee is the seqnum of the end record and
  OUTFIL FNAMES=C1,
    INCLUDE=((1,4,CH,EQ,C'HEAD',AND,6,6,CH,EQ,C'001188'),OR,
             (1,4,CH,EQ,C'FOOT',AND,6,6,CH,EQ,C'001188')),
   OUTREC=(C'N',SEQNUM,1,ZD,C',+',81,8,80:X)
/*
//S2    EXEC  PGM=ICEMAN
//SYMNAMES DD DSN=&&C1,DISP=(OLD,PASS)
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
* Use generated N1 and N2 symbols to include needed records.
  INCLUDE COND=(81,8,ZD,GE,N1,AND,81,8,ZD,LE,N2)
* Remove seqnum
  OUTREC FIELDS=(1,80)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Wed Jun 30, 2004 5:04 am    Post subject: Reply with quote

Hi Kolusu, Frank

Thanks a lot for the above code and explanation. It is a superb learning experience.

I wanted to increase the scope of this sort.
I want to include these results to the output header and footer records:

1. In the below header record:

HEAD 001187 20040628100111

001187 - stands for transmission number..
20040628 - date
100111 - Time.

I want to change the transmission number to '999999', the date to today's date (date1), time to now (time1).

Similarly in the footer. Could you help me with this.

PS: Kolusu - Why do we need to include the 19X (19 blanks) in the outrec -> OUTREC=(19X,C'ENDREC=',1601,8,1600:X)

When I remove 19X from outrec I get the message "ICE001A 0 TEXT BEGINS IN WRONG COLUMN " but I don't see why.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Wed Jun 30, 2004 5:52 am    Post subject: Reply with quote

Relaxing,

The following JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                 
//SYSOUT    DD SYSOUT=*                   
//SYSPRINT  DD SYSOUT=*                   
//SORTIN    DD *                         
HEAD 001188 20040628100111               
DT1                                       
DT2                                       
DT3                                       
DT4                                       
DT5                                       
DT6                                       
DT7                                       
FOOT 001188 20040628100111               
//SORTOUT   DD SYSOUT=*                   
//SYSIN     DD *                         
  SORT FIELDS=COPY                         
  OMIT COND=(1,4,SS,EQ,C'HEAD,FOOT')       
  OUTREC FIELDS=(1,80,DATE1,TIME1)         
  OUTFIL HEADER1=(C'HEAD 999999 ',81,14), 
        TRAILER1=(C'FOOT 999999 ',81,14) 
/*


Quote:

Why do we need to include the 19X (19 blanks) in the outrec -> OUTREC=(19X,C'ENDREC=',1601,8,1600:X)


I coded 19 blanks so that endrec parm will exactly be under the STARTREC parm. It is just my preference to have the control cards aligned.

Code:

OUTFIL FNAMES=OUT,STARTREC=00000006,
                  ENDREC=00000014 


Quote:

When I remove 19X from outrec I get the message "ICE001A 0 TEXT BEGINS IN WRONG COLUMN " but I don't see why


When you removed that 19x , sort writes the record starting from pos 1(default). And your control cards should always start from pos2.

You code a single blank so that it starts from pos2. following are the different ways of coding

Code:

C' ENDREC=',81,8,80:X)   $ Note the space before Endrec


or

Code:

X,C'ENDREC=',81,8,80:X)   $ A single space denoted by X


or

Code:

2:C'ENDREC=',81,8,80:X)   $ specify the start pos as 2


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Jun 30, 2004 10:07 am    Post subject: Reply with quote

Actually, you can put date1 and time1 directly into the header and trailer without using the OUTREC "trick". Here's the DFSORT job:

Code:

//S1 EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*
//SORTIN    DD *
HEAD 001188 20040628100111
DT1
DT2
DT3
DT4
DT5
DT6
DT7
FOOT 001188 20040628100111
//SORTOUT   DD SYSOUT=*
//SYSIN     DD *
  SORT FIELDS=COPY
  OMIT COND=(1,4,SS,EQ,C'HEAD,FOOT')
  OUTFIL HEADER1=(C'HEAD 999999 ',DATENS=(4MD),TIMENS=(24)),
        TRAILER1=(C'FOOT 999999 ',DATENS=(4MD),TIMENS=(24))
/*


DATENS=(4MD) is equivalent to DATE1 and TIMENS=(24) is equivalent to TIME1.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Thu Jul 01, 2004 1:45 am    Post subject: Reply with quote

Kolusu, Frank

Can I make the changes in the existing header and footer record (without omitting and re-adding the records). This is because the existing header and trailer are 1600 length records containing some dynamic information like number of details lines etc. which I want to retain.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Jul 01, 2004 5:21 am    Post subject: Reply with quote

Relaxing,

Try this.Use MOD as disposition for the output dataset

Code:

//STEP0100  EXEC PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*     
//DFSMSG    DD SYSOUT=*     
//IN        DD DSN=YOUR INPUT FILE,
//             DISP=SHR
//OUT       DD DSN=YOUR OUTPUT FILE,
//             DISP=(MOD,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
//TOOLIN    DD *                                             
  COPY FROM(IN) USING(CTL1)                                 
  COPY FROM(IN) USING(CTL2)                                 
  COPY FROM(IN) USING(CTL3)                                 
//CTL1CNTL  DD *                                             
  OPTION STOPAFT=1                                           
  OUTFIL FNAMES=OUT,OUTREC=(1,5,C'999999 ',DATE1,TIME1,27,1574)
//CTL2CNTL  DD *                                             
  OMIT COND=(1,4,SS,EQ,C'HEAD,FOOT')                         
  OUTFIL FNAMES=OUT                                         
//CTL3CNTL  DD *                                             
  INCLUDE COND=(1,4,CH,EQ,C'FOOT')                           
  OUTFIL FNAMES=OUT,OUTREC=(1,5,C'999999 ',DATE1,TIME1,27,1574)
/*                                                           

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Mon Jul 05, 2004 7:21 am    Post subject: Reply with quote

Hi Kolusu, Frank

How do I insert an header and a trailer (input is only detail lines) for a record length 1600? I guess we cannot use SORT (the code you mentioned above) here.
I also need to include the complete record count in the trailer file.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Jul 05, 2004 9:08 am    Post subject: Reply with quote

Relaxing,

DFSORT's HEADERx and TRAILERx parameters will create header and trailer records whose length match the length of the output LRECL. In the job below, if your input file has RECFM=FB and LRECL=1600, then the header, detail and trailer records will all be 1600 bytes. Notice that I've also included COUNT=(M11,LENGTH=6) in TRAILER1. This will place the count of the detail records in the trailer record. It will be 6 characters with leading zeros. You can use any form of COUNT=(edit) to edit the count into the format you like.

If your input records are not 1600 bytes long, but you want the output records to be 1600 bytes long, then you can use the OUTREC statement or OUTFIL OUTREC parameter to change the length of the input records to the length you want for the output records.

If you're unfamiliar with DFSORT/ICETOOL, I'd suggest you go through "DFSORT: Getting Started". It shows you, with examples, how to use the features of DFSORT, ICETOOL and DFSORT Symbols to do all kinds of things. You can access it online at:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG00/CCONTENTS

You can access all of the DFSORT books online from:

http://www.storage.ibm.com/software/sort/mvs/srtmpub.html

Code:

//S1 EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*
//SORTIN    DD DSN=...  input file
//SORTOUT   DD DSN=...  output file
//SYSIN     DD *
  SORT FIELDS=COPY
  OUTFIL HEADER1=(C'string',DATENS=(4MD),TIMENS=(24)),
        TRAILER1=(C'string',COUNT=(M11,LENGTH=6),DATENS=(4MD),TIMENS=(24))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group