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

Need a not matching logic to write to output file


IBM Mainframe Forums -> CA Products
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shakti

New User


Joined: 20 Jan 2004
Posts: 42

PostPosted: Mon Dec 10, 2007 11:28 pm
Reply with quote

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
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Tue Dec 11, 2007 3:54 am
Reply with quote

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
View user's profile Send private message
shakti

New User


Joined: 20 Jan 2004
Posts: 42

PostPosted: Tue Dec 11, 2007 6:48 am
Reply with quote

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
View user's profile Send private message
kunalgala

New User


Joined: 11 Dec 2007
Posts: 1
Location: India

PostPosted: Tue Dec 11, 2007 12:03 pm
Reply with quote

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
View user's profile Send private message
shakti

New User


Joined: 20 Jan 2004
Posts: 42

PostPosted: Tue Dec 11, 2007 3:23 pm
Reply with quote

Hi,

I tried this option too. But getting invalid file reference field error...

Any easytrieve suggestion is highly appriceated.

Thanks
Shakti
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Dec 11, 2007 3:52 pm
Reply with quote

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
View user's profile Send private message
shakti

New User


Joined: 20 Jan 2004
Posts: 42

PostPosted: Tue Dec 11, 2007 4:18 pm
Reply with quote

Hi Anuj,

Thanks for ur suggestion.
But i wanted to do it using easytrive.

thanks much
Shakti
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Dec 19, 2007 10:55 pm
Reply with quote

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
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Thu Dec 20, 2007 2:08 am
Reply with quote

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
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 -> CA Products

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top