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

Sort a File


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 2481
Location: @my desk

PostPosted: Wed Feb 10, 2010 4:09 pm
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
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
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
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
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
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
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: 8797
Location: Welsh Wales

PostPosted: Wed Feb 10, 2010 7:48 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
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
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top