SORT query

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
srinivas
Member
Posts: 9
Joined: Wed Feb 08, 2006 2:58 pm
Location: Bangalore

SORT query

Post by srinivas » Mon Oct 09, 2006 2:21 pm

Hi,

I have 3 i/p files having same header and tailer. My requirement is to copy all the three files to a single o/p with only one trailer and hearder.Pls find the below example.

File1
------
Hearder
01433435466
01213232322
04354574585
Trailer

File2
------
Header
47934739748
49574957498
57457495448
39473974938
Trailer

File3
------
Header
58458400098
34384738698
Trailer

o/p File
---------
Header
01433435466
01213232322
04354574585
47934739748
49574957498
57457495448
39473974938
58458400098
34384738698
Trailer

Can any one suggest me how to solve this using SORT. Thanks

Regards,

Srinivas.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Oct 09, 2006 10:13 pm

Is there something unique about the header that identifies it (e.g. 'HDR' in positions 1-3) or is it just the first record of every file?

Is there something unique about the trailer that identifies it (e.g. 'TRL' in positions 1-3) or is it just the last record of every file?

Is the header and trailer in every file the same, so it doesn't matter which one you keep?

What is the RECFM and LRECL of each input file?
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

rahul_kolhe
Member
Posts: 12
Joined: Wed Nov 08, 2006 1:03 am

Post by rahul_kolhe » Wed Nov 08, 2006 1:33 am

The easiest way by using Xsum if you have same header and trailer in all three file and content of all three files is not duplicate. You can avoid XSUM part and SORTXSUM file.

//STEP01 EXEC PGM=SORT,REGION=0M
//SORTIN DD DSN=AAA,DISP=SHR
// DD DSN=BBB,DISP=SHR
// DD DSN=BBB,DISP=SHR
//SORTOUT DD DSN=AAA.dup,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(2000,500),RLSE),
// DCB=(MODELDCB,RECFM=FB,LRECL=270,DSORG=PS)
//SORTXSUM DD DSN=,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(2000,500),RLSE),
//* UNIT=TAPEA,EXPDT=2005/365,
// DCB=(MODELDCB,RECFM=FB,LRECL=270,DSORG=PS)
//SYSIN DD *
SORT FIELDS=copy
SUM FIELDS=NONe,XSUM
END
//SYSOUT DD SYSOUT=*
//*


Hope this will help! :roll:

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Nov 08, 2006 2:20 am

rahul,

Your "solution" makes no sense. SUM FIELDS=NONE is ignored with SORT FIELDS=COPY. You must use SORT or MERGE with a key in order for SUM FIELDS=NONE to eliminate records. The key determines the duplicates to be eliminated. If you sorted on positions 1-7 to try to keep only one Header and one Trailer, you would remove duplicate data records as well, and also sort Header and Trailer before the data records. Also, if all of the header and trailer records are not the same, you might get the wrong one. Additionally, XSUM has no relevance for this requirement.

The questions I asked are relevant to the solution.

In the future, please try your "solutions" to ensure they work before posting them.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others