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

Overlay date from one input file to another input file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Mon Sep 19, 2011 2:33 pm
Reply with quote

Hello All,

I have a scenario where i need to copy date from a file1 to the header record of file2.

Input file1 - LRECL/RECFM - FB/1900

This file contains only one record with processing date at position 1 of length 8.
Code:
----+----1----+----2
09/16/11

Input file2 - LRECL/RECFM - VB/334

First record is the header record and can also be found by the value 'PROCESS' in position 9 of length 7.
Code:
----+----1----+----2----+----3----+----4
Date of process :
Data1
Data2
Data3


Expected output file - LRECL/RECFM - VB/334
Code:
----+----1----+----2----+----3----+----4
Date of process :09/16/11


Any pointers would be helpful.

Code:
SYNCSORT FOR Z/OS  1.3.0.2RI
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Sep 19, 2011 3:21 pm
Reply with quote

since you have only one record in the file containing the date,
a modification of this:
ibmmainframes.com/viewtopic.php?p=106139&highlight=append#106139
and using IFTHEN to find the header in you second step probably would work.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Sep 19, 2011 3:24 pm
Reply with quote

dbz beat me, I was thinking of this one here.
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Mon Sep 19, 2011 4:18 pm
Reply with quote

Thanks Dick and BIll. It really helped.
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Wed Sep 21, 2011 2:28 pm
Reply with quote

I have one more requirement here to repeat the header whenever there is a key change.

Input file -
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
Date of process :09/16/11                        DATA11 123456798           
Data11
Data12
Data13
Data21
Data21
Data23
Data31
Data32
Data33

Output file -
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
Date of process :09/16/11                        DATA11 123456798           
Data11
Data12
Data13
Date of process :09/16/11                        DATA21 123456798           
Data21
Data21
Data23
Date of process :09/16/11                        DATA31 123456798           
Data31
Data32
Data33

Both the input and output files are LRECL/RECFM - VB/334.

Any pointers on this one.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 21, 2011 4:03 pm
Reply with quote

I did a little search and got to this one.

Wrong sort product for you... but no biggie?
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Wed Sep 21, 2011 5:06 pm
Reply with quote

Hi bill,

Thank you for the quick response. Actually the solution did work for writing a new header, but mine is to repeat the existing header with few modifications.

Please let me know if you come across any such scenario.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 21, 2011 5:16 pm
Reply with quote

Quote:
repeat the header whenever there is a key change


Sorry, I took this too literally I suppose, didn't check against the data provided and notice the one character in the middle of the data that is different :-)

I thought you might get to a different problem, being how to get the basic header information, rather than the "break" key, which should be fine with this.

Can you post what you got as your solution for the first part?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Sep 22, 2011 6:04 am
Reply with quote

Hi,

you might use this as a starting point
Code:
//S1       EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *      INPUT FILE1                                     
09/16/11                                                             
/*                                                                   
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)     
//SYSIN    DD    *                                                   
  OPTION COPY                                                       
  INREC BUILD=(C'DATEIT,''',01,8,C'''',80:X)                         
/*                                                                   
//S2       EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                               
//SORTIN   DD *     INPUT FILE2                                     
DATE OF PROCESS :                                                       
DATA11                                                                 
DATA12                                                                 
DATA13                                                                 
DATA21                                                                 
DATA22                                                                 
DATA23                                                                 
DATA24                                                                 
DATA31                                                                 
DATA32                                                                 
DATA33                                                                 
/*                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY,SKIPREC=1                                                 
  INREC IFTHEN=(WHEN=INIT,                                             
  OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,5)))                               
  OUTFIL IFOUTLEN=80,IFTHEN=(WHEN=(81,8,ZD,EQ,+00000001),               
     BUILD=(C'DATE OF PROCESS : ',DATEIT,50:1,6,C' 123456798',80:X,/,   
                1,80))                                                 
/*


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

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Thu Sep 22, 2011 10:15 am
Reply with quote

Bill,

I am using below code to extract the date as you suggested.
Code:
//S1 EXEC PGM=ICETOOL                                                 
//DFSMSG DD SYSOUT=*                                                 
//TOOLMSG DD SYSOUT=*                                                 
//IN1      DD DSN=input file1...FB/1900
//IN2      DD DSN=input file2...VB/334         
//TEMP     DD DSN=temporary file...FB/80                                       
//OUT      DD DSN=output file2...VB/334                                                 
//TOOLIN   DD *                                                       
 COPY FROM(IN1) TO(TEMP) USING(CTL1)                                                                       
 COPY FROM(IN2) TO(OUT) USING(CTL2)                                   
//*                                                                   
//CTL1CNTL DD *                                                       
  OUTFIL BUILD=(1:C'  INREC IFTHEN=(WHEN=(8,1,CH,EQ,C''1''),',/,     
               C'      OVERLAY=(18:C''',1,8,C'''))',80:X)             
/*                                                                   
//CTL2CNTL DD *                                                       
  SORT FIELDS=COPY                                                   
//    DD DSN=temporary file


Gerry,

This file is getting received from other application and they are populating values after the 100th byte which wont be constant in the header record. So building as mentioned wont work. I should have mentioned it before icon_redface.gif. One more information missed is there can be only three type of records that can be present in the dataset (DATA1, DATA2, DATA3).

I tried using the below code to repeat the header records...But the issue here is the dataset does not always contain all the datatype records.

Code:
OUTFIL IFTHEN=(WHEN=(13,7,CH,EQ,C'PROCESS'),         
BUILD=(1,334,/,1,53,54:C'DATA21',60,275,/,1,53,54:C'DATA31',60,275))                 
SORT FIELDS=(1,3,CH,D)                         
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Sep 22, 2011 11:27 am
Reply with quote

Hi,

Quote:
This file is getting received from other application and they are populating values after the 100th byte which wont be constant in the header record.


What do you mean by this ?

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

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Thu Sep 22, 2011 12:05 pm
Reply with quote

gcicchet wrote:
Hi,

Quote:
This file is getting received from other application and they are populating values after the 100th byte which wont be constant in the header record.


What do you mean by this ?

Gerry


I meant to say after the 100th byte the values are not fixed. It varies daily...
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Fri Sep 23, 2011 2:37 pm
Reply with quote

Was able to achieve the output using symnames by splitting the header record as shown

Code:
  SORT FIELDS=COPY                                           
  INCLUDE COND=(5,4,CH,EQ,C'DATE')                           
  OUTFIL BUILD=(C'HEAD1,''',5,49,C'''',80:X,/,               
                C'HEAD2,''',60,70,C'''',80:X,/,             
                C'HEAD3,''',130,70,C'''',80:X,/,             
                C'HEAD4,''',200,70,C'''',80:X,/,             
                C'HEAD5,''',270,64,C'''',80:X),VTOF         


If you take a look at the code HEAD2/3/4/5 are just the breakup of the record becoz of the limitation of SYMNAMES record length. Is there any way we can assign only one symbol for the record starting from position 60 - 334 by providing any conituation character ?

Here the header record is rebuilt whenever the data type varies.

Code:
  SORT FIELDS=COPY                                                 
  OMIT COND=(5,4,CH,EQ,C'DATE')                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(335:SEQNUM,4,ZD,RESTART=(5,5))) 
  OUTFIL IFOUTLEN=334,IFTHEN=(WHEN=(335,4,CH,EQ,C'0001'),           
         BUILD=(1,4,HEAD1,5,6,HEAD2,HEAD3,HEAD4,HEAD5,/,1,334))     


Thanks everyone for your help.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
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