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 a File

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

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Feb 10, 2010 4:02 pm    Post subject: Sort a File
Reply with quote

Hi All,

I have one input file in which we will be having one header record, some detail records and one trailor record. Details records will contain Add, Delete and Update records. it could be in any order. for ex
Add record
Delete record
Update record
Delete record
Add record
Add record
Update record etc.....

I want to write all these records (including header and trailor records) into one out put file. But the detail records should be in some order as shown below...
Delete record
Add record
Update record.

I want sort this file using JCL.

Please provide me your comments.

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

Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2284
Location: @my desk

PostPosted: Wed Feb 10, 2010 4:09 pm    Post subject:
Reply with quote

Quote:
I want sort this file using JCL.
What this has to do with COBOL? icon_rolleyes.gif ? btw which sort product are you using-DFSORT or Syncsort or something else?Which version?
Quote:
I want to write all these records (including header and trailor records) into one out put file.But the detail records should be in some order
You need to explain this "some order". And how your header and trailer records look like. Provide some real input and expected output data with all the file attributes.
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Feb 10, 2010 4:41 pm    Post subject:
Reply with quote

I am using DFSORT. I want the records in Delete, Add and Update order.
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Wed Feb 10, 2010 4:48 pm    Post subject:
Reply with quote

Do you have any field in your file which can diffrentiate it as Add,delete or Update record type??
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Feb 10, 2010 4:54 pm    Post subject:
Reply with quote

the operation Add, Delete and Update itself will differenciate the each record. Add, Delete or Update will start from location 26. Header record will be identified by using VSP at location 29 and trailor record will be identified by TRAIL at location 31.

Is it possible to use a single file instead of splitting into different files and merge them?
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Wed Feb 10, 2010 4:55 pm    Post subject: Reply to: Sort a File
Reply with quote

Hi ,
Please post the thread in related section only to get a quick response.
PLease provide sone more information about the file details so that the record can be identified. There should be some identifier to diffrentiate the records.
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Wed Feb 10, 2010 5:17 pm    Post subject: Reply to: Sort a File
Reply with quote

Hi Simha,
Below sort step will give you desired result.
I have assumed you have dataset with LRECL 80

Code:

//S1    EXEC  PGM=SORT                                         
//SORTIN DD *                                                 
HEADER                      VSP                               
ADD RECORD               ADD                                   
DELETE RECORD            DELETE                               
UPDATE RECORD            UPDATE                               
DELETE RECORD            DELETE                               
ADD RECORD               ADD                                   
ADD RECORD               ADD                                   
UPDATE RECORD            UPDATE                               
TRAILER                       TRAIL                           
//SORTOUT DD SYSOUT=*                                         
//SYSOUT    DD  SYSOUT=*                                       
//SYSIN    DD  *                                               
  SORT FIELDS=(81,1,ZD,A)                                     
  INREC IFTHEN=(WHEN=(29,3,CH,EQ,C'VSP'),OVERLAY=(81:C'0')),   
        IFTHEN=(WHEN=(26,6,CH,EQ,C'DELETE'),OVERLAY=(81:C'1')),
        IFTHEN=(WHEN=(26,6,CH,EQ,C'ADD   '),OVERLAY=(81:C'2')),   
        IFTHEN=(WHEN=(26,6,CH,EQ,C'UPDATE'),OVERLAY=(81:C'3')),   
        IFTHEN=(WHEN=NONE,OVERLAY=(81:C'4'))                     
  OUTFIL BUILD=(1,80)                                             
/*                                                               

Output will be
Code:

HEADER                      VSP     
DELETE RECORD            DELETE     
DELETE RECORD            DELETE     
ADD RECORD               ADD         
ADD RECORD               ADD         
ADD RECORD               ADD         
UPDATE RECORD            UPDATE     
UPDATE RECORD            UPDATE     
TRAILER                       TRAIL 


Let us know if you need something else than this..
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Feb 10, 2010 7:31 pm    Post subject: Re: Reply to: Sort a File
Reply with quote

Thanks for your response...LRECL is 350 for my file. When I am using 350 and 351 in place of 80 and 81, i am not getting the expected results. Showing both input file and out put file are same..
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Feb 10, 2010 7:48 pm    Post subject:
Reply with quote

What is the RECFM of the input file, is it FB or VB
Please post the SYSOUT of your run to show
a) which sort product you are using
b) the release level of the sort product installed
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Wed Feb 10, 2010 7:51 pm    Post subject: Re: Reply to: Sort a File
Reply with quote

It is working fine. Thank for your timely help.....
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Feb 10, 2010 10:25 pm    Post subject:
Reply with quote

simha_it,

Another way of doing it without worrying about the LRECL of the file and you need not add any indicators . Using ALTSEQ , we sort the alphabet A records so that it comes just before U.

Code:

//STEP0100 EXEC PGM=ICETOOL   
//TOOLMSG  DD SYSOUT=*         
//DFSMSG   DD SYSOUT=*         
//IN       DD DSN=Your input file,DISP=SHR
//OUT      DD SYSOUT=*                               
//TOOLIN   DD *                                     
  DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
//CTL1CNTL  DD *                                     
  SORT FIELDS=(1,1,AQ,A)                             
  ALTSEQ CODE=(C1E3)                                 
//*
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 Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am


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