Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
akashs

New User

Joined: 24 Nov 2005
Posts: 49
Location: chennai

 Posted: Sun May 03, 2009 6:19 pm    Post subject: How to get odd number of records Hi, There is a input sequential file.I need to get 1st,3rd,5th....Only odd number of records to the output file.How to do it a COBOL program. thanks, Akash

dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

 Posted: Sun May 03, 2009 6:23 pm    Post subject: what kind of logic flow have you developed?
akashs

New User

Joined: 24 Nov 2005
Posts: 49
Location: chennai

 Posted: Sun May 03, 2009 6:36 pm    Post subject: Hi, It was asked in one interview.Please tell me possible solution regards, Akash
CICS Guy

Senior Member

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

Posted: Sun May 03, 2009 6:49 pm    Post subject:

How would you do it if you were the COBOL program?
 Code: Read input record   Add one to count Is count odd?   No, go to read   Yes, write input record to output Go to read

This could also be done with a simple sort where input has a seqnum of one digit, starting at zero and incremented by five. Omit the fives for odds and omit the zeros for evens.
Anuj Dhawan

Senior Member

Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

Posted: Mon May 04, 2009 2:37 pm    Post subject:

 Quote: This could also be done with a simple sort where input has a seqnum of one digit, starting at zero and incremented by five. Omit the fives for odds and omit the zeros for evens.
There is other simple alternative to this:
 Code: //SORTIN   DD  DSN= . . . input FB/80 //ODD      DD  SYSOUT=*                  //*                                      //EVEN     DD  SYSOUT=*                  //*                                      //SYSIN DD *                               SORT FIELDS=COPY                           OUTFIL FNAMES=(ODD,EVEN),SPLIT      /*
mmwife

Super Moderator

Joined: 30 May 2003
Posts: 1592

Posted: Fri May 08, 2009 7:03 am    Post subject:

Here's some pseudo code for a COBOL solution:
 Code: read ip chk for eof - yes, error and out no, perform until ipeof        write op        read ip        eof? Yes, set ipeof, exit perform              No, read ip, eof? Yes, set ipeof     end-perform                                      close, etc
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 21 Sun Aug 27, 2017 10:35 pm Profile changed to NUMBER ON STD (fro... Martylin TSO/ISPF 1 Thu Aug 03, 2017 9:14 am Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm Edit large number of datasets (QSAM) zh_lad TSO/ISPF 3 Tue Apr 04, 2017 6:08 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us