Page 1 of 1

File Match problem

PostPosted: Tue Feb 14, 2012 9:03 pm
by shailaja85
please help me

File-1
----+----1--
AAAA
BBBB
CCCC
DDDD


File-2
----+----1--
AAAA 1111
CCCC 2222
DDDD 3333


Expected Output
“BBBB is not there in file-B” in SYSOUT


File-1 has to match with file-2, the below are my requirements

1. If field of file-1 is there in file-2 to then entire file-2 record has to move to output file
2. If field of file-1 is NOT there in file-2 to then job has to abend and error message has to come in SYSOUT saying that “BBBB is not there in file-B”

Re: File Match problem

PostPosted: Tue Feb 14, 2012 9:41 pm
by Robert Sample
Since you are not consistent in what you want, how do you expect anybody to help you?

According to your requirement
2. If field of file-1 is NOT there in file-2 to then job has to abend and error message has to come in SYSOUT saying that “BBBB is not there in file-B”
the records CCCC and DDDD would not appear in your output file. ABEND is a very specific term that means the job stops running immediately, hence neither CCCC nor DDDD would be looked at on the input side, and would not show up on the output side.

Re: File Match problem

PostPosted: Tue Feb 14, 2012 10:01 pm
by shailaja85
Hi Robert Sample

Sorry for insufficient data.

If key of file-1 is NOT there in file-2 then job has to abend and error message has to come in SYSOUT saying that “BBBB is not there in file-B”

In the above case I am not expecting any data into output file.(execution of job has to stop as soon as if key is NOT found in file-2 )
In the above example I am treating first 4 bytes of file-1 and file-2 as KEY
My intension is until and unless file-2 is updated with all keys job should not run successfully
And SYSOUT has to have information at which key of file-1 is abended, and message has to come in SYSOUT as
“BBBB is not there in file-B”

Re: File Match problem

PostPosted: Wed Feb 15, 2012 12:48 am
by bodatrinadh
Shailaja,

It is not possible to compare and abend the job using Syncsort
For reference check this link.
syncsort-synctool/topic1281.html#p5032

You need to add one more step to your job for force abending

Thanks
-3nadh

Re: File Match problem

PostPosted: Wed Feb 15, 2012 4:38 am
by MrSpock
Two files that need to be matched-up based on a common key. Sounds like a typical JOINKEYS situation.

shailaja85, do you not agree, or am I over-simplifying this?

Re: File Match problem

PostPosted: Wed Feb 15, 2012 1:52 pm
by NicC
Why do you want to abend after the first error is found? It is more efficient to find ALL errors and then abend so that all errors can be fixed at one time.

Re: File Match problem

PostPosted: Wed Feb 15, 2012 10:34 pm
by shailaja85
Thanks for your kind inputs/points

Hi Nic,
Yes it is really good idea to abend after processing of all recoreds, So that I can update all records at a time.
Can you please provide the sort card for that?

Hi Bodatrinadh,
It is OK to have more than one step to achieve the above said logic
Can you please provide the sort card for that?

Re: File Match problem

PostPosted: Thu Feb 16, 2012 8:01 pm
by bodatrinadh
Try this

//STEP1    EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTJNF1 DD *                                                     
AAAA                                                               
BBBB                                                               
CCCC                                                               
DDDD                                                               
//SORTJNF2 DD *                                                     
AAAA 1111                                                           
CCCC 2222                                                           
DDDD 3333                                                           
//SORTOF01 DD SYSOUT=*                                             
//SORTOF02 DD DSN=&&TEMP,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)       
//SYSIN    DD *                                                     
 JOINKEYS FILE=F1,FIELDS=(1,4,A)                                   
 JOINKEYS FILE=F2,FIELDS=(1,4,A)                                   
 JOIN UNPAIRED,F1,ONLY                                             
 SORT FIELDS=COPY                                                   
 OUTFIL FILES=01,                                                   
        OUTREC=(1,4,X,C'IS NOT THERE IN FILE-B')                 
 OUTFIL FILES=02,                                               
        OUTREC=(1,4,X,C'IS NOT THERE IN FILE-B') 
//*                                                             
//SORT2 EXEC PGM=IDCAMS                                         
//IN01    DD DISP=SHR,DSN=&&TEMP                                 
//OUT01   DD SYSOUT=*                                           
//SYSOUT  DD SYSOUT=*                                           
//SYSPRINT DD SYSOUT=*                                           
//SYSIN   DD *                                                   
   PRINT INFILE(IN01) COUNT(1)                                   
   IF LASTCC EQ 0 THEN  -                                         
   SET MAXCC = 12                                                 
   ELSE IF LASTCC EQ 4 THEN  -                                   
  SET MAXCC = 0                                                 
                                   


Thanks
-3nadh