View previous topic :: View next topic
|
Author |
Message |
manoj84
New User
Joined: 04 Jan 2007 Posts: 4 Location: CHENNAI
|
|
|
|
hi...
actually i want to know how to create a cobol code for sorting a given file say on the basis of ssn.
Ex: Suppose the file has information regarding two individuals(ie 2 ssn)
now how to sort this and then details regarding each individual is put into two seperate output files.Can someone help me with this code.... |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Hi back,
manoj84 wrote: |
i want to know how to create a cobol code for sorting a given file say on the basis of ssn.
Ex: Suppose the file has information regarding two individuals(ie 2 ssn)
now how to sort this and then details regarding each individual is put into two seperate output files.Can someone help me with this code.... |
Sorting is simple in COBOL, but I'm not sure I understand your intended result...Suppose the file had 4 SSNs, would you want 4 output files?
Awaiting your reply,
Bill |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi manoj84,
Quote: |
Ex: Suppose the file has information regarding two individuals(ie 2 ssn)
now how to sort this and then details regarding each individual is put into two seperate output files.Can someone help me with this code.... |
This can be easily done through SORT( DFSORT/SYNCSORT)
Code: |
SORT FIELDS=(1,5,CH,A)
OUTFIL FILES=1,
INCLUDE=(1,5,CH,EQ,C'AAAAA')
OUTFIL FILES=2,
INCLUDE=(1,5,CH,EQ,C'BBBBB') |
here i am assuming that ssn field is in first 5 bytes
Why u want to go for cobol code? |
|
Back to top |
|
|
manoj84
New User
Joined: 04 Jan 2007 Posts: 4 Location: CHENNAI
|
|
|
|
hi.
Actually sorry for not being clear in my query.This is what i am supposed to do...
- The details of transactions for 2 account number that happened in one day need to be
Processed and loaded into separate files.
- The input file needs to be sorted based on the ssn.
- The first output file will have all the records belonging to account number 1 and the second output file that of account number 2.
- After writing the records into the output file for the account numbers write another record at the end which has the entire amount for that account number summed up.
Another report file has to be generated, which should have the following details
- Counts of total number of records read and the total amount.
- Counts of total number of records written for account number 1 and the total amount for that account.
- Counts of total number of records written for account number 2 and the total amount for that account
...thank you for your quick replies... |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi There,
That can be done throgh sort also ..
Please have a look at Frank's " Smart DFSORT Trick at:
http://.ibm.com/servers/storage/support/software/sort/mvs/tricks/ |
|
Back to top |
|
|
manoj84
New User
Joined: 04 Jan 2007 Posts: 4 Location: CHENNAI
|
|
|
|
hi. william;;
ya if there are 4 such ssns u will be puttin it into four output files...actually there are other records like tel-no,add ..etc in the input file relate to each ssn,so after sortin suppose to move relevant details to corresponding output file |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
In general, this is how it could be done...
Code: |
one input file: in1
two output files: out1 & out2
one sort file: sort
Sort input the file
Sort output procedure:
Return sort
if ssn1
add 1 to cnt1
add $ to $1
write out1 from sort
else
add 1 to cnt2
add $ to $2
write out2 from sort
endif
After the sort ends, report on both cnts and $s and the sum of them.
If there might be assitional SSNs:
if 1
process
else
if 2
process
endif
endif |
Hope it helps.... |
|
Back to top |
|
|
manoj84
New User
Joined: 04 Jan 2007 Posts: 4 Location: CHENNAI
|
|
|
|
Thanks for the pseudo code....
Anyways ..Can u send me JCL code for the above program to execute.. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
manoj84 wrote: |
Anyways ..Can u send me JCL code for the above program to execute.. |
It would just be an execute, a DD for the input and two allocating DDs for output...quite location dependant.... |
|
Back to top |
|
|
|