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
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
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.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
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)
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