View previous topic :: View next topic
|
Author |
Message |
r23051984
New User
Joined: 24 May 2009 Posts: 10 Location: chennai
|
|
|
|
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 |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
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 |
|
|
r23051984
New User
Joined: 24 May 2009 Posts: 10 Location: chennai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Good to hear you have a process working
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 |
|
Back to top |
|
|
|