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
 

 

Split a file in to two files & sort the 2ndfile in one s

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

New User


Joined: 05 Oct 2005
Posts: 4
Location: pune

PostPosted: Sun Mar 22, 2009 6:18 pm    Post subject: Split a file in to two files & sort the 2ndfile in one s
Reply with quote

Hi I have one file as below and i want to split depends on code, if code is K or L recodrs should be in file1 else if code = B records should be file2 and sort the file2 depends on on Number .
this all should be happens in one step. can any body give me the solution.



code Number
K 1051313222
L 1051444365
L 1051256360
K 1051263549
K 1051270460
L 1051272961
B 5040156184
B 9355294470
B 4094752136
B 1420149825
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sun Mar 22, 2009 9:39 pm    Post subject: Re: Split a file in to two files & sort the 2ndfile in o
Reply with quote

ramaraju wrote:
Hi I have one file as below and i want to split depends on code, if code is K or L recodrs should be in file1 else if code = B records should be file2 and sort the file2 depends on on Number .
this all should be happens in one step.
I suppose that if you appended the file2 key to the end of the B input records and appended either a sequence number or constant to the K & L records, you could use that key to sort file2 output without resequencing the file1 output.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sun Mar 22, 2009 11:20 pm    Post subject:
Reply with quote

pramaraju,

It's not clear from your description what you want to do.

Please show the expected records in each output file for your input examples. Explain the "rules" for getting from input to output in terms of the example. Give the RECFM and LRECL of the input file. Give the starting position, length and format for each relevant field.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Mar 23, 2009 10:07 pm    Post subject: Reply to: Split a file in to two files & sort the 2ndfil
Reply with quote

ramaraju,

If I understood your question correctly you only want to sort the records which have B in the first position and the other records are to be left as is. You also want to split these records into 2 files. One file containing the sorted 'B' records and the other file which have all the other records. I assumed your input to be FB and 80 bytes lrecl

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
K 1051313222                                                 
L 1051444365                                                 
L 1051256360                                                 
K 1051263549                                                 
K 1051270460                                                 
L 1051272961                                                 
B 5040156184                                                 
B 9355294470                                                 
B 4094752136                                                 
B 1420149825                                                 
//OUT1     DD SYSOUT=*                                       
//OUT2     DD SYSOUT=*                                       
//SYSIN    DD *                                             
  OPTION EQUALS                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),         
  IFTHEN=(WHEN=(1,1,CH,EQ,C'B'),OVERLAY=(81:8C'0'))         
  SORT FIELDS=(81,08,CH,A,                                   
               03,10,CH,A)                                   
                                                             
  OUTFIL FNAMES=OUT1,BUILD=(1,80),INCLUDE=(1,1,CH,EQ,C'B')   
  OUTFIL FNAMES=OUT2,BUILD=(1,80),SAVE                       
/*


OUT1 will contain the sorted B records and OUT2 will contain the rest of the records
Back to top
View user's profile Send private message
ramaraju
Warnings : 1

New User


Joined: 05 Oct 2005
Posts: 4
Location: pune

PostPosted: Mon Mar 30, 2009 2:00 pm    Post subject: Sort doubt
Reply with quote

Frank Yaeger wrote:
pramaraju,

It's not clear from your description what you want to do.

Please show the expected records in each output file for your input examples. Explain the "rules" for getting from input to output in terms of the example. Give the RECFM and LRECL of the input file. Give the starting position, length and format for each relevant field.


Hi Frank,
Please find the description.
we have one input file with record format is FB and LRECL is 1000
ward code(1byte character) and patient number(10 bytes numeric) are the TWO fields among the all the fields on file .
possible ward code values are X, Y, Z.

we need two output files with the below scenarios:

1. If ward code is X OR Y then i have to keep all records of these codes in output file1.
but these records should be sorted on Patient number.

2. if ward code is z then i have to keep all the records in out put file 1.
( no need to sort these records on any filed)
Input File:


Code:
Ward code       Patient number  Amount
(1-1)           (2-11)          (12-15)
X                 9051316566   5000
Y                 1051440000   4589
X                 2051257789   5341
Y                 4071051265   6226
X                 3301270460   3344
Y                 1051272922   9864
Z               5040930184   8653
Z               9835930447   3465
Z               9994752136   2387
Z               9720149825   3356
Z               5964722586   9865
X                 6905131627   8754
Y                 3021406577   0943
X                 1059226765   6598
Y                 7051441523   5432
Z               4220060087   6578



Required Out put file1:
(If ward code is X or Y then we have to include records in output file1 and these records should be sorted on Patient number )

Code:

Ward code       Patient number  Amount
(1-1)            (2-11)          (12-15)
Y                 1051272922   9864
Y                 1051440000   4589
X                 1059226765   6598
X                 2051257789   5341
Y                 3021406577   0943
X                 3301270460   3344
Y                 4071051265   6226
X                 6905131627   8754
Y                 7051441523   5432
X                 9051316566   5000



Required Output file2:
(If ward code is Z then we have to include the records in output file2, No need to sort these records on any scenario)

Code:
Ward code       Patient number  Amount
(1-1)           (2-11)          (12-15)
Z               5040930184   8653
Z               9835930447   3465
Z               9994752136   2387
Z               9720149825   3356
Z               5964722586   9865
Z               4220060087   6578
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Mar 30, 2009 9:51 pm    Post subject: Reply to: Split a file in to two files & sort the 2ndfil
Reply with quote

ramaraju,

The following DFSORT JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=your 1000 byte FB file,
//            DISP=SHR
//OUT1     DD DSN=your sorted x,y, file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
/*
//OUT2     DD DSN=your unsorted z file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
/*
//SYSIN    DD *                                               
  OPTION EQUALS                                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1001:SEQNUM,8,ZD)),         
  IFTHEN=(WHEN=(1,1,SS,EQ,C'X,Y'),OVERLAY=(1001:8X))           
                                                               
  SORT FIELDS=(1001,08,CH,A,                                   
               0002,10,CH,A)                                   
                                                               
  OUTFIL FNAMES=OUT1,BUILD=(1,1000),INCLUDE=(1,1,SS,EQ,C'X,Y')
  OUTFIL FNAMES=OUT2,BUILD=(1,1000),SAVE                       
/*   
Back to top
View user's profile Send private message
ramaraju
Warnings : 1

New User


Joined: 05 Oct 2005
Posts: 4
Location: pune

PostPosted: Fri Apr 03, 2009 7:06 pm    Post subject: Re: Reply to: Split a file in to two files & sort the 2n
Reply with quote

Hi S.K,

Thanks a lot.
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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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