Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Compare File A with File B and copy from File B

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Mon Jun 15, 2009 6:12 pm    Post subject: Compare File A with File B and copy from File B
Reply with quote

Please find my requirement below.

Content of File1: (RECFM=FB,LRECL=80) (Key position: 1 to 4)
Code:
1111
2222
5555
7777

Content of File2: (RECFM=FB,LRECL=80) (Key position: 5 to 8)
Code:
ABCD1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
EFGH1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
IJKL1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
LMNO2222XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
JHJU2222XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
KUJI3333XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
LIKO4444XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
POLK4444XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
MNJU5555XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
YUIJ5555XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
MNJU6666XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
YUIJ6666XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
YUKJ7777XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
FRED7777XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX



Output file should have the below value:
(Basically the 3333, 4444 and 7777 recs should not get written)
Code:
ABCD1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
EFGH1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
IJKL1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
LMNO2222XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
JHJU2222XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
MNJU5555XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
YUIJ5555XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
YUKJ7777XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX
FRED7777XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX



Note: I want to write in the output file with LRELC=16 only from the file2 (without duplicates).

Arun A
Back to top
View user's profile Send private message

Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Mon Jun 15, 2009 6:22 pm    Post subject:
Reply with quote

Arun,

This is already discussed, Please search the forum, Frank has given a solution for this kind one.
Back to top
View user's profile Send private message
Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Mon Jun 15, 2009 6:26 pm    Post subject:
Reply with quote

FYI

http://ibmmainframes.com/viewtopic.php?p=190052&highlight=#190052
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Mon Jun 15, 2009 6:32 pm    Post subject:
Reply with quote

Please explain the rules for data selection as I can see no logic between your expected output and the two input files.

Also, how can you expected output be written to a file of LRECL 16 when you have shown more than 16 characters of output.
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Mon Jun 15, 2009 7:02 pm    Post subject: Reply to: Compare File A with File B and copy from File B
Reply with quote

Expat - I am sorry. I have given my output file format wrongly. Below is the correct one. Basically the I have build the output only with LRECL 16.

Hope I made it clear. Thanks in advance for your valuable comments.

Output file should have the below value:
(Basically the 3333, 4444 and 7777 recs should not get written)
ABCD1111<-the rest rec till LRECL 16>
EFGH1111 <-the rest rec till LRECL 16>
IJKL1111<-the rest rec till LRECL 16>
LMNO2222<-the rest rec till LRECL 16>
JHJU2222<-the rest rec till LRECL 16>
MNJU5555<-the rest rec till LRECL 16>
YUIJ5555<-the rest rec till LRECL 16>
YUKJ7777<-the rest rec till LRECL 16>
FRED7777<-the rest rec till LRECL 16>

Thanks!
Arun
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Mon Jun 15, 2009 7:48 pm    Post subject: Reply to: Compare File A with File B and copy from File B
Reply with quote

Frank - I tried with your previous example but to my dismay, I am running to some or other issue due to the conflict in the position. Would be great if you could send your solution for my request. Your response is greatly appreciated. Thanks in advance!

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

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Mon Jun 15, 2009 7:50 pm    Post subject:
Reply with quote

It may be an idea to post the output showing the error codes and messages to allow us to see exactly what the problem may be.
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Mon Jun 15, 2009 7:54 pm    Post subject: Reply to: Compare File A with File B and copy from File B
Reply with quote

Hello Expat - I was getting the error regarding the keyword parameter...

SPLICE FROM(T1) TO(MATCH) ON(1,4) -
£
ICE604A 0 ERROR IN KEYWORD, PARAMETER, OR DELIMITER
KEEPBASE KEEPNODUPS WITHALL WITH(1,16) USING(CTL3)
ICE602I 0 OPERATION RETURN CODE: 12
ICE630I 2 MODE IN EFFECT: SCAN
SELECT FROM(T1) TO(OUT) ON(1,4,CH) NODUPS USING(CTL3)
ICE612I 0 NO ERRORS FOUND IN STATEMENT

Thanks!
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Mon Jun 15, 2009 8:48 pm    Post subject: Reply to: Compare File A with File B and copy from File B
Reply with quote

Hello All- I was trying out couple of times by making correction in my TOOLIN card. To my surprise, though the job went fine with RC=0 but the output file didnt contain any recs. Below is my TOOLIN Card which I used.

I need the solution very badly for this. Frank, could you please throw some light on this?....Please....

//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
COPY FROM(IN2) USING(CTL2)
SPLICE FROM(T1) TO(FILEC) ON(8,4,CH) WITHALL WITH(01,80) USING(CTL3)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,OVERLAY=(5:1,4,81:1,4)
/*
//CTL2CNTL DD *
OUTFIL FNAMES=T1,OVERLAY=(81:4X)
/*
//CTL3CNTL DD *
OUTFIL FNAMES=FILEC,INCLUDE=(5,4,CH,EQ,81,4,CH),
BUILD=(1,80)
/*

Belos is the msg from the spool:
COPY FROM(IN1) USING(CTL1)
DFSORT CALL 0001 FOR COPY FROM IN1 TO OUTFIL USING CTL1CNTL COM
OPERATION RETURN CODE: 00

COPY FROM(IN2) USING(CTL2)
DFSORT CALL 0002 FOR COPY FROM IN2 TO OUTFIL USING CTL2CNTL COM
OPERATION RETURN CODE: 00

SPLICE FROM(T1) TO(FILEC) ON(8,4,CH) WITHALL WITH(01,80) USING(CTL3)
DFSORT CALL 0003 FOR SORT FROM T1 TO FILEC USING CTL3CNTL COM
RECORD COUNT: 000000000327244
NUMBER OF RECORDS RESULTING FROM CRITERIA: 000000000326318
OPERATION RETURN CODE: 00
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jun 15, 2009 10:59 pm    Post subject:
Reply with quote

ArunAnbu,

The problem with your splice job is that your key is in pos 5 for 4 bytes and you are splice with key at pos 8 which does not produce any matches. However you really don't need splice. Use the following JCL.

I assumed that file 1 which has key in pos 1 thru 4 has spaces in pos 5.

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
1111                                                                 
2222                                                                 
5555                                                                 
7777                                                                 
//         DD *                                                       
ABCD1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
EFGH1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
IJKL1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
LMNO2222XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
JHJU2222XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
KUJI3333XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
LIKO4444XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
POLK4444XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
MNJU5555XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
YUIJ5555XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
MNJU6666XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
YUIJ6666XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
YUKJ7777XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
FRED7777XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX               
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
 
  INREC IFTHEN=(WHEN=(5,1,CH,EQ,C' '),OVERLAY=(81:C'$',1,4)),         
        IFTHEN=(WHEN=NONE,OVERLAY=(82:5,4))                           
  SORT FIELDS=(82,4,CH,A),EQUALS                                     
 
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(86:SEQNUM,8,ZD,RESTART=(82,4))), 
  IFTHEN=(WHEN=GROUP,BEGIN=(86,8,ZD,EQ,1),PUSH=(81:81,1))             
  OUTFIL BUILD=(1,16),INCLUDE=(81,1,CH,EQ,C'$',AND,86,8,ZD,GT,1)     
/*                                                                   
Back to top
View user's profile Send private message
Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Tue Jun 16, 2009 9:49 pm    Post subject:
Reply with quote

Quote:
Thanks for your comments Mazahar! Yeah I tried based on the previous examples but I ran into some or other problem due to the conflict of the position. Still Iam trying to have this corrected. If you find a suitable solution for my question, pls feel free to pass it across.

Thanks a lot!


Giving the solution in board so that every once can know the solution.

Try this and let me know if it works for you


Code:
//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//FILEA DD DSN=... input fileB (FB/80)     (keys are present at pos 5)
//FILEB DD DSN=... input fileA (FB/80)     (keys are present at pos 1)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS),                          (make sure of MOD)
// LRECL=82                           (make sure of LRECL 82)
//FILEC DD DSN=...  output fileC (FB/80)
//TOOLIN DD *
COPY FROM(FILEB) TO(T1) USING(CTL1)
COPY FROM(FILEA) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(FILEC) ON(5,4,CH) KEEPBASE KEEPNODUPS -
       WITHALL WITH(1,80) WITH(81,1) USING(CTL3)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,BUILD=(5:1,76,81:C'BB')
/*
//CTL2CNTL DD *
  INREC BUILD=(1:1,80,81:C'VV')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=FILEC,INCLUDE=(81,2,CH,EQ,C'VB'),
    BUILD=(1:1,16,17:c' ')
/*
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 16, 2009 10:32 pm    Post subject: Reply to: Compare File A with File B and copy from File B
Reply with quote

ArunAnbu,

Here is a one pass solution which would give you the desired results. Since your both lrecl's are the same you can simply concatenate them.

Code:

//STEP0100 EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD *                                                     
1111                                                               
2222                                                               
5555                                                               
7777                                                               
//         DD *                                                     
ABCD1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
EFGH1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
IJKL1111XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
LMNO2222XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
JHJU2222XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
KUJI3333XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
LIKO4444XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
POLK4444XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
MNJU5555XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
YUIJ5555XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
MNJU6666XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
YUIJ6666XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
YUKJ7777XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
FRED7777XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...XX             
//OUT      DD SYSOUT=*                                             
//TOOLIN   DD *                                                     
  SPLICE FROM(IN) TO(OUT) ON(81,4,CH) WITH(1,80) WITHALL USING(CTL1)
//CTL1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=(5,1,CH,EQ,C' '),OVERLAY=(81:1,4,C'$')),       
        IFTHEN=(WHEN=NONE,OVERLAY=(81:5,4))                         
  OUTFIL FNAMES=OUT,BUILD=(1,16),INCLUDE=(85,1,CH,EQ,C'$')         
/*


Mazahar,

Why do you need KEEPBASE AND KEEPNODUPS parm on SPLICE? The intention is to get only the matched records. Why do you even need them?
Back to top
View user's profile Send private message
Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Tue Jun 16, 2009 10:48 pm    Post subject:
Reply with quote

Kolusu,

Sorry, copy paste problem :-)

Arun

we dont need them as We use KEEPNODUPS to keep single records that don't have a match, and KEEPBASE to ensure we keep all duplicate records that don't have a match.
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Wed Jun 17, 2009 11:09 am    Post subject: Reply to: Compare File A with File B and copy from File B
Reply with quote

Hello Mazahar!

I appreciate your response for my post. Well, I proceded per your suggestion but I was getting RC 16 in the splice part.

Splice error msg:
-------------------
SPLICE FROM(T1) TO(FILEC) ON(5,4,CH) -
WITHALL WITH(01,80) WITH(81,1) USING(CTL3)
DFSORT CALL 0003 FOR SORT FROM T1 TO FILEC
OPERATION RETURN CODE: 16

I thought the second WITH has to be WITH(81,2) as we are dealing with 'BB' or 'BV'. So tried changing as below but, still I was getting RC=16.
WITHALL WITH(01,80) WITH(81,2) USING(CTL3)


Below is my TOOLIN for your ref:
-------------------------------------
//TOOLIN DD *
COPY FROM(FILEB) TO(T1) USING(CTL1)
COPY FROM(FILEA) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(FILEC) ON(5,4,CH) -
WITHALL WITH(01,80) WITH(81,1) USING(CTL3)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,BUILD=(5:1,76,81:C'BB')
/*
//CTL2CNTL DD *
INREC BUILD=(1:1,80,81:C'VV')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=FILEC,INCLUDE=(81,2,CH,EQ,C'VB'),
BUILD=(1:1,16,17:C' ')
/*


Your response is greatly appreciated Mazhar.


Regards
Arun A
Back to top
View user's profile Send private message
ArunAnbu

New User


Joined: 15 Jun 2009
Posts: 17
Location: India

PostPosted: Wed Jun 17, 2009 2:55 pm    Post subject: Reply to: Compare File A with File B and copy from File B
Reply with quote

Thank you so much to Kolusu & Mazahar for your valuable inputs!

Finally I was able to sort out my issue by following your posts.
Tons of Thanks to both of you. This is a very good forum for guy like me :D

Regards
Arun A
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us