COmpare 2 files and remove the odd value



IBM's Command List programming language & Restructured Extended Executor

COmpare 2 files and remove the odd value

Postby samurai » Thu Jan 22, 2015 3:32 am

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.
samurai
 
Posts: 30
Joined: Tue Mar 18, 2014 3:29 pm
Has thanked: 6 times
Been thanked: 0 time

Re: COmpare 2 files and remove the odd value

 

Re: COmpare 2 files and remove the odd value

Postby enrico-sorichetti » Thu Jan 22, 2015 3:53 am

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: COmpare 2 files and remove the odd value

Postby NicC » Fri Jan 23, 2015 3:13 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
samurai (Sat Jan 24, 2015 12:37 am)
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: COmpare 2 files and remove the odd value

Postby Steve Coalbran » Thu Jun 11, 2015 2:28 pm

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.
Steve
User avatar
Steve Coalbran
 
Posts: 102
Joined: Wed Apr 06, 2011 11:49 am
Location: Stockholm, Sweden
Has thanked: 5 times
Been thanked: 1 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post