|
View previous topic :: View next topic
|
| Author |
Message |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
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 |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| dbz beat me, I was thinking of this one here. |
|
| Back to top |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
| Thanks Dick and BIll. It really helped. |
|
| Back to top |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I did a little search and got to this one.
Wrong sort product for you... but no biggie? |
|
| Back to top |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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 |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
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 . 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 |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
| 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 |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|