Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Comapare two fields in a single file using easytrieve

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CA Products
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    Post subject: Comapare two fields in a single file using easytrieve
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    Post subject: Reply to: Comapare two fields in a single file using easytri
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    Post subject:
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

Site Director


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

PostPosted: Fri May 29, 2009 8:01 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CA Products All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 1 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us