Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Copy Header record from KS to SQ file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Copy Header record from KS to SQ file
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    Post subject: Reply to: Copy Header record from KS to SQ file
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 Moderator


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

PostPosted: Tue Feb 01, 2011 2:33 am    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Tue Feb 01, 2011 1:42 pm    Post subject:
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    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Feb 01, 2011 3:24 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Feb 02, 2011 12:30 am    Post subject:
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 Moderator


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

PostPosted: Wed Feb 02, 2011 3:36 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Thu Feb 03, 2011 12:46 am    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us