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
 

 

Sort Mulitple files with Header & Detail records in 1 st

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Tue Sep 20, 2011 2:59 pm    Post subject: Sort Mulitple files with Header & Detail records in 1 st
Reply with quote

Hi..
I have multiple files(34 to be specific) which need to be sorted using one control card. The files will have Header, Detail and trailer records and Only detail records need to be sorted. Header and trialer records can be identified with A and Z in the first position of the record. All other records are detail records. I have used below JCL to sort only detail records.
Sample Data:

A12334
DDETAIL DATA123
MDETAIL DATA123
YDETAIL DATA123
Ztotal records 3


//STEP020 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DISP=SHR,DSN=FILE1
//IN2 DD DISP=SHR,DSN=FILE2
//IN3 DD DISP=SHR,DSN=FILE3
//OUT1 DD DISP=SHR,DSN=FILE1OUT
//OUT2 DD DISP=SHR,DSN=FILE2OUT
//OUT3 DD DISP=SHR,DSN=FILE3OUT
//DUP DD DSN=DUPFILE,DISP=SHR
//*
//TOOLIN DD *
DATASORT FROM(IN1) TO(OUT1) HEADER TRAILER USING(CTL1)
DATASORT FROM(IN2) TO(OUT2) HEADER TRAILER USING(CTL1)
DATASORT FROM(IN3) TO(OUT3) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=(1,80,CH,A)
INREC BUILD=(1:1,80)
/*
//SYSOUT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSDUMP DD SYSOUT=*


However, this job fails when the file has multiple header and trailer records like below.

A12334
DDETAIL DATA123
MDETAIL DATA123
YDETAIL DATA123
Ztotal records 3
A12335
DDETAIL DATA124
MDETAIL DATA124
Ztotal records 2

Could someone suggest an alternative.

Thanks,
Vamshi
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 20, 2011 3:21 pm    Post subject: Reply to: Sort Mulitple files with Header & Detail recor
Reply with quote

Have a look here. What are your DCBs and RECFMs? Can you concatenate the 34 files on one DD?

This topic was just a few below yours in the DFSORT forum. It seems to be common these days to just toss headers and trailers into the data without any thought for later sorting the file.

Code:

file header  = key set low, indicator, data for file header
data header  = key of data, indicator, data for data header
data         = key of data, indicator, data
data trailer = key of data, indicator,  data for data trailer
....
file trailer = key set high, indicator, data for file trailer

Then you can always sort the data without having to worry about where the headers/trailers are going to end up.
Back to top
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Tue Sep 20, 2011 5:02 pm    Post subject: Reply to: Sort Mulitple files with Header & Detail recor
Reply with quote

I have 34 different files which needed to be sorted to corresponding 34 output files. I can not concatenate them in one DD. I've no idea whether or not this can be achieved using SORT utility. Also, I had difficulties understanding the code given by you. Could you elucidate.
Back to top
View user's profile Send private message
THINKSRINIII
Warnings : 1

New User


Joined: 09 Jan 2009
Posts: 88
Location: India

PostPosted: Tue Sep 20, 2011 5:36 pm    Post subject:
Reply with quote

Vamshi,

Let me know whcih header and trailer you would want to have incase there are multiple headers in a file?

Is it always the first header and last trailer that you would like to retain?
Back to top
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Tue Sep 20, 2011 5:49 pm    Post subject:
Reply with quote

I need to have all headers and trailers intact. Only the detail data needs to be sorted. If I have the data in one of the files as below,
A12334
YDETAIL DATA123
MDETAIL DATA123
DDETAIL DATA123
Ztotal records 3
A12335
YDETAIL DATA124
MDETAIL DATA124
Ztotal records 2

Expected output needs to be

A12334
DDETAIL DATA123
MDETAIL DATA123
YDETAIL DATA123
Ztotal records 3
A12335
MDETAIL DATA124
YDETAIL DATA124
Ztotal records 2

Please note, not all files will have similar data. I mean, some files might have one just one header and trailer and some others might have multiple headers and trailers.
Back to top
View user's profile Send private message
THINKSRINIII
Warnings : 1

New User


Joined: 09 Jan 2009
Posts: 88
Location: India

PostPosted: Tue Sep 20, 2011 6:09 pm    Post subject:
Reply with quote

Use this:

Code:

//STEP0010 EXEC PGM=SORT                                             
//SORTIN   DD *                                                     
A12334                                                               
DDETAIL DATA123                                                     
MDETAIL DATA123                                                     
YDETAIL DATA123                                                     
ZTOTAL RECORDS 3                                                     
A12335                                                               
MDETAIL DATA124                                                     
YDETAIL DATA124                                                     
ZTOTAL RECORDS 2                                                     
//SYSOUT   DD SYSOUT=*                                               
//SYSUDUMP DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(89:C'2')),                         
       IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'A'),PUSH=(81:ID=8)),   
       IFTHEN=(WHEN=(1,1,CH,EQ,C'A'),OVERLAY=(89:C'1')),             
       IFTHEN=(WHEN=(1,1,CH,EQ,C'Z'),OVERLAY=(89:C'3'))             
 SORT FIELDS=(81,8,ZD,A,89,1,ZD,A,1,80,CH,A)             
 OUTFIL BUILD=(1,80)                                                 
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 20, 2011 8:33 pm    Post subject: Reply to: Sort Mulitple files with Header & Detail recor
Reply with quote

I wasn't giving code, I was saying that someone designed a system with at least 34 files without "internal integrity". If you drop them on the floor, or sort them, you have problems.

Fortunately for you, DFSORT/ICETOOL is an extremely flexible product which can drag your files from the mire. Is it going to do this every day? Who gets to pay for the poor design? Client, I guess.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 20, 2011 9:50 pm    Post subject:
Reply with quote

i would thing replacing your //CTL1CNTL with Elo's //SYSIN
would do the trick.
that way you have 34 inputs, 34 outputs and 34 ICETOOL statements.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Sep 20, 2011 11:07 pm    Post subject:
Reply with quote

Vamshi,

DATASORT is NOT the correct choice for this - it only deals with headers at the top and bottom, not in the middle.

The WHEN=GROUP technique is the correct way to do this. If you want to sort multiple files with ICETOOL, you would need multiple SORT operators.
You could use a DFSORT/ICETOOL job like the following:

Code:

//STEP020 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/80)
//IN2 DD DSN=... input file2 (FB/80)
...
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/80)
...
//*
//TOOLIN DD *
SORT FROM(IN1) TO(OUT1) USING(CTL1)
SORT FROM(IN2) TO(OUT2) USING(CTL1)
...
/*
//CTL1CNTL DD *
 INREC IFTHEN=(WHEN=INIT,
   OVERLAY=(81:1,1,CHANGE=(1,C'A',C'0',C'Z',C'9'),NOMATCH=(C'2'))),
       IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'A'),PUSH=(82:ID=8))
 SORT FIELDS=(82,8,ZD,A,81,1,CH,A,1,80,CH,A)
 OUTFIL BUILD=(1,80)
/*
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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