View previous topic :: View next topic
|
Author |
Message |
shakti
New User
Joined: 20 Jan 2004 Posts: 42
|
|
|
|
Hi,
I have a requirement as follows.
input file 1
------------
emp-no
emp-name
input file2
------------
emp-no
emp-status
emp-state
output file
------------
emp-no
emp-name
emp-status
emp-state
Requirement
---------------
If emp-no from file1 is not equal to emp-no of file2
the following fields will be wriiten to output
emp-no from input file 1
emp-name from input file1
emp-status and emp-state from file2
both the input files are sorted based on emp-no
Please advice how to write the record as shown in output file...
Thanks in advance
shakti |
|
Back to top |
|
|
Ramya A
Active User
Joined: 26 Jul 2004 Posts: 104
|
|
|
|
Hi Shakti,
Quote: |
If emp-no from file1 is not equal to emp-no of file2
the following fields will be wriiten to output
emp-no from input file 1
emp-name from input file1
emp-status and emp-state from file2 |
If emp-no of file1 and 2 doesn't match, which record from file2 should be used to take emp-status and emp-state?? |
|
Back to top |
|
|
shakti
New User
Joined: 20 Jan 2004 Posts: 42
|
|
|
|
Hi Ramya,
I would like to write the file2(Currently not matched) fields of emp-state and emp-status if emp-no of file 1 and 2 doesn't match.
Hope this will helps to understand my requirement.
Thanks and regards,
Shakti |
|
Back to top |
|
|
kunalgala
New User
Joined: 11 Dec 2007 Posts: 1 Location: India
|
|
|
|
Hi Shakti...
The logic as per my understanding of your requirement is as follows:
The following para is to be called in loop until either of the file end is reached.
PROCESS-PARA.
READ FILE1 AT END..
READ FILE2 AT END ...
IF FILE1 AND FILE NOT AT END.....
IF EMP-NO in FILE1-REC NOT = EMP-NO IN FILE2-REC
MOVE EMP-NO IN FILE1-REC TO EMP-NO IN OUTFILE-REC
MOVE emp-name IN file1-REC TO EMP-NAME IN OTFILE-REC
MOVE emp-status IN FILE2-REC TO emp-status IN OUTFILE-REC
MOVE emp-state IN FILE2-REC TO EMP-STATE IN OUTFIILE-REC
(Note .... implies the required logic is not entioned here)
Hope this helps... |
|
Back to top |
|
|
shakti
New User
Joined: 20 Jan 2004 Posts: 42
|
|
|
|
Hi,
I tried this option too. But getting invalid file reference field error...
Any easytrieve suggestion is highly appriceated.
Thanks
Shakti |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
Your post is in CA-products forum..so I'm bit not sure whether you would like to do it using COBOL or SORT. However if COBOL, there is A "sticky" in COBOL forum that can be useful for you...here is the link..
If SORT, a JOB like this can be handy,
Code: |
//DFSORT EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=HLQ.FIRST.FILE,DISP=(SHR,KEEP,KEEP)
//IN2 DD DSN=HLQ.SECOND.FILE,DISP=(SHR,KEEP,KEEP)
//TMP1 DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//OUT DD DSN=HLQ.OUT.FILE1,DISP=(NEW,CATLG,CATLG)
//TOOLIN DD *
COPY FROM(IN1) TO(TMP1) USING(CPY1)
COPY FROM(IN2) TO(TMP1) USING(CPY2)
SPLICE FROM(TMP1) TO(OUT) ON(1,3,CH) WITH(11,5)
//CPY1CNTL DD *
OUTREC FIELDS=(1:1,3,5:5,5,11:5X)
/*
//CPY2CNTL DD *
OUTREC FIELDS=(1:1,3,11:5,5)
/* |
In above JCL contents of inputs & ouputs are:
HLQ.FIRST.FILE
Code: |
111 $$$$$
222 AAAAA
444 FFFFF
555 GGGGG
888 CCCCC |
HLQ.SECOND.FILE
Code: |
111 BBBBB
333 DDDDD
444 FFFFF
555 HHHHH |
HLQ.OUT.FILE1
Code: |
111 $$$$$ BBBBB
444 FFFFF FFFFF
555 GGGGG HHHHH |
|
|
Back to top |
|
|
shakti
New User
Joined: 20 Jan 2004 Posts: 42
|
|
|
|
Hi Anuj,
Thanks for ur suggestion.
But i wanted to do it using easytrive.
thanks much
Shakti |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
I do not use easytrive so can not provide the code right away..However it should have a COBOL like pseudo code, there is a "sticky" in COBOL forum that can be useful for you as far as pseuo code is concern...here is the link.. |
|
Back to top |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
Easytrieve is very good for file matching. "invalid file reference field error" is usually the result of using variables from one file when you have a non-match condition and you are processing a record from the other file. If you show us your matching logic including the statement the error is on we could help you find the problem. |
|
Back to top |
|
|
|