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
 

 

How to wirte JCL Sort for two input files

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Venkat K

New User


Joined: 29 Jun 2009
Posts: 6
Location: Hyderabad

PostPosted: Mon Aug 10, 2009 10:45 am    Post subject: How to wirte JCL Sort for two input files
Reply with quote

Hi All,

Could you please help any one ..how to achieve the below sort query using JCL SORT

I have two input files File A and File B. Both the files contains header, details and trailer records.

Detail record contains account details. I have to merge both files records by sorting on Account number key and generates one output file.
This new sort output file contains header and trailer record from File B file.

Only change the Trailer record count on the file B, trailer record contains total number of details records of File A and File B and write it to the sort output file.
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Aug 10, 2009 11:21 am    Post subject:
Reply with quote

Hi Vekant,
Please specify below..
RECFM,LRECL of input and output files.

How header detail and trailer records are identified?

Show us sample records and desired output for the same.
Back to top
View user's profile Send private message
Venkat K

New User


Joined: 29 Jun 2009
Posts: 6
Location: Hyderabad

PostPosted: Mon Aug 10, 2009 11:29 am    Post subject:
Reply with quote

For the both input and output files
Record format fixed and record lengh 31 bytes

Header records are indentified by HDR-REC-ID = 'HDR'

and Trailer record identified by TRL-REC-ID = ‘TRL’
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Aug 10, 2009 12:15 pm    Post subject:
Reply with quote

Hi Venkat You have not provided all the information asked for..
Anyways,
I have assumed detail records are identified by REC
Below sort step will give you what you have asked for.
Code:

//S1    EXEC  PGM=SORT                 
//SYSOUT    DD  SYSOUT=*               
//SORTMSG    DD  SYSOUT=*             
//SORTIN DD *                         
HDRHEADER1                             
RECACC01                               
RECACC03                               
TRL00000002TR1                         
/*                                     
//  DD *                               
HDR HEADER2                           
RECACC02                               
RECACC05                               
RECACC04                               
TRL00000003TR2                         
/*                                     
//SYSOUT   DD SYSOUT=*                 
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  SORT FIELDS=(1,3,CH,A,4,5,CH,A)                                           
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(32:ID=1)),
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'TRL',AND,32,1,ZD,EQ,1),     
  PUSH=(33:4,8))                                                   
                                                                   
  OUTREC IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL',AND,32,1,ZD,EQ,2),         
  OVERLAY=(4:4,8,ZD,ADD,33,8,ZD,ZD,LENGTH=8))                       
                                                                   
  OUTFIL BUILD=(1,31),                                             
  OMIT=((1,3,CH,EQ,C'HDR',AND,32,1,ZD,EQ,1),OR,                     
        (1,3,CH,EQ,C'TRL',AND,32,1,ZD,EQ,1))                       
/*                                                                 

Output of the same will be..

Code:

HDR HEADER2         
RECACC01           
RECACC02           
RECACC03           
RECACC04           
RECACC05           
TRL00000005TR2     
Back to top
View user's profile Send private message
Venkat K

New User


Joined: 29 Jun 2009
Posts: 6
Location: Hyderabad

PostPosted: Mon Aug 10, 2009 5:12 pm    Post subject:
Reply with quote

Hi Sambhaji,

Sorry for the late reply

The header, Details and trailer records format as follows:

Header record
========
WS-HEADER-REC 31/GRP
5 HDR-REC-KEY 2/AN 00
5 HDR-REC-ID 3/AN HDR
5 HDR-FILE-ID 7/AN ABCD123
5 HDR-DATE-CREATE 5/NUM 12345
5 HDR-DATE-USED 5/NUM 12346
5 HDR-REEL-NO 3/NUM 123
5 HDR-REC-CNT 6/PS 1

Detail record
==========
WS-DETAIL-REC 31/GRP
5 DTL-BRANCH 5/NUM 12345
5 DTL-ACCOUNT 6/NUM 123456
5 DTL-BNOTE-IND 1/AN
5 DTL-COE-REASON 1/AN
5 DTL-SSN-NO-IND 1/AN
5 DTL-SSN-NO-X 9/AN 123456789
5 DTL-SSN-NO REDEFINES DTL-SSN-NO-X
5 DTL-SSN-NO 9/NUM 123456789
5 DTL-PRIOR-COE-REASON 1/AN 0
5 FILLER 7/AN

Trailer record:
=========
3 WS-TRAILER-REC 31/GRP
5 TRL-REC-KEY 2/AN 00
5 TRL-REC-ID 3/AN TRL
5 TRL-FILE-ID 7/AN XYZD456
5 TRL-DATE-CREATE 5/NUM 12345
5 TRL-DATE-USED 5/NUM 12346
5 TRL-REEL-NO 3/NUM 123
5 TRL-REC-CNT 6/PS 4

Total file length 31 bytes

Please proivde the solution..I would appriciate your help on this..
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Aug 10, 2009 10:24 pm    Post subject: Reply to: How to wirte JCL Sort for two input files
Reply with quote

venkat k,

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD DSN=your 31 byte input file1,DISP=SHR
//         DD DSN=your 31 byte input file2,DISP=SHR
//SYSIN    DD *                                             
  SORT FIELDS=(32,1,CH,A,6,6,CH,A),EQUALS                   
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,31,C'1')),               
  IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR'),OVERLAY=(32:C'0')),       
  IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),OVERLAY=(32:C'9'))         
                                                             
  OUTREC IFTHEN=(WHEN=INIT,                                 
  OVERLAY=(33:SEQNUM,6,PD,SEQNUM,8,ZD,RESTART=(32,1))),     
  IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),                           
  OVERLAY=(25:33,6,PD,SUB,+2,PD,LENGTH=6))                   
                                                             
  OUTFIL BUILD=(1,31),                                       
  OMIT=(32,1,ZD,EQ,0,AND,39,8,ZD,GT,1,OR,                   
        32,1,ZD,EQ,9,AND,39,8,ZD,EQ,1)   
                   
/*
Back to top
View user's profile Send private message
Venkat K

New User


Joined: 29 Jun 2009
Posts: 6
Location: Hyderabad

PostPosted: Tue Aug 11, 2009 9:41 am    Post subject:
Reply with quote

But I am getting below errors

-------- PROCESSING SYSIN --------
SORT FIELDS=(32,1,CH,A,6,6,CH,A),EQUALS,
INREC IFTHEN=(WHEN=INIT,BUILD=(1,31,C'1')),
E2 - DSS10066E - POSITIONAL PARAMETER 'INREC' IS NOT VALID. IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR'),OVERLAY=(32:C'0')),
IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),OVERLAY=(32:C'9'))
E3 - DSS10070E - UNIDENTIFIED CHARACTER '=' WAS FOUND IN THE 'IFTHEN'
FIELD.
E4 - DSS11051E - UNRECOGNIZED 'SORT' KEYWORD 'IFTHEN'.

OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(33:SEQNUM,6,PD,SEQNUM,8,ZD,RESTART=(32,1))),
IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
OVERLAY=(25:33,6,PD,SUB,+2,PD,LENGTH=6))
E5 - DSS10065E - PARAMETER 'IFTHEN' IS UNIDENTIFIED.
E6 - DSS10065E - PARAMETER 'IFTHEN' IS UNIDENTIFIED.


OUTFIL BUILD=(1,31),
OMIT=(32,1,ZD,EQ,0,AND,39,8,ZD,GT,1,OR,
32,1,ZD,EQ,9,AND,39,8,ZD,EQ,1)


------- END OF UTILITY PROGRAM OUTPUT -------

--- END OF STEP ---
--- END OF JOB ---

JOB ITD69DTA CONSISTS OF 2 PROGRAM(S), 0 PROC(S), 0 INCLUDE(S), 8 DD
STATEMENT(S)
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Tue Aug 11, 2009 9:55 am    Post subject:
Reply with quote

Hi,

the errors you are getting are not sort related but part of JSCAN or equivalent.

It just that JSCAN is not in sync with all the features of DFSORT.

Just submit the job and see the outcome.


Gerry
Back to top
View user's profile Send private message
Venkat K

New User


Joined: 29 Jun 2009
Posts: 6
Location: Hyderabad

PostPosted: Tue Aug 11, 2009 10:18 am    Post subject:
Reply with quote

Hi Gerry,

I am getting output file message like this..

00HDRDDA62221234512346123
00TRLDDA62221234512346123 <
00HDREGCD6321234512346123
00TRLEGC63221234512346123 <
12345123456 1234567890
12345123456 1234567820
12345123456 1234567890
12345123456 1234567820
12345123457 1234567800
12345123457 1234567800
12345123458 1234567811
12345123458 1234567811

I need second file header and trailer records..not both files header and trailer records.
and total count should be update in the second file trailer records.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Aug 11, 2009 9:05 pm    Post subject:
Reply with quote

venkat,

The above shown control cards assume that the string HDR , TRL start in pos 1. Looks like it starts in pos 3 . Use the following control cards

Code:

//SYSIN    DD *                                         
  SORT FIELDS=(32,1,CH,A,6,6,CH,A),EQUALS               
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,31,C'1')),           
  IFTHEN=(WHEN=(1,5,CH,EQ,C'00HDR'),OVERLAY=(32:C'0')), 
  IFTHEN=(WHEN=(1,5,CH,EQ,C'00TRL'),OVERLAY=(32:C'9'))   
                                                         
  OUTREC IFTHEN=(WHEN=INIT,                             
  OVERLAY=(33:SEQNUM,6,PD,SEQNUM,8,ZD,RESTART=(32,1))), 
  IFTHEN=(WHEN=(1,5,CH,EQ,C'00TRL'),                     
  OVERLAY=(25:33,6,PD,SUB,+2,PD,LENGTH=6))               
                                                         
  OUTFIL BUILD=(1,31),                                   
  OMIT=(32,1,ZD,EQ,0,AND,39,8,ZD,GT,1,OR,               
        32,1,ZD,EQ,9,AND,39,8,ZD,EQ,1)                   
/*
Back to top
View user's profile Send private message
Venkat K

New User


Joined: 29 Jun 2009
Posts: 6
Location: Hyderabad

PostPosted: Wed Aug 12, 2009 5:03 pm    Post subject:
Reply with quote

Thank you Kolusu ...

It's working fine..
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    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 Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm


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