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 

Joinkeys 2 files, retain date in discarded file

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


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Mon Nov 15, 2010 10:54 am    Post subject: Joinkeys 2 files, retain date in discarded file Reply with quote

I am comparing File A and File B.
1.File A has date info as first rec.
2.Match recs in File B will be written to output.
3. I want to retain Date info as first record in the output file but it is there only in the discarded file A as first rec.
I know I can do it in two sync sort steps or say join unpaired write date row only to unpaired file and concatenate that file with Matched output file and use it next step. I am trying to find out if there is any other simpler way to do it.

Let me know.

Thanks,
Vivek
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Nov 15, 2010 11:22 am    Post subject: Reply with quote

vivek,

Assuming your input files are FB recfm and LRECL=80, the following DFSORT JCL will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//INA      DD *                                           
2010-11-15                                                 
AAA                                                       
BBB                                                       
CCC                                                       
DDD                                                       
GGG                                                       
//INB      DD *                                           
BBB                                                       
DDD                                                       
EEE                                                       
FFF                                                       
GGG                                                       
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  OPTION COPY                                             
  JOINKEYS F1=INA,FIELDS=(1,3,A)                           
  JOINKEYS F2=INB,FIELDS=(1,3,A)                           
  JOIN UNPAIRED                                           
  REFORMAT FIELDS=(?,F2:1,80,F1:81,80)                     
  OUTFIL REMOVECC,BUILD=(2,80),HEADER1=(82,80),           
  INCLUDE=(1,1,CH,EQ,C'B')                                 
//JNF1CNTL DD *                                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(161:SEQNUM,8,ZD)),     
  IFTHEN=(WHEN=GROUP,BEGIN=(161,8,ZD,EQ,1),PUSH=(81:1,80))
//*


The output from this job is
Code:

2010-11-15       
BBB             
DDD             
GGG             

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


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Mon Nov 15, 2010 11:26 am    Post subject: Reply with quote

Kolusu,

thanks for the response. I am using syncsort.
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vivek
Beginner


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Mon Nov 15, 2010 1:50 pm    Post subject: Reply with quote

Code:

//USERID12 JOB (ABCD),'PGMER',NOTIFY=&SYSUID,CLASS=W,
//  MSGCLASS=X
//JOINKEYS EXEC PGM=SORT
//SORTJNF1 DD *
DATE=111510
NONMATCH   NMNMN
MATCH1     22222
NONMATCH   MMMMM
MATCH2     33333
//SORTJNF2 DD *
NONMATCH   OOOOO
MATCH12    22222
NONMATCH   LLLLL
MATCH22    33333
//SORTOUT1 DD DSN=USERID.SORT1,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(TRK,(1,10),RLSE)
//SORTLIST DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  JOINKEYS FILES=F1,FIELDS=(12,5,A)
  JOINKEYS FILES=F2,FIELDS=(12,5,A)
  REFORMAT FIELDS=(F1:1,20,F2:1,20),FILL=X'FF'
  JOIN UNPAIRED
  SORT FIELDS=COPY
**  OUTFIL FILES=01,INCLUDE=(1,4,CH,EQ,C'DATE'),
**      OUTREC=(1,20)
**  OUTFIL FILES=02,INCLUDE=(1,1,BI,NE,X'FF',AND,21,1,BI,NE,X'FF'),
   OUTFILE FNAMES=SORTOUT1,INCLUDE=(1,4,CH,EQ,C'DATE',OR,
          (1,1,BI,NE,X'FF',AND,21,1,BI,NE,X'FF'))
        OUTREC IFTHEN=(WHEN=(1,4,CH,EQ,C'DATE'),
                       BUILD=(1,20)),
               IFTHEN=(WHEN=(1,1,BI,NE,X'FF',AND,21,1,BI,NE,X'FF'),
                       BUILD=(21,20))
/*
//


Code:
********************************* Top of Data **********************************
DATE=111510
MATCH12    22222
MATCH22    33333
******************************** Bottom of Data ********************************


I guess the file would be equal to the length of file at the reformat ?
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Tue Nov 16, 2010 2:53 am    Post subject: Reply with quote

Quote:
I guess the file would be equal to the length of file at the reformat ?
Suggest you look at the LRECL of SORTOUT1 using ISPF 3.4/I and compare it with what you think.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
vivek
Beginner


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Tue Nov 16, 2010 9:58 am    Post subject: Reply with quote

I contacted syncsort. Two errors in the card.

1. I wasn't using when(none) condition so syncsort must have kept the whole file length for that condition. I added that condition and got an error that omit/include was out of bounds. This is because
2. I was using Outrec as control statement instead of Outfil parm. Ifthen replaces outrec in outfil statement. Since outrec control statement runs before outfil even though it is coded after, it decreased file length to 20 bytes and i was referring 21st byte in the include. I fixed that and solved the problem.
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Wed Nov 17, 2010 8:45 am    Post subject: Reply with quote

That's nice and thanks for coming back with the solution you've used.

Take care,
_________________
Regards,
Anuj
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