View previous topic :: View next topic
|
Author |
Message |
Nico van der Merwe
New User
Joined: 02 Oct 2008 Posts: 9 Location: Wellington
|
|
|
|
Hi,
I have the following 2 files:
FILE1: DNGG01.NDPACK.NDDPP2.D0.KS90 (KEY=15 LONG)
FILE2: DNGG01.CVPACK.NNMPP2.D0.SQ90
DNGG01.NDPACK.NDDPP2.D0.KS90 contains:
a Header with low-values and a date CCYYMMDD at the end.
Alot of records with values in it, not of concern.
DNGG01.CVPACK.NNMPP2.D0.SQ90
Lots of records with values, but this files has no header
What I want to do:
Copy FILE1's Header to FILE2, while keeping the rest of the records of FILE2 just like it is.
I keep on overwriting everthing, so then FILE2 has the Header but all the other records are lost. Any advise on how to do this? |
|
Back to top |
|
|
Nico van der Merwe
New User
Joined: 02 Oct 2008 Posts: 9 Location: Wellington
|
|
|
|
Both file LRECL = 90 and the header is LOW-VALUES with a date at the end. There is only one header and it's always the 1st record. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Assuming both files can be treated as fixed-length, you can use a DFSORT job like the following. Note that you SHOULD NOT use the same data set for input and output. You can copy the resulting output file back to the original file if you need to.
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=... input file1 (VSAM,FB,90)
//IN2 DD DSN=... input file2 (FB/90)
//SORTOUT DD DSN=... output file (FB/90)
//SYSIN DD *
JOINKEYS F1=IN1,FIELDS=(91,8,A),SORTED
JOINKEYS F2=IN2,FIELDS=(91,8,A),SORTED
JOIN UNPAIRED,F1,F2,ONLY
OPTION COPY
REFORMAT FIELDS=(F2:1,90,?,F1:1,90)
OUTREC IFOUTLEN=90,
IFTHEN=(WHEN=(91,1,CH,EQ,C'2'),BUILD=(1,90)),
IFTHEN=(WHEN=(91,1,CH,EQ,C'1'),BUILD=(92,90))
/*
//JNF1CNTL DD *
OPTION STOPAFT=1
RECORD TYPE=F
INREC OVERLAY=(91:C'00000000')
/*
//JNF2CNTL DD *
INREC OVERLAY=(91:SEQNUM,8,ZD)
/*
|
|
|
Back to top |
|
|
Nico van der Merwe
New User
Joined: 02 Oct 2008 Posts: 9 Location: Wellington
|
|
|
|
Thanks guys, its working fine now. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
DSN=DSN=
As an aside, when you post error messages related to JCL, can you please also post the JESJCL portion from the output as this will be helpful. |
|
Back to top |
|
|
Nico van der Merwe
New User
Joined: 02 Oct 2008 Posts: 9 Location: Wellington
|
|
|
|
Just a question: input file2 (FB/90) must be sorted before in order for it to process the whole file? |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
You could have done it like this :
Code: |
//STEP01 EXEC PGM=IDCAMS
//FILE01 DD DSN=first input file
//FILE02 DD DSN=second input file
//FILE03 DD header + FILE02 data,DISP=(MOD,CATLG,DELETE),
// additional parameters
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
REPRO IFILE(FILE01) OFILE(FILE03) COUNT(1)
REPRO IFILE(FILE02) OFILE(FILE03)
|
|
|
Back to top |
|
|
Nico van der Merwe
New User
Joined: 02 Oct 2008 Posts: 9 Location: Wellington
|
|
|
|
Hi, how would I go about doing this same job, but I need to not only copy the Header, I now need to copy the header and the Trailer.
Trailer being the last record with High-Values and a count at the end. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
Just a question: input file2 (FB/90) must be sorted before in order for it to process the whole file? |
No.
There was no mention of sorting the file2 records - sorted on what field?
The records in input file2 will be kept in their original order. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
how would I go about doing this same job, but I need to not only copy the Header, I now need to copy the header and the Trailer.
Trailer being the last record with High-Values and a count at the end |
Please describe the header record in more detail. Give the starting position, length and value of each field in the header record.
Please describe the trailer record in more detail. Give the starting position, length and value of each field in the trailer record. |
|
Back to top |
|
|
Nico van der Merwe
New User
Joined: 02 Oct 2008 Posts: 9 Location: Wellington
|
|
|
|
Header Record: 1-82, Low-Values. 83-90, DATE(CCYYMMDD)
Trailer Record: 1-82, High-Values. 83-90, COUNT.
The file/record is 90 characters long. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Do you need the Trailer count updated to reflect the data records in file2?
Or do you just need the original Trailer record from file1? |
|
Back to top |
|
|
Nico van der Merwe
New User
Joined: 02 Oct 2008 Posts: 9 Location: Wellington
|
|
|
|
I just need to copy the original trailer from file1. |
|
Back to top |
|
|
Guest
|
|
|
|
Hi,
According to my understanding of your requirement you can use the following:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
000
DATA1
DATA2
999
//IN2 DD *
DATA3
DATA4
//OUT1 DD DSN=xxx.output.file,DISP=MOD
//TOOLIN DD *
SUBSET FROM(IN1) TO(OUT1) INPUT KEEP FIRST
COPY FROM(IN2) TO(OUT1)
SUBSET FROM(IN1) TO(OUT1) INPUT KEEP LAST
//*
|
Kindly get back to me in case the requirement is not met.
devil13
There is always a better solution. |
|
Back to top |
|
|
|