Page 1 of 1

COmpare 2 files and remove the odd value

PostPosted: Thu Jan 22, 2015 3:32 am
by samurai
Hello,


I have 2 files, i need to compare and remove the odd value and write to other file.

eg:
file1
aaa
bbb
file2
aaa
ccc
bbb

output should be ccc


i have written the below code :
Z= 0                                           
ADDRESS TSO                                   
"ALLOC FI(IN) DA('"inp1"') SHR"     
"EXECIO * DISKR IN(FINIS STEM INP."           
"FREE FI(IN)"                                 
"ALLOC FI(INS) DA('"inp2"') SHR"   
"EXECIO * DISKR INS(FINIS STEM INP1."         
"FREE FI(INS)"                                 
DO I = 1 TO INP.0                             
 DO J =1 TO INP1.0                             
FLAG = 1                                       
 INP1.J = STRIP(INP1.J)                       
 INP.I  = STRIP(INP.I)                         
 IF INP.I = INP1.J THEN                       
    DO                                         
                           
      FLAG = 0                                 
    END                                       
 END                                           
 IF FLAG = 1 THEN                             
 DO                                           
     OUT.Z = INP.I                             
     Z = Z + 1                                 
 END                                           
END                                           
ADDRESS TSO                                   
"ALLOC FI(ERRFL) DA('"output"') SHR" 
"EXECIO * DISKW ERRFL (FINIS STEM OUT."       
"FREE FI(ERRFL)"     


can someone please tell me what is the mistake in this.

Re: COmpare 2 files and remove the odd value

PostPosted: Thu Jan 22, 2015 3:53 am
by enrico-sorichetti
for a successful TWO FILES match the files must be in sequence

file 2 is not in sequence , so You are out of luck

why not use Your sort product ( join keys )
search the forum and You will find gazillions of examples

Re: COmpare 2 files and remove the odd value

PostPosted: Fri Jan 23, 2015 3:13 am
by NicC
Please learn to use the code tags when posting data, code screen cut'n'paste and anything else requiring a fixed pitch font and the retention of multiple spaces.

Re: COmpare 2 files and remove the odd value

PostPosted: Thu Jun 11, 2015 2:28 pm
by Steve Coalbran
This is not a file match it's a two stem load and match stems - if they're in order.
If the files are too large then you're looking at S80A & SB37 type errors.