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 

SORT (split the files into 3 files viz..Hdr , Dtl , Trlr

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
kishore_gk
Beginner


Joined: 23 Jul 2003
Posts: 12
Topics: 8

PostPosted: Tue Nov 11, 2003 6:21 am    Post subject: SORT (split the files into 3 files viz..Hdr , Dtl , Trlr Reply with quote

Hi,

I have a file with header having Low-Values and trailer having High-Values and 1 to many detail records. I want to copy the header separately into a temp file and trailer separately into another temp file and all the details records into a separate file. I want to use Sort utility for this.

Here the input file is a variable length one with header and trailer layout being declared with COMP-3 and detail record with alpha and numeric combinations.

Could anyone help me in getting this solved.

Thanks in advance..
_________________
kishore
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Nov 11, 2003 8:53 am    Post subject: Reply with quote

kishore_gk,

Comp-3 with low-values and high-values? can you show your input with hex on for the header and trailer contents?

Your input file is VB , do you want your output files to be VB? or FB?

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: Tue Nov 11, 2003 11:34 am    Post subject: Reply with quote

Kishore,

DFSORT's equivalent of COMP-3 is PD. Let's assume that your COMP-3 field is in positions 11-14 (4-byte PD field -> 7 decimal digits and a sign). I would assume that low-values would be P'0000000' (PD zeros) and high values would be P'9999999' (PD nines). If so, then you can do what you want with a DFSORT job like this.

Note: Since your file is VB, remember to account for the 4-byte RDW at the start of each record when determining starting positions.

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...   VB input file
//HDR DD DSN=...        VB header file
//DTL DD DSN=...         VB detail file
//TRL DD DSN=...         VB trailer file
//SYSIN DD *
  OPTION COPY
  OUTFIL FNAMES=HDR,INCLUDE=(11,4,PD,EQ,+0)
  OUTFIL FNAMES=TRL,INCLUDE=(11,4,PD,EQ,+9999999)
  OUTFIL FNAMES=DTL,SAVE
/*


If your low and high values do not look like that, then just change the INCLUDE conditions appropriately to handle what they do look like. For example, if your low-values are actually all binary zeros (X'00000000') and your high-values are actually all binary ones (X'FFFFFFFF'), then you could use these OUTFIL statements:

Code:


  OUTFIL FNAMES=HDR,INCLUDE=(11,4,BI,EQ,X'00000000')
  OUTFIL FNAMES=TRL,INCLUDE=(11,4,BI,EQ,X'FFFFFFFF')
  OUTFIL FNAMES=DTL,SAVE

_________________
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
kishore_gk
Beginner


Joined: 23 Jul 2003
Posts: 12
Topics: 8

PostPosted: Wed Nov 12, 2003 12:17 am    Post subject: Reply with quote

Hi Kolusu/Frank,
Quote:

----+----1----+----2--
----+----F----+----F--
----+----1----+----2--
---------------------
**********************


---------------------
......................
0200000000000000000000
0C00000000000000000000
---------------------


is the Header record.

Quote:

----+----1----+----2--
----+----F----+----F--
----+----1----+----2--
---------------------
......................
01FFFFFFFFFFFFFFFFFFFF
0CFFFFFFFFFFFFFFFFFFFF


is the trailer record.
both of them are declared in comp-3 format. Here i want to issue the selection criteria from third column onwards.

My actual requirement is to sort the detail records in the file without disturbing header and trailer record (header should be the first record and trailer should be the last record with all other detail records in the sorted order in the output file). The sorting should be based on some sequence number present in position 80 and 10 bytes long - comp -3. My requirement is to use only Sort and not ICETOOL.

The file layout is having header and trailer declared in COMP-3 format and the detail records in combinations of alpha and numeric format.

Thanks for your reply.
_________________
kishore
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Nov 12, 2003 3:05 am    Post subject: Reply with quote

Kishore,

As frank mentioned above your data is actually binary format. Your low-values are actually all binary zeros (X'00000000') and your high-values are actually all binary ones (X'FFFFFFFF'). PGM=SORT and PGM=ICEMAN can both be used to call "SORT". The following JCl will give you the desired results. A brief explanation of the JOb.

Step0100 will split the input file into 3 different files. HDR file will have Header record and TRl will have the trailer and all the detail records are copied into TRl file.

Step0200 takes this detail records file(D1) created in step0100 and sorts on the required field and creates a temp file D2.

Step0300 concatenates header file (H1) , Sorted detail record file(D2) and trailer file(T1) and copies into a final output file.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//HDR      DD DSN=&H1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//TRL      DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//DTL      DD DSN=&D1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
  SORT FIELDS=COPY
  OUTFIL FNAMES=HDR,INCLUDE=(7,4,BI,EQ,X'00000000')
  OUTFIL FNAMES=TRL,INCLUDE=(7,4,BI,EQ,X'FFFFFFFF')
  OUTFIL FNAMES=DTL,SAVE
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=&D1,DISP=OLD
//SORTOUT  DD DSN=&D2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
  SORT FIELDS=(80,10,PD,A)
//*
//STEP0300 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=&H1,DISP=OLD
//         DD DSN=&D2,DISP=OLD
//         DD DSN=&T1,DISP=OLD
//SORTOUT  DD DSN=YOUR FINAL OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
  SORT FIELDS=COPY
//*


The same output can be achieved in just one step using DFSORT/ICETOOL. If your shop has syncsort then change the pgm name to synctool
Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN       DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//H1       DD DSN=&H1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//D1       DD DSN=&D1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//D2       DD DSN=&D2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//CON      DD DSN=&H1,DISP=OLD,VOL=REF=*.H1
//         DD DSN=&D2,DISP=OLD,VOL=REF=*.D2
//         DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//OUT      DD DSN=YOUR FINAL OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *
  COPY FROM(IN) USING(CTL1)
  SORT FROM(D1) TO(D2) USING(CTL2)
  COPY FROM(CON) TO(OUT)
//CTL1CNTL DD *
  OUTFIL FNAMES=H1,INCLUDE=(7,4,BI,EQ,X'00000000')
  OUTFIL FNAMES=T1,INCLUDE=(7,4,BI,EQ,X'FFFFFFFF')
  OUTFIL FNAMES=D1,SAVE
//CTL2CNTL DD *
  SORT FIELDS=(80,10,PD,A)
//*


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Srika
Beginner


Joined: 12 Nov 2003
Posts: 3
Topics: 2
Location: Bangalore

PostPosted: Wed Nov 12, 2003 4:49 am    Post subject: Reply with quote

Hi Kolusu,

Can you please explain me the following line in the ICETOOL step..

Quote:

//CON DD DSN=&H1,DISP=OLD,VOL=REF=*.H1
// DD DSN=&D2,DISP=OLD,VOL=REF=*.D2
// DD DSN=&T1,DISP=OLD,VOL=REF=*.T1


Here what does VOL=REF=*.H1 refers to..

Thankx
_________________
-Sri
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Nov 12, 2003 7:10 am    Post subject: Reply with quote

Srika,

That is one method of using referbacks which I use. I am concating 3 datasets and am using "*" to referback , "&" is a Symbolic Parameter.

For OLD data sets, if VOL=REF references a non-SMS-managed data set, the system assumes the data set is non-SMS-managed and on the same volume as the referenced data set. If VOL=REF references an SMS-managed data set, the system searches the catalog because the referencing data set might not be on the same volume as the referenced data set.

The other way to do is:
Code:

//CON  DD DSN=*.H1,VOL=REF=*.H1,DISP=OLD
//     DD DSN=*.D2,VOL=REF=*.D2,DISP=OLD
//     DD DSN=*.T1,VOL=REF=*.T1,DISP=OLD


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kris_madras
Beginner


Joined: 07 Apr 2004
Posts: 46
Topics: 29

PostPosted: Wed Jun 23, 2004 4:01 am    Post subject: Clarifications Reffering to the post Reply with quote

Hi,
Reffering to the post http://www.mvsforums.com/helpboards/viewtopic.php?t=1426&start=0&postdays=0&postorder=asc&highlight=cobol%20jcl%20paramaters,

Few clarifications needed from ur side


1. The INCLUDE cond for HDR and TLR are same
OUTFIL FNAMES=HDR,INCLUDE=(7,4,BI,EQ,X'00000000')
OUTFIL FNAMES=TRL,INCLUDE=(7,4,BI,EQ,X'FFFFFFFF')
OUTFIL FNAMES=DTL,SAVE

Both are starting at 7 columns of length 4 but the Trailer starts
after the data content?

2. please explain the Third statement. you didn't mentioned any include cond(Starting location and Length??? How does it assumes the starting position and length?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Jun 23, 2004 5:27 am    Post subject: Reply with quote

kris_madras,


SAVE selects the records that are not selected for any other OUTFIL group. In the control cards you see the save parm will write out all other records which are not written to HDR or TRL file

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: Tue Jun 29, 2004 12:49 pm    Post subject: Reply with quote

kris wrote
Quote:
1. The INCLUDE cond for HDR and TLR are same
OUTFIL FNAMES=HDR,INCLUDE=(7,4,BI,EQ,X'00000000')
OUTFIL FNAMES=TRL,INCLUDE=(7,4,BI,EQ,X'FFFFFFFF')
OUTFIL FNAMES=DTL,SAVE

Both are starting at 7 columns of length 4 but the Trailer starts
after the data content?


Are you concerned that the OUTFIL for the the trailer record (TRL) comes before the OUTFIL for the detail records (DTL)? If that's your question, then the answer is that it doesn't matter because when you're writing out separate OUTFIL data sets, the OUTFIL statements can be in any order. The header record will be written to the HDR data set. The trailer record will be written to the TRL data set. The detail records will be written to the DTL data set.

The CON DD then concatenates these data sets in the correct order in which they need to be read in (header record, detail records, trailer record).

Quote:
2. please explain the Third statement. you didn't mentioned any include cond(Starting location and Length??? How does it assumes the starting position and length?


For more information on the SAVE parameter of DFSORT's OUTFIL, see "OUTFIL Features" - "OUTFIL: Subsets" in "Beyond Sorting" at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/beyond_sorting/
_________________
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 -> Job Control Language(JCL) 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