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

Copy Header record from KS to SQ file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nico van der Merwe

New User


Joined: 02 Oct 2008
Posts: 9
Location: Wellington

PostPosted: Mon Jan 31, 2011 6:07 pm
Reply with quote

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
View user's profile Send private message
Nico van der Merwe

New User


Joined: 02 Oct 2008
Posts: 9
Location: Wellington

PostPosted: Mon Jan 31, 2011 9:07 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Feb 01, 2011 2:33 am
Reply with quote

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
View user's profile Send private message
Nico van der Merwe

New User


Joined: 02 Oct 2008
Posts: 9
Location: Wellington

PostPosted: Tue Feb 01, 2011 1:37 pm
Reply with quote

Thanks guys, its working fine now.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Feb 01, 2011 1:42 pm
Reply with quote

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
View user's profile Send private message
Nico van der Merwe

New User


Joined: 02 Oct 2008
Posts: 9
Location: Wellington

PostPosted: Tue Feb 01, 2011 3:06 pm
Reply with quote

Just a question: input file2 (FB/90) must be sorted before in order for it to process the whole file?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Feb 01, 2011 3:24 pm
Reply with quote

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
View user's profile Send private message
Nico van der Merwe

New User


Joined: 02 Oct 2008
Posts: 9
Location: Wellington

PostPosted: Tue Feb 01, 2011 6:12 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Feb 02, 2011 12:30 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Feb 02, 2011 3:36 am
Reply with quote

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
View user's profile Send private message
Nico van der Merwe

New User


Joined: 02 Oct 2008
Posts: 9
Location: Wellington

PostPosted: Wed Feb 02, 2011 1:05 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Feb 03, 2011 12:46 am
Reply with quote

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
View user's profile Send private message
Nico van der Merwe

New User


Joined: 02 Oct 2008
Posts: 9
Location: Wellington

PostPosted: Thu Feb 03, 2011 12:40 pm
Reply with quote

I just need to copy the original trailer from file1.
Back to top
View user's profile Send private message
Guest







PostPosted: Thu Feb 03, 2011 2:46 pm
Reply with quote

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
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 FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top