IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Joinkeys overlay and unmatched with Outfil


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ambalam

New User


Joined: 19 Aug 2018
Posts: 5
Location: India

PostPosted: Thu Aug 23, 2018 11:57 am
Reply with quote

Hi All,

I have two files of length 500 and same structure . I am comparing the files and updating the first file (F1) , with values from 50th position of F2. I am using be below JCL to update my first file and working fine.
Code:

 //SORTJNF1 DD DSN=FILE1,                               
 //            DISP=SHR                                 
 //SORTJNF2 DD DSN=FILE2,                               
 //            DISP=SHR                                 
 //SORTOUT  DD DSN=FILE1UPD,                           
 //            DISP=(,CATLG,DELETE),                   
 //            SPACE=(500,(30,20)),AVGREC=K,           
 //            LRECL=500,RECFM=FB                       
 //SYSIN    DD    *                                     
   JOINKEYS FILES=F1,FIELDS=(1,10,A,65,5,A,)           
   JOINKEYS FILES=F2,FIELDS=(1,10,A,65,5,A,)           
   JOIN UNPAIRED,F1                                     
   REFORMAT FIELDS=(F1:1,500,?,F2:50,1)                 
   OPTION COPY                                         
   OUTFIL IFOUTLEN=500,                                 
     IFTHEN=(WHEN=(501,1,CH,EQ,C'B'),OVERLAY=(50:502,1))


Now I also want to create a file with unmatched records from first file (F1) . So I modified the JCL as follows.
Code:

 //SORTJNF1 DD DSN=FILE1                                   
 //            DISP=SHR                                   
 //SORTJNF2 DD DSN=FILE2                                   
 //            DISP=SHR                                   
 //OUT1     DD DSN=FILE1UP                                 
 //            DISP=(,CATLG,DELETE),                       
 //            SPACE=(600,(30,20)),AVGREC=K,               
 //            LRECL=500,RECFM=FB                         
 //OUT2     DD DSN=FILE1.NOMATCH,                         
 //            DISP=(,CATLG,DELETE),                       
 //            SPACE=(600,(30,20)),AVGREC=K,               
 //            LRECL=500,RECFM=FB                         
 //SYSIN    DD    *                                       
   JOINKEYS FILES=F1,FIELDS=(1,19,A,65,5,A,)               
   JOINKEYS FILES=F2,FIELDS=(1,19,A,65,5,A,)               
   JOIN UNPAIRED,F1                                       
   REFORMAT FIELDS=(F1:1,500,?,F2:50,1)                   
   OPTION COPY                                             
     OUTFIL FNAMES=OUT1,INCLUDE=(501,1,CH,EQ,C'B'),       
       IFTHEN=(WHEN=(501,1,CH,EQ,C'B'),OVERLAY=(50:502,1)),
       BUILD=(1,600)             
      IFTHEN=(WHEN=(501,1,CH,EQ,C'1'),   
    OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,500),                 

But I am facing the error below
Code:

ICE214A F DUPLICATE, CONFLICTING, OR MISSING OUTFIL STATEMENT OPERANDS 
                IFTHEN=(WHEN=(501,1,CH,EQ,C'1'),                       
                $                                                       
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY   
              OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,500),         

can you please let me know how can I correct the error and create the unmatched file in the same step.

Please learn to use the code tags to make things easier to read. They are easy to use

Code:
[code]
Your stuff here
[/code]

Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Aug 23, 2018 12:22 pm
Reply with quote

Do you need the comma on the last statement for OUT1.
Code:

      IFTHEN=(WHEN=(501,1,CH,EQ,C'1'),   

maybe should be

      IFTHEN=(WHEN=(501,1,CH,EQ,C'1')
Back to top
View user's profile Send private message
ambalam

New User


Joined: 19 Aug 2018
Posts: 5
Location: India

PostPosted: Thu Aug 23, 2018 12:59 pm
Reply with quote

Hi EXPACT ,

Thank you for your suggestion . I had tried without comma and the results are same only.


Code:


//SYSIN    DD    *                                       
  JOINKEYS FILES=F1,FIELDS=(1,19,A,65,5,A,)       
  JOINKEYS FILES=F2,FIELDS=(1,19,A,65,5,A,)       
  JOIN UNPAIRED,F1                                       
  REFORMAT FIELDS=(F1:1,500,?,F2:50,1)                   
  OPTION COPY                                             
    OUTFIL FNAMES=OUT1,INCLUDE=(501,1,CH,EQ,C'B'),       
      IFTHEN=(WHEN=(501,1,CH,EQ,C'B'),OVERLAY=(50:502,1)),
      BUILD=(1,500)                                       
      IFTHEN=(WHEN=(501,1,CH,EQ,C'1'),                   
    OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,500)                 
/*                                                       


Code:

     OUTFIL FNAMES=OUT1,INCLUDE=(601,1,CH,EQ,C'B'),           
       IFTHEN=(WHEN=(501,1,CH,EQ,C'B'),OVERLAY=(50:502,1)),   
       BUILD=(1,500)                                           
       $                                                       
 DUPLICATE, CONFLICTING, OR MISSING OUTFIL STATEMENT OPERANDS 
       IFTHEN=(WHEN=(501,1,CH,EQ,C'1'),                       
       $                                                       
 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY   
     OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,500)                     


Infact I have tried other combination for the syntax also. But the results seems to be same. Can we use overlay with build ? If not how can we use instead of this .
Back to top
View user's profile Send private message
ambalam

New User


Joined: 19 Aug 2018
Posts: 5
Location: India

PostPosted: Thu Aug 23, 2018 1:17 pm
Reply with quote

I have tried the following also.



Code:

 //SYSIN    DD    *                                       
   JOINKEYS FILES=F1,FIELDS=(1,10,A,65,5,A)       
   JOINKEYS FILES=F2,FIELDS=(1,10,A,65,5,A)       
   JOIN UNPAIRED,F1                                       
   REFORMAT FIELDS=(F1:1,500,?,F2:50,1)                   
   OPTION COPY                                             
     OUTFIL FNAMES=OUT1,INCLUDE=(501,1,CH,EQ,C'B'),       
       IFTHEN=(WHEN=(501,1,CH,EQ,C'B'),OVERLAY=(50:502,1)),
       BUILD=(1,500)                                       
     OUTFIL FNAMES=OUT2,       

      IFTHEN=(WHEN=(501,1,CH,EQ,C'1'),                   
       BUILD=(1,500)                                       
 /*                                                       


The output is

Code:

     OUTFIL FNAMES=OUT1,INCLUDE=(501,1,CH,EQ,C'B'),           
       IFTHEN=(WHEN=(501,1,CH,EQ,C'B'),OVERLAY=(50:502,1)),   
       BUILD=(1,500)                                         
       $                                                     
 DUPLICATE, CONFLICTING, OR MISSING OUTFIL STATEMENT OPERANDS
     OUTFIL FNAMES=OUT2,                                     
       IFTHEN=(WHEN=(501,1,CH,EQ,C'1'),                       
       BUILD=(1,500)                             
             
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Aug 23, 2018 2:01 pm
Reply with quote

I think your parentheses are misplaced. You want to overlay & build for the case where "B" and, separately, select the records where case is "1". Then all other records to the SAVE output.

e.g.
Code:
   OUTFIL FNAMES=OUT1,INCLUDE=(501,1,CH,EQ,C'B'),         
      IFTHEN=(WHEN=(501,1,CH,EQ,C'B'),OVERLAY=(50:502,1), 
      BUILD=(1,500)),                                     
     IFTHEN=(WHEN=(501,1,CH,EQ,C'1'),                     
      BUILD=(1,500))                                       
   OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,500)                   


You say:
Quote:
I am comparing the files and updating the first file (F1) , with values from 50th position of F2.


What you have is overlaying byte 50 of the record from file 1 with the first byte from the record in file 2. Is this what you want? or should this be :
Code:
  OVERLAY=(50:552,1) 


Garry.
Back to top
View user's profile Send private message
ambalam

New User


Joined: 19 Aug 2018
Posts: 5
Location: India

PostPosted: Thu Aug 23, 2018 2:24 pm
Reply with quote

Hi Garry,

I am getting the expected results for overlay , that is file F1 in 50th position is updating perfectly with the 50 th position from file F2. , with my first JCL. Only problem is when I tried to write the unmatched records for F1 , I am getting error.

REFORMAT FIELDS=(F1:1,500,?,F2:50,1) is ok.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Aug 23, 2018 2:54 pm
Reply with quote

I believe that your JCL is working OK. It is your Sort control statements that you are having problems with. JCL and program control statements are not the same thing.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Aug 23, 2018 3:39 pm
Reply with quote

I misread the REFORMAT statement icon_redface.gif v

However, I suggested moving the last close parenthesis of the IFTHEN from after the OVERLAY to after the BUILD, then continue into the next IFTHEN which has the OVERLAY omitted and has the closing parenthesis after a separate BUILD.

Garry.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Thu Aug 23, 2018 5:09 pm
Reply with quote

In your first IFTHEN= group, subparameters BUILD=, and OVERLAY= are mutually exclusive.

You need to review the logic of your parameters.

P.S.
It might be easier to catch similar problems, including misplaced parenthesis, if you aligned your code properly (with logical indentation), and divided parameters by lines.
This is an extra recommendation besides of standard one: always use code tags in your questions.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Aug 23, 2018 9:52 pm
Reply with quote

As sergeyken pointed out, your original problem is having BUILD and OVERLAY in the same OUTFIL, you cannot have both, you can have ONLY either one of those.

Quote:
I also want to create a file with unmatched records from first file (F1)
From this it looks like you are trying to create 2 outputs
OUT1 - All the records from F1 with pos-50 replaced for matching records in F2.
OUT2 - ONLY non-matching records from F1.

If that is what you want, then you can keep the OUT1 OUTFIL same as what you showed in your very first post and add another OUTFIL like this (untested).
Code:
    JOINKEYS FILES=F1,FIELDS=(1,10,A,65,5,A,)           
    JOINKEYS FILES=F2,FIELDS=(1,10,A,65,5,A,)           
    JOIN UNPAIRED,F1                                     
    REFORMAT FIELDS=(F1:1,500,?,F2:50,1)                 
    OPTION COPY                                         
    OUTFIL FNAMES=OUT1,
           IFOUTLEN=500,                                 
           IFTHEN=(WHEN=(501,1,CH,EQ,C'B'),
           OVERLAY=(50:502,1))
    OUTFIL FNAMES=OUT2,
           INCLUDE=(501,1,CH,EQ,C'1'),
           BUILD=(1,500)
But your later posts show that you are including only matching records into OUT1, if that is what you want you can add an INCLUDE in OUT1 OUTFIL to extract only 'B' records.

IFOUTLEN would help limit your final record length - if that is what you were trying to do with the extra BUILD. You had it in your original control card but looks like you left that out in your 'modified' control card.
Back to top
View user's profile Send private message
ambalam

New User


Joined: 19 Aug 2018
Posts: 5
Location: India

PostPosted: Thu Aug 30, 2018 2:59 pm
Reply with quote

Thank You Arun ! This was exactly what I required.


Sorry for the delay . I was on a vacation for a week.

Thanks Garry , Nic and Sergeyken .
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Aug 30, 2018 8:47 pm
Reply with quote

ambalam wrote:
Thank You Arun ! This was exactly what I required.


Sorry for the delay . I was on a vacation for a week.

Thanks Garry , Nic and Sergeyken .
You're welcome. Thanks for the update!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts OUTFIL with SAVE option DFSORT/ICETOOL 7
Search our Forums:

Back to Top