View previous topic :: View next topic
Author
Message
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi,
I have 2 files.
file1(FB,LRECL=3) - having some data
Code:
ABC
DEF
GHI
JKL
MNO
PQR
...
file2(FB,LRECL=1) - having values as below
I want to attach the values in the 2nd file to the first file so that the ouptut should look like this
Code:
ABC0
DEF1
GHI2
JKL0
MNO1
PQR2
....
Thanks,
Arun
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
other than the usual record length and type info, how about:
1. do both files have equal number of records?
2. is there some kind of sort or sequencing? or just the data from file 2 to be appended to file 1?
Back to top
samuel_Inba New User Joined: 03 Jan 2008Posts: 53 Location: Chennai
you can do this by using splice operator in SYNCTOOL.
Steps:
1. Include sequence number for both the files(The sequence no will be the key for both the files).
2.now just reformat your 2nd file with 3 blank chars, in front of the data in file 2.
3.Now using seq num as key, use spilce operator to overlay the content of file 1 over file 2.(This can be done vice versa).
Hope This helps.
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi Dick,
file1 will always have more number of records
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi Samuel,
What will happen if the sequence numbers are not matching???
Thanks,
Arun
Back to top
samuel_Inba New User Joined: 03 Jan 2008Posts: 53 Location: Chennai
That particular record will be written as it is.
consider
File 1:
seq num spaces(3) field2
1 aaa
2 bbb
3 ccc
File2:
Seq num field1
1 123
2 456
now u want to overlay 2 on 1,
your output will be,
seqnum field1field2
1 123aaa
2 456bbb
3 ccc
This reformatting can done according to your wish.
U have to take the file which has the maximum record as the base file and fewer as overlay.
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi Samuel,
I m sorry, I dint get your point. why the third record is having the below value
As per my requirement, as you could see in the first post, all the records in the output file should have values from both the files.
Can you please explain
Thanks,
Arun
Back to top
samuel_Inba New User Joined: 03 Jan 2008Posts: 53 Location: Chennai
the 3rd rec will be like:
seqnumspaces(3)field2
3___ccc
What I understood is :
you have 2 files file1 and file2.Both have set of records and there is no key common between the 2 files.
so u need to map all the records in file 2 to file 1 ...
or u have any criteria ?
U wanted the concatenation to happen with repeated values of file2 ?
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi,
I dont want to compare file1 & file2
I need to concatenate file2 values to file1 and just repeat the process till the end of file1
Thanks,
Arun
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi everybody...
Any hope on this....??
Thanks,
Arun
Back to top
sril.krishy Active User Joined: 30 Jul 2005Posts: 183 Location: hyderabad
Hi,
Please check the below code.
Code:
//S1 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN0 DD *
ABC
DEF
GHI
JKL
MNO
PQR
//IN1 DD DSN=XXXXXXX.T1,UNIT=SYSDK,SPACE=(CYL,(6,6)),
// DISP=(NEW,CATLG,DELETE),DCB=(RECFM=FBA,LRECL=80)
//IN2 DD *
0
1
2
//C1 DD DSN=&&C1,UNIT=SYSDK,SPACE=(CYL,(6,6)),DISP=(,PASS)
//T1 DD DSN=&&T1,UNIT=SYSDK,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=XXXXX.T2,UNIT=SYSDK,SPACE=(CYL,(6,6)),
// DISP=(NEW,CATLG,DELETE),DCB=(RECFM=FB,LRECL=80)
//TOOLIN DD *
SORT FROM(IN0) TO(IN1) USING(CTL0)
COPY FROM(IN1) TO(C1) USING(CTL1)
COPY FROM(IN2) USING(CTL2)
SORT FROM(T1) TO(OUT) USING(CTL3)
/*
//CTL0CNTL DD *
OPTION COPY
OUTFIL TRAILER1=(COUNT=(M11,LENGTH=8)),NODETAIL
//CTL1CNTL DD *
INREC BUILD=(C' REPEAT=',2,8,80:X)
/*
//CTL2CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
OUTFIL FNAMES=T1,OVERLAY=(89:SEQNUM,8,ZD,RESTART=(81,8)),
/*
// DD DSN=*.C1,VOL=REF=*.C1,DISP=(OLD,PASS)
//CTL3CNTL DD *
OPTION EQUALS
SORT FIELDS=(89,8,ZD,A)
OUTREC BUILD=(1,80)
/*
//S1 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//INA DD *
ABC
DEF
GHI
JKL
MNO
PQR
//INB DD DSN=XXXXX.T2,DISP=SHR
//CTL1JNF1 DD DSN=XXXXX.S.K1,
// DISP=(,CATLG,DELETE),
// UNIT=SYSDK,
// SPACE=(CYL,(55,55),RLSE)
//CTL1JNF2 DD DSN=XXXXX.S.T2,
// DISP=(,CATLG,DELETE),
// UNIT=SYSDK,
// SPACE=(CYL,(55,55),RLSE)
//CTL1OF01 DD DSN=XXXXX.S.T1,
// DISP=(,CATLG,DELETE),
// UNIT=SYSDK,
// SPACE=(CYL,(55,55),RLSE)
//TOOLIN DD *
SORT FROM(INA) TO(CTL1JNF1) USING(CTLA)
SORT FROM(INB) TO(CTL1JNF2) USING(CTLB)
SORT FROM(CTL1JNF1) USING(CTL1)
//CTLACNTL DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,3,1X,SEQNUM,8,ZD)
//CTLBCNTL DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,1,3X,SEQNUM,8,ZD)
//CTL1CNTL DD *
JOINKEYS FILES=F1,FIELDS=(5,8,A)
JOINKEYS FILES=F2,FIELDS=(5,8,A)
REFORMAT FIELDS=(F1:1,3,F2:1,1)
SORT FIELDS=COPY
OUTFIL FILES=01,OUTREC=(1,4)
/*
Code:
The output :
ABC0
DEF1
GHI2
JKL0
MNO1
PQR2
Thanks
Krishy
Back to top
Please enable JavaScript!