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

Comapare two fields in a single file using easytrieve


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

New User


Joined: 24 May 2009
Posts: 10
Location: chennai

PostPosted: Fri May 29, 2009 10:53 am
Reply with quote

hi all,

I have a input file of length 313 bytes ,

as-acc-key (30 bytes) starts in 13 th position and ap-acc-key (30 bytes) starts in 172 nd position

i want to compare this two fields and write in a matched file...like

If as-acc-key = ap-acc-key
<write matched records in a output file>

If match is not found , i have to write in another output file.

Quote:
FILE INPUT FB (313 0)

JOB INPUT(NULL)

PERFORM GET-INPUT-FILE


IF INP-EOF = 'Y'
STOP
ELSE
IF as-acc-key = ap-acc-key
IF INP-EOF = 'N'
[ i am moving all the inp records to the output files here]
put output

else
<i am moving all the non matched records to the other output file>


GET-INPUT-FILE. PROC
IF INP-EOF = 'N'
GET INPUT
DISPLAY 'READ INPUT'
IF EOF INPUT
INP-EOF = 'Y'
END-IF
END-IF
END-PROC


But here...i got error as invalid file reference...

Can anyone say is this a correct logic ...or my code is wrong?!
Back to top
View user's profile Send private message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Fri May 29, 2009 12:08 pm
Reply with quote

Hello,
Declare the two fields as a key and
try this
JOB INPUT ( FILEA KEY(A-KEY) +
FILEB KEY(B-KEY) ) FINISH
*
IF MATCHED
C-REC = A-REC
PUT FILEC
ELSE
IF FILEA
D-REC = A-REC
PUT FILED
ELSE
IF FILEB
E-REC = B-REC
PUT FILEE
END-IF
END-IF
END-IF
*
i hope this helps.
Note: Both the files has to be sorted before running this easytrieve.
Back to top
View user's profile Send private message
r23051984

New User


Joined: 24 May 2009
Posts: 10
Location: chennai

PostPosted: Fri May 29, 2009 12:23 pm
Reply with quote

hi anandinmainframe,

I said i am having only one input file...not two..

anyway...i code in a simple logic..i got the expected results..

Thanks
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri May 29, 2009 8:01 pm
Reply with quote

Hello,

Good to hear you have a process working icon_smile.gif

In the future, you might want to consider a simpler style of code. . .

I leave the file definitions to you, but the following bit of code should do what you want:
Code:

JOB INPUT INFILE.

IF as-acc-key = ap-acc-key
   [ i am moving all the inp records to the output files here]
    put output
else
   <i am moving all the non matched records to the other output file>
    put other-output
endif

You should not need to check eof over and over and you should not need a proc to read the input. Easytrieve will do lots for you icon_wink.gif
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 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
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top