Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7488779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:01:59+00:00 2026-05-29T15:01:59+00:00

The below JCL should select the first duplicate of each record, keeping them in

  • 0

The below JCL should select the first duplicate of each record, keeping them in the same order because of “OPTION COPY” and only with the ‘NETWORK’ at byte 4 length 7 and ‘.’ at byte 59 length 1, excluding records with ‘TOTAL’ at byte 3 length 5 and ‘GRAND’ at byte 3 length 5.

It shows any record with ‘NETWORK’ at byte 4 length 7

//SORT EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DISP=SHR,DSN=INPUT.FILE
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(TRK,(5,5))
//OUT DD SYSOUT=*
//OUTFIL DD SYSOUT=*
//TOOLIN   DD *
* DROP EVERYTHING WE DON'T WANT
  SELECT FROM(IN)  TO(OUT) ON(1,134,CH) USING(CTL1) FIRST
/*
//CTL1CNTL DD *
  OPTION COPY
  INCLUDE COND=((4,7,CH,EQ,C'NETWORK',OR,
                 59,1,CH,EQ,C'.'),AND,
                 (3,5,CH,NE,C'TOTAL',AND,
                  3,5,CH,NE,C'GRAND'))
/*

If I change it the conditions for only ‘NETWORK’ at byte 4 length 7 it only shows 1 record, which is what I expect. The input is the same each time.

//CTL1CNTL DD *
  OPTION COPY
  INCLUDE COND=((4,7,CH,EQ,C'NETWORK'))
/*

I can’t figure out what the difference is that causes the other conditions to change it so it has duplicates

2 of the comments have suggested that the issue is with the include conditions.

I have tried the below, the first select is doing what I was doing original and the second SELECT is without the include conditions because they have already happened in the first select. There are still duplicate records with NETWORK at byte 4 length 7. The rest of the record with NETWORK are the exact same so there should only be 1.

//TOOLIN   DD *
* DROP EVERYTHING WE DON'T WANT
  SELECT FROM(IN)  TO(T1) ON(1,133,CH) USING(CTL1) FIRST
  SELECT FROM(T1)  TO(OUT) ON(1,133,CH) USING(CTL2) FIRST
/*
//CTL1CNTL DD *
  OPTION COPY
    INCLUDE COND=((4,7,CH,EQ,C'NETWORK',OR,
                   59,1,CH,EQ,C'.'),AND,
                   (3,5,CH,NE,C'TOTAL',AND,
                    3,5,CH,NE,C'GRAND'))
/*
//CTL2CNTL DD *
  OPTION COPY
/*
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:02:02+00:00Added an answer on May 29, 2026 at 3:02 pm

    The SELECT FIRST operator expects the input to be sorted, which it does before checking for duplicates once you don’t specify “OPTION COPY”

    I wanted to remove the duplicates and keep it in input order.

    The below does it by adding a sequence number that allows the temp file to be sorted back to input order

    //TOOLIN   DD *
    * SELECT REMOVING THE DUPLICATES AND ONLY INCLUDING THE FIELDS WANTED
    * TO TEMP DD T1
      SELECT FROM(IN)  TO(T1) ON(1,133,CH) USING(CTL1) FIRST
    * COPY FROM TEMP DD T1 TO DD OUT USING CTL2 STATEMENTS
      COPY FROM(T1) TO(OUT) USING(CTL2)
    /*
    //CTL1CNTL DD *
      INCLUDE COND=((4,7,CH,EQ,C'NETWORK',OR,
                     59,1,CH,EQ,C'.'),AND,
                     (3,5,CH,NE,C'TOTAL',AND,
                      3,5,CH,NE,C'GRAND'))
    * ADD SEQUENCE NUMBER 8 NUMBERS LONG TYPE SIGNED ZONED DECIMAL AT THE
    * END OF EACH RECORD
      INREC OVERLAY=(134:SEQNUM,8,ZD)
    /*
    //CTL2CNTL DD *
    * SORT ON THE SEQUENCE NUMBER WHICH PUTS THE RECORDS BACK IN INPUT
    * ORDER
      SORT FIELDS=(134,8,CH,A)
    /*
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used the below jcl to modify the existing ps. I was able to
I've used the below jcl: //STEP1 EXEC PGM=IEBGENER //SYSUT1 DD DUMMY,RECFM=FB,LRECL=80 //SYSUT2 DD DSN=RK.MYDIR.FILES(NEW1),DISP=(SHR)
//below In my application i have a button select image from sdcard and on
Below are two ways of reading in the commandline parameters. The first is the
Below is my stored procedure. I want use stored procedure select all row of
Below is a question from Kathy & Bert Bates SCJP 5 preparation CD. I
Below I have written a sample program that I have written to learn about
Below I present you some code which has completely been butchered by me. $(.gig).hover(function()
Below is a fine piece of artwork that represents a WPF form with a
Below, I inserted a code written by Ray Konopka (part of the Coderage presentation).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.