MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with INREC Overlapping Columns & SEQNUM for Groupin

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 41
Topics: 10

PostPosted: Thu Sep 11, 2025 12:27 pm    Post subject: Help with INREC Overlapping Columns & SEQNUM for Groupin Reply with quote

I'm working with a 260-byte fixed-length input file and need to identify the least record (based on a group of key fields). The goal is to split the file into two outputs:

One with the least record from each group (OUTLEAST) first 3 fields
Another with the remaining records (OUTOTHER)

I'm trying to use INREC BUILD to append the sort keys and a SEQNUM to the record, and then use RESTART on the composite key to determine group boundaries. However, I'm encountering an error:
"INREC has overlapping columns specified" or sometimes "no keywords found on control statement".

235,26 is the timestamp field, need to the select the least timestamp record to first file for each key of 3,12,CH,A,15,5,CH,A,36,3,CH,A and other records to the second file

Code:

SORT FIELDS=(3,12,CH,A,15,5,CH,A,36,3,CH,A,235,26,CH,A)
  INREC BUILD=(
    1:1,260,                      * Original input record (1?260)
    261:3,12,                     * Key 1
    273:15,5,                     * Key 2
    278:36,3,                     * Key 3
    281:SEQNUM,8,ZD,START=1,RESTART=(261,20))  * Seq num (restart when full key changes)
  OUTFIL FNAMES=OUTLEAST,INCLUDE=(281,8,ZD,EQ,1),BUILD=(1,260),REMOVECC
  OUTFIL FNAMES=OUTOTHER,INCLUDE=(281,8,ZD,GT,1),BUILD=(1,260),REMOVECC
Back to top
View user's profile Send private message
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 41
Topics: 10

PostPosted: Thu Sep 11, 2025 3:37 pm    Post subject: Reply with quote

Kolusu,
Please delete the duplicate messages posted on the same subject, due to PHP issue it happened

We modified the code and it worked fine, please advise

Code:

SORT FIELDS=(3,12,CH,A,15,05,CH,A,36,3,CH,A,235,26,CH,A)       
  INREC OVERLAY=(261:3,12,273:15,5,278:36,3,                     
          300:SEQNUM,8,ZD,START=1,RESTART=(261,20))               
  OUTFIL FNAMES=OUTMIN,INCLUDE=(300,8,ZD,EQ,1),REMOVECC           
  OUTFIL FNAMES=OUTOTH,INCLUDE=(300,8,ZD,GT,1),REMOVECC 
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12385
Topics: 75
Location: San Jose

PostPosted: Sat Sep 13, 2025 11:54 am    Post subject: Reply with quote

Suchay,

A few issues.

1. Your first attempt failed because you are using BUILD which cannot see the new fields that you added at the end of the record.
2. You are adding the new key on INREC which is processed before SORT. your sequence number will be reset to 1 as the keys are NOT sorted.

example data as input keys
Code:

ABC
ABC
DEF
ABC


Now the 3rd ABC will also get a Sequence number of 1 because the previous key is DEF.

So you need to add the sequence number AFTER SORT ie on OUTREC

3. Since you are adding the temp fields at the end you are increasing the length of the record and that would also increase the resources needed to sort the records. Your input has LRECL of 260 but with INREC you increased the length 307 which is ~16% increase and that would require more resources to sort the data.

4. You also are NOT removing the temporary fields that you added at the end of the record as you are writing the entire record that you built using INREC.

so ideally your control cards ( untested ) should be

Code:

 SORT FIELDS=(003,12,CH,A,        * Key-1
              015,05,CH,A,        * Key-2
              036,03,CH,A,        * Key-3
              235,26,CH,A)        * Key-4

 OUTREC OVERLAY=(261:003,12,   
                     015,05,
                     036,03,
                 285:SEQNUM,8,ZD,RESTART=(261,20))


OUTFIL FNAMES=OUTMIN,BUILD=(001,260),
INCLUDE=(285,8,ZD,EQ,1)

OUTFIL FNAMES=OUTOTH,BUILD=(001,260),SAVE



Alternatively you can use ICETOOL select operator to do this without the need of adding the sequence number and then splitting the files into Unique and duplicates

Here is an untested JCL

Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//SORTDIAG DD DUMMY
//INP      DD DISP=SHR,DSN=Your.input.file
//*
//FREC     DD DSN=Your.first.record.key.file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)     
//RESTR       DD DSN=Your.other.records.file,     
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)   
//TOOLIN   DD *
  SELECT FROM(INP) TO(FREC) FIRST DISCARD(RESTR)   -
           ON(03,12,CH)                            -
           ON(15,05,CH)                            -
           ON(36,03,CH)                            -
  USING(CTL1)
//*
//CTL1CNTL DD *
  SORT FIELDS=(003,12,CH,A,        * Key-1
               015,05,CH,A,        * Key-2
               036,03,CH,A,        * Key-3
               235,26,CH,A)        * Key-4
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 41
Topics: 10

PostPosted: Mon Sep 15, 2025 3:11 pm    Post subject: Reply with quote

Thank you so much Kolusu, using INREC gave us duplicates as you have explained above

OUTREC it worked fine.

Thank you
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group