View previous topic :: View next topic
Author
Message
honeykun New User Joined: 16 Apr 2007Posts: 3 Location: philippines
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
yogeshwar_ade Active User Joined: 31 Aug 2006Posts: 103 Location: INDIA
Take use of SORT.
Use
Code:
SORT FIELDS=COPY,
SKIPREC=1
to skip first record.
[/code]
Back to top
yogeshwar_ade Active User Joined: 31 Aug 2006Posts: 103 Location: INDIA
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
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
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
yogeshwar_ade Active User Joined: 31 Aug 2006Posts: 103 Location: INDIA
My apology for this one,
I will keep in mind while posting in future.
Regards,
Yogeshwar
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello Yogeshwar,
Quote:
My apology for this one,
No harm done
d
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
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
honeykun New User Joined: 16 Apr 2007Posts: 3 Location: philippines
wow this is great! thanks a lot for all your help guys!
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
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
Please enable JavaScript!