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

How do I combine 2 datasets removing the header/trailer?


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

New User


Joined: 16 Apr 2007
Posts: 3
Location: philippines

PostPosted: Fri May 30, 2008 9:14 am
Reply with quote

Hi,

How do I combine 2 datasets with the following requirements:
1. Remove the trailer from File1
2. Remove the header from File2

example:
File1 contains
19980APPL20080530
C4260276845078560785075
C4239406854345486485674
99980APPL0000004

File2 contains
19980APPL20080529
C4523650978709567865075
99980APPL0000003

Output file should be
19980APPL20080530
C4260276845078560785075
C4239406854345486485674
C4523650978709567865075
99980APPL0000005

Note that the output file should contain the Header of File1 and trailer of File2 with the record count updated to contain the number of records in the output file which is 5.

Thank you!
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Fri May 30, 2008 9:47 am
Reply with quote

Take use of SORT.

Use

Code:

SORT FIELDS=COPY,
SKIPREC=1     


to skip first record.

[/code]
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Fri May 30, 2008 9:52 am
Reply with quote

yogeshwar_ade wrote:
Take use of SORT.



Code:

//STEP1  EXEC PGM=SORT                                             
//SORTMSG  DD SYSOUT=*                                             
//SYSOUT   DD SYSOUT=*                                             
//SORTWK01 DD UNIT=D,SPACE=(CYL,500)                               
//SORTWK02 DD UNIT=D,SPACE=(CYL,500)                               
//SORTWK03 DD UNIT=D,SPACE=(CYL,500)                               
//SORTIN   DD DSN=YOUR.INPUT.FILE,DISP=SHR                         
//SORTOUT  DD DSN=YOUR.OUTPUT.FILE,
// DISP=(NEW,CATLG,DELETE),       
// UNIT=D,SPACE=(TRK,(500,1000),RLSE),DCB=*.SORTIN     
//SYSIN    DD *                                                   
 SORT FIELDS=COPY,                                                 
 SKIPREC=1                                                         


This is to skip your Header from file2, simillarly give trailer record number in SKIPREC to skip trailer of your file1.

Regareds,
Yogeshwar
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: Fri May 30, 2008 9:53 am
Reply with quote

Hello,

Please read the request thoroughly before you toss out some suggestion.

What you have posted cannot provide the needed solution.

Why suggest sort? The topic is in the dfsort section of the forum.

If you test suggestions before posting them, you can verify that your suggestion will do what has been asked for.
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Fri May 30, 2008 10:00 am
Reply with quote

My apology for this one,

I will keep in mind while posting in future.


Regards,
Yogeshwar
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: Fri May 30, 2008 10:15 am
Reply with quote

Hello Yogeshwar,

Quote:
My apology for this one,
No harm done icon_smile.gif

d
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri May 30, 2008 11:21 am
Reply with quote

Hi,

try this
Code:
//S0000001 EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IP1      DD *                                           
19980APPL20080530                                         
C4260276845078560785075                                   
C4239406854345486485674                                   
99980APPL0000004                                         
/*                                                       
//IP2      DD *                                           
19980APPL20080529                                         
C4523650978709567865075                                   
99980APPL0000003                                         
/*                                                       
//TMP      DD DSN=&&TMP,                                 
//            DISP=(MOD,PASS),                           
//            UNIT=SYSDA,SPACE=(TRK,(30,10),RLSE)         
//OPFILE   DD SYSOUT=*                                   
//TOOLIN   DD *                                           
  COPY FROM(IP1) TO(TMP)    USING(HEAD)                   
  COPY FROM(IP2) TO(TMP)    USING(DETL)                         
  COPY FROM(TMP) TO(OPFILE) USING(TRIL)                         
/*                                                               
//HEADCNTL DD *                                                 
**** COPY TO OP FILE MINUS TRAILER                               
  SORT FIELDS=COPY                                               
  OMIT COND=(1,9,CH,EQ,C'99980APPL')                             
/*                                                               
//*                                                             
//DETLCNTL DD *                                                 
***** COPY TO OP FILE MINUS HEADER AND TRAILER                   
  OMIT COND=(6,4,CH,EQ,C'APPL')                                 
/*                                                               
//*                                                             
//TRILCNTL DD *                                                 
*** TRAILER RECORD                                               
  OUTFIL FNAMES=OPFILE,REMOVECC,                                 
  TRAILER1=(1:C'99980APPL',10:COUNT+1=(EDIT=(TTTTTTT)))         
/*                                                               


Gerry
Back to top
View user's profile Send private message
honeykun

New User


Joined: 16 Apr 2007
Posts: 3
Location: philippines

PostPosted: Fri May 30, 2008 11:32 am
Reply with quote

wow this is great! thanks a lot for all your help guys!
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri May 30, 2008 9:45 pm
Reply with quote

honeykum,

You dont need 3 passes to get the desired results. Here is a one pass DFSORT solution which will give you the desired results

Concatenate both files together to sortin and run the following job. I assumed that your input files are FB recfm and 80 byte LRECL
Code:

//STEP0100 EXEC PGM=ICEMAN                                         
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=your input file1,disp=shr
//            DSN=your input file2,disp=shr     
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
                                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(82:SEQNUM,8,ZD)),               
        IFTHEN=(WHEN=(6,4,CH,EQ,C'APPL'),OVERLAY=(81:SEQNUM,1,ZD))
                                                                   
  OUTREC IFTHEN=(WHEN=(81,1,ZD,EQ,4),                             
        OVERLAY=(10:+2,SUB,82,8,ZD,M11,LENGTH=7))                 
                                                                   
  OUTFIL OMIT=(81,1,SS,EQ,C'2,3'),BUILD=(01,80)                   
/*


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 Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Insert trailer for non empty file only DFSORT/ICETOOL 6
No new posts Merging 2 datasets into one DFSORT/ICETOOL 1
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
No new posts PL/I, VB Datasets and the RDW PL/I & Assembler 4
Search our Forums:

Back to Top