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
 

 

Cobol code for sorting into two seperate output files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
manoj84

New User


Joined: 04 Jan 2007
Posts: 4
Location: CHENNAI

PostPosted: Thu Jan 04, 2007 2:45 pm    Post subject: Cobol code for sorting into two seperate output files
Reply with quote

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
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jan 04, 2007 2:51 pm    Post subject: Re: regarding the code for sorting
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Thu Jan 04, 2007 3:00 pm    Post subject:
Reply with quote

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
View user's profile Send private message
manoj84

New User


Joined: 04 Jan 2007
Posts: 4
Location: CHENNAI

PostPosted: Thu Jan 04, 2007 3:10 pm    Post subject:
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Thu Jan 04, 2007 3:15 pm    Post subject:
Reply with quote

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
View user's profile Send private message
manoj84

New User


Joined: 04 Jan 2007
Posts: 4
Location: CHENNAI

PostPosted: Thu Jan 04, 2007 3:26 pm    Post subject:
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jan 04, 2007 3:27 pm    Post subject:
Reply with quote

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
View user's profile Send private message
manoj84

New User


Joined: 04 Jan 2007
Posts: 4
Location: CHENNAI

PostPosted: Thu Jan 04, 2007 4:57 pm    Post subject: Re: regarding the code for sorting
Reply with quote

Thanks for the pseudo code....


Anyways ..Can u send me JCL code for the above program to execute..
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jan 04, 2007 5:08 pm    Post subject: Re: regarding the code for sorting
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts MAX-RC 88 and Return code 606 in DFH0... lind sh CICS 1 Tue Jan 24, 2017 1:23 pm
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm


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