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 

Search for DUP and increment only the first occurence

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


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Thu Oct 15, 2009 10:58 am    Post subject: Search for DUP and increment only the first occurence Reply with quote

Hi All,

I need some help with creating a SORT card for below stated problem.

- I have list of DUP keys in file 1.
- I need to search for these keys in the entire GDG base and
- Need to increment the first set of occurence and extract all these records to a single flat file.

Code:

Ex :

File 1 : DUP key file ( LRECL 80 : FB)
Key                        empno
Pos ( 1:9)                pos ( 11:9)
11111111111          998877665
22222222222          887766554
33333333333          776655443
44444444444          665544332


File 2 : GDG files ( LRECL 155 : FB )


----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
ABC00   $$$$$$ xxxxxx998877665                                         
ABC01   PQRS11111111111   001100                300
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                400
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                500
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                600
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                300
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                400
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                500
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                600


If rec 1(Pos 1:3 ) = ABC00 and ( Pos 22: 9 ) =    emp num
 and rec 2 ( 13:9 ) = DUP key
   Increment the DUP key by +1 untill (Pos 49: 3) = 600
   
  This should be done for the first set of records only
 
 

The expected output file :


----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
ABC00   $$$$$$ xxxxxx998877665                                         
ABC01   PQRS11111111112   001100                300
ABC00   $$$$$$ xxxxxx998877665                       
ABC01   PQRS11111111112   001100                400   
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111112   001100                500
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111112   001100                600
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                300
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                400
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                500
ABC00   $$$$$$ xxxxxx998877665                     
ABC01   PQRS11111111111   001100                600




Any help is much appreciated !!

Thanks,
Martin
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Oct 15, 2009 11:37 am    Post subject: Reply with quote

Martin,

How do you differentiate EACH set? Do you mean to update the first set from gdg version it found first?

ex :

gdg 1 had key 11111111111 998877665 and also the same set is fund in gdg3 and gdg5 . so in output you will only update the records from gdg1 and leave the gdg3 and gdg5 as is?

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


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Thu Oct 15, 2009 11:43 am    Post subject: Reply with quote

Hi Kolusu,

Thanks for looking into this !!

The ans to your question is :

The entire combination of Emp num and the key will be present in only one gdg file.

- Martin
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Oct 15, 2009 12:29 pm    Post subject: Reply with quote

Martin wrote:
The entire combination of Emp num and the key will be present in only one gdg file.

- Martin


huh? Now I am confused if it is found only in one file , I am confused as to how differentiate which set to be updated? In your first post you show 16 records and you updated only the first 8 records. How did you decide to update the first 8 records? Is set of 8 records considered a SET? or how is it decided?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Thu Oct 15, 2009 12:40 pm    Post subject: Reply with quote

kolusu wrote:
Martin wrote:
The entire combination of Emp num and the key will be present in only one gdg file.

- Martin


huh? Now I am confused if it is found only in one file , I am confused as to how differentiate which set to be updated? In your first post you show 16 records and you updated only the first 8 records. How did you decide to update the first 8 records? Is set of 8 records considered a SET? or how is it decided?


We need to update the key untill the below condition is met :

Code:

Increment the DUP key by +1 untill (Pos 49: 3) = 600


Pos ( 49 :3 ) = 600 corresponds to end of first set.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Oct 15, 2009 2:03 pm    Post subject: Reply with quote

Martin,

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=your 80byte dup key lookup file,DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)       
//HDR      DD DSN=&&HD,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)       
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INREC OVERLAY=(155:X)                                         
  OUTFIL FNAMES=HDR,REMOVECC,NODETAIL,HEADER1=('HDR')           
/*                 
//STEP0200 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=&&HD,DISP=SHR,VOL=REF=*.STEP0100.HDR                 
//         DD DSN=&&T1,DISP=SHR                                         
//         DD DSN=&&HD,DISP=SHR,VOL=REF=*.STEP0100.HDR                 
//         DD DSN=Your 155 byte gdg base,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(156:ID=1)),   
  IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'ABC00'),PUSH=(180:1,155)),     
  IFTHEN=(WHEN=(1,5,CH,EQ,C'ABC01'),OVERLAY=(160:13,9,170:201,9)),     
  IFTHEN=(WHEN=(156,1,ZD,EQ,1),OVERLAY=(160:1,9,170:11,9))             
  SORT FIELDS=(160,9,CH,A,170,9,CH,A),EQUALS                           
                                                                       
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(335:SEQNUM,8,ZD,RESTART=(160,19))),
  IFTHEN=(WHEN=GROUP,BEGIN=(335,8,ZD,EQ,1),END=(49,3,CH,EQ,C'600'),     
  PUSH=(157:156,1))                                                     
                                                                       
  OUTFIL INCLUDE=(156,2,SS,EQ,C'21,2 '),IFOUTLEN=155,                   
  IFTHEN=(WHEN=(156,2,CH,EQ,C'21',AND,1,5,CH,EQ,C'ABC01'),             
  BUILD=(180,155,/,1,12,+1,ADD,13,9,ZD,M11,LENGTH=9,22,134)),           
  IFTHEN=(WHEN=(156,2,CH,EQ,C'2 ',AND,1,5,CH,EQ,C'ABC01'),             
  BUILD=(180,155,/,1,155))
//*

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


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Thu Oct 15, 2009 2:36 pm    Post subject: Reply with quote

Kolusu !!

Thanks a lot for the solution.. But unfortunately we do not have GROUP feature available in our shop..

Is it possible for you provide this without GROUP clause... Embarassed
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Oct 15, 2009 3:23 pm    Post subject: Reply with quote

Martin wrote:
Kolusu !!

Thanks a lot for the solution.. But unfortunately we do not have GROUP feature available in our shop..

Is it possible for you provide this without GROUP clause... Embarassed


Martin,

I don't have that much time to experiment for an alternate solution. Sorry

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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