how to retrieve the odd and even numbers records

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
murali6831
Member
Posts: 1
Joined: Fri Apr 17, 2015 1:12 pm

how to retrieve the odd and even numbers records

Post by murali6831 » Fri Apr 17, 2015 1:18 pm

Hi,

I have been asked in one interview that, how to retrieve the odd and even numbers records from the PS file to two output files all odd number into one output file and all even number into another output file using SORT.

I dont know the answer for this question. If anybody knows the answer means, please help me.

Thanks.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Sat Apr 18, 2015 12:26 pm

It is a COPY operation with two OUTFILs.

With INREC you prepend/append a one-digit sequence number (depending on whether variable-/fixed-length records).

In the first OUTFIL you test that sequence number for being even with an INCLUDE=.

On the other OUTFIL you specify SAVE, which means you get all the records not written to any other OUTFIL.

On both OUTFILS use BUILD to remove the byte which has been added.

The test you need is a "bit mask" like this: B'.......0'. If your sequence-number byte matches that, you have an even number.

ChykyMunky
Member
Posts: 12
Joined: Tue May 05, 2015 8:21 pm

Post by ChykyMunky » Tue May 05, 2015 8:55 pm

William Collins,

Can you give an example of this?

Or anyone else who can answer?

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed May 06, 2015 1:39 am

Code: Select all

INREC IFTHEN=(WHEN=(1,1,BI,EQ,B'.......0'),
                  BUILD=(1,1,X,C'IT''S EVEN!'))

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others