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

Regarding deleting and appending records


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

New User


Joined: 21 Apr 2008
Posts: 5
Location: Mysore

PostPosted: Sun Apr 27, 2008 5:27 pm
Reply with quote

hi all,
i have three flat files.
first file has records:

0001
0002
0003
0004
0005
0006
0007
0023
0056

another file has records:

0023
0056

And the third file has records:

0008
0009
0010

I need to create a file which will delete records from file 1 which are present in file 2 and add records whcih are present in file 3 . thus the output would be:

0001
0002
0003
0004
0005
0006
0007
0008
0009
0010

Can somebody help me regarding this?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sun Apr 27, 2008 9:18 pm
Reply with quote

What if a record is present in all 3 files?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Apr 27, 2008 11:30 pm
Reply with quote

And how should duplicates in any/all of the files be handled?
Back to top
View user's profile Send private message
Vishal Trehan

New User


Joined: 21 Apr 2008
Posts: 5
Location: Mysore

PostPosted: Mon Apr 28, 2008 10:20 am
Reply with quote

records present in file 2 will be present in file 1 but records presnt in file 3 will not be present in file 1.
Its simple deletion and addition of records to the file 1.
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Mon Apr 28, 2008 12:12 pm
Reply with quote

Here is the SORT control card which you have asked for

Code:
//STEP0100  EXEC  PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN1       DD *
0001
0002
0003
0004
0005
0006
0007
0023
0056
//IN2       DD *
0023
0056
/*
//T1      DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),
//           DISP=(MOD,PASS)
//FILEA     DD SYSOUT=*
//OUT12   DD SYSOUT=*
//OUT1    DD DSN=&&TEMP1,UNIT=SYSDA,SPACE=(TRK,(5,5)),
//           DISP=(MOD,PASS)
//OUT2    DD SYSOUT=*
//TOOLIN  DD *
  COPY FROM(IN1) TO(T1) USING(CTL1)
  COPY FROM(IN2) TO(T1) USING(CTL2)
  SPLICE FROM(T1) TO(OUT12) ON(1,4,CH) WITH(81,1) -
  USING(CTL3) KEEPNODUPS
/*
//CTL1CNTL DD *
  INREC OVERLAY=(80:C'11')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(80:C'22')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT1,INCLUDE=(80,2,CH,EQ,C'11'),BUILD=(1,80)
/*
//STEP2    EXEC PGM=SORT
//SYSOUT   DD   SYSOUT=*
//SYSPRINT DD   SYSOUT=*
//SORTIN    DD DSN=&&TEMP1,DISP=OLD
//          DD DSN=SB9642.TEMP.TEST,DISP=SHR
//SORTOUT   DD SYSOUT=*
//SYSIN     DD *
  SORT FIELDS=(1,4,CH,A)
/*
Back to top
View user's profile Send private message
Vishal Trehan

New User


Joined: 21 Apr 2008
Posts: 5
Location: Mysore

PostPosted: Mon Apr 28, 2008 1:53 pm
Reply with quote

Thanks.
but u havent mentioned how to append the records from the third file.
and i dont want to give the input from the JCl. i has to be from the flat file.
Please let me know that too. The question might be trivial for u but i am stilla novice. So would like to know that in details.
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Mon Apr 28, 2008 3:30 pm
Reply with quote

The Step2 is doing the 3rd file appending to the output of 1st and Second
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Apr 28, 2008 10:29 pm
Reply with quote

Vishal Trehan,

The following DFSORT JCL will give you the desired results. I assumed that all files are of the same record length and file1 and file 2 does not have duplicates. The first step concatenates file 1 and file 2 and removes the dupes from them which means that any matching record is deleted. And step0200 concatenates the output from step 1 to file3 and creates 1 single file.

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN       DD DSN=your file 1,DISP=SHR
//         DD DSN=your file 2,DISP=SHR
/*                                             
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)   
//TOOLIN   DD *                                             
  SELECT FROM(IN) TO(T1) ON(1,4,CH) NODUPS                   
/*
//STEP0200 EXEC PGM=ICEMAN       
//SYSOUT   DD SYSOUT=*           
//SORTIN   DD DSN=&&T1,DISP=SHR   
//         DD DSN=your file 2,DISP=SHR
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD *                   
  OPTION EQUALS                   
  SORT FIELDS=(1,4,CH,A)         
/*     


Hope this helps...

Cheers
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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Deleting a Tape file JCL & VSAM 14
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top