IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

sort a file having header and trailer records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mahua Mitra

New User


Joined: 26 Apr 2007
Posts: 49
Location: Delhi

PostPosted: Fri Jul 13, 2007 2:43 pm
Reply with quote

Hi,
I have a file having header and trailer records. My requirement is to sort both the fields. if the header is 'BANK ACCT' then bank account number should be written in the oupu file, and if the 14th-17th position is PREV , then the check number must be in the output file. I need this to be done in a single sort step.

BANK ACCT 001036

CHECK CHECK
NUMBER STATUS ISSUE AMOUNT ACTG DATE PAID DAT

19900000 PREV $4,000.00 6 15 1997
CURR
CNCL $4,000.00 6 15 1997


Thanks in advance,
Mahua
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jul 13, 2007 2:52 pm
Reply with quote

Mahua Mitra wrote:

Code:
BANK ACCT  001036                                                     

CHECK            CHECK                                         
NUMBER           STATUS     ISSUE AMOUNT   ACTG DATE   PAID DAT

19900000         PREV        $4,000.00     6 15 1997         
                 CURR     
                 CNCL        $4,000.00     6 15 1997         
You have given a fine example of your input, how about a fine example of you expected output?
Back to top
View user's profile Send private message
Mahua Mitra

New User


Joined: 26 Apr 2007
Posts: 49
Location: Delhi

PostPosted: Fri Jul 13, 2007 3:16 pm
Reply with quote

My ouput must be
001036
19900000

Thanks in advance
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Jul 13, 2007 3:53 pm
Reply with quote

Mahua Mitra
Here you go
Code:
//*******************************************************               
//STEP1    EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
BANK ACCT  001036                                                       
CHECK            CHECK                                                 
NUMBER           STATUS     ISSUE AMOUNT   ACTG DATE   PAID DAT         
19900000         PREV        $4,000.00     6 15 1997                   
                 CURR                                                   
                 CNCL        $4,000.00     6 15 1997                   
/*                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
           SORT FIELDS=COPY                                             
 INCLUDE COND=(1,9,CH,EQ,C'BANK ACCT',OR,18,4,CH,EQ,C'PREV')           
 OUTREC IFTHEN=(WHEN=(1,9,CH,EQ,C'BANK ACCT'),BUILD=(12,6)),   
        IFTHEN=(WHEN=(18,4,CH,EQ,C'PREV'),BUILD=(1,8))                 
/*                                                                     
SORTOUT
Code:
----+----1
001036   
19900000 
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top