MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

EZT - Without using IF MATCHED condition

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
rkarthik22
Beginner


Joined: 27 Sep 2008
Posts: 24
Topics: 9

PostPosted: Wed May 27, 2009 4:21 am    Post subject: EZT - Without using IF MATCHED condition Reply with quote

I have two files, input file one, has got duplicates in emp-key which is of 28 bytes
and input file two is not having duplicates of emp key (28 bytes)

I have to match this two files , without using IF MATCHED condition..like
IF inp1-emp-key = inp2-emp-key

and write all the records from both the input files to the output files. (output)

And if present only in input file1 write to outputfile2

And if present only in input file2 write to outputfile3


Following is the code snippet (This is one - to -many match)

Quote:
FILE INPFIL1 FB (313 0)

<input fields>

FILE INPFIL2 FB (800 0)
<input fields>

FILE OUTPUT FB (1131 0)
<output fields>

FILE OUTPUT2 FB (313 0)
<output fields>

FILE OUTPUT3 FB (800 0)
<output fields>


********WS Fields*******

INP1-EOF W 1 A VALUE 'N'
INP2-EOF W 1 A VALUE 'N'

************************

JOB INPUT(NULL) +
START(INIT-PROCESS) +
FINISH(WRAP-UP)

PERFORM GET-INP1-FILE
PERFORM GET-INP2-FILE

IF INP1-EOF = 'Y' AND +
INP2-EOF = 'Y'
STOP
ELSE
IF INP1-EMP-KEY = INP2-EMP-KEY
IF INP1-EOF = 'N' OR +
INP2-EOF = 'N'

<HERE I AM MOVING ALL THE RECORDS FROM BOTH
THE INPUT FILES AND WRITING TO THE OUTPUT FILE>

PUT OUTPUT
ELSE IF INPFIL1
<here i am movinginput file 1 RECORDS TO outputfile2>
PUT OUTPUT2
ELSE IF INPFIL2
<here i am movinginput file 2 RECORDS TO outputfile3>
PUT OUTPUT2
END-IF
END-IF
END-IF

GET-INP1-FILE. PROC

IF INP1-EOF = 'N'
GET INPFIL1
ELSE
IF EOF INPFIL1
INP1-EOF = 'Y'
END-IF
END-IF

END-PROC

GET-INP2-FILE. PROC

IF INP2-EOF = 'N'
GET INPFIL2
ELSE
IF EOF INPFIL2
INP2-EOF = 'Y'
END-IF
END-IF

END-PROC


But i got error like...

*******A010 INVALID FILE REFERENCE - INPFIL2
Back to top
View user's profile Send private message
callanand
Beginner


Joined: 12 Jun 2007
Posts: 23
Topics: 2

PostPosted: Wed May 27, 2009 6:43 am    Post subject: Reply with quote

Hi Rkarthik,

Why dont you want to use MATCHED feature of easytrieve. It will make the above code much easier. Here is the code that you can use

Code:
FILE INPFIL1 FB (313 27857)
EMP-NO-INP1  1 28 A
INP1-TEXT1  29 20 A

FILE INPFIL2 FB (800 18400)
EMP-NO-INP2  1 28 A
INP2-TEXT1  29 20 A

FILE OUTPUT FB (1131 27144)
EMP-NO-OUT  1 28 A
OUT-TEXT1   29 20 A
OUT-TEXT2   49 20 A

FILE OUTPUT2 FB (313 27857)
EMP-NO-OUT2 1 28 A

FILE OUTPUT3 FB (800 18400)
EMP-NO-OUT3 1 28 A

*----------------------------------------
JOB INPUT (INPFIL2  KEY(EMP-NO-INP2) +
           INPFIL1  KEY(EMP-NO-INP1) )

 IF MATCHED
    EMP-NO-OUT = EMP-NO-INP1
    OUT-TEXT1  = INP1-TEXT1
    OUT-TEXT2  = INP2-TEXT1
    PUT OUTPUT
 ELSE
    IF INPFIL1
       EMP-NO-OUT2 = EMP-NO-INP1
       PUT OUTPUT2
    END-IF
    IF INPFIL2
       EMP-NO-OUT3 = EMP-NO-INP2
       PUT OUTPUT3
    END-IF
 END-IF


I have tested the above code if the following example

Input2 no duplicates
0000000000000000000000011111recinpfile2
1111111111111111111111111111recinpfile2
2222222222222222222222222222recinpfile2
3333333333333333333333333333recinpfile2
4444444444444444444444444444recinpfile2
5555555555555555555555555555recinpfile2
6666666666666666666666666666recinpfile2
9999999999999999999999999999recinpfile2

Input1 with duplicates
1111111111111111111111111111recinpfile1
1111111111111111111111111111recinpfile1
2222222222222222222222222222recinpfile1
3333333333333333333333333333recinpfile1
4444444444444444444444444444recinpfile1
4444444444444444444444444444recinpfile1
5555555555555555555555555555recinpfile1
6666666666666666666666666666recinpfile1
7777777777777777777777777777recinpfile1
8888888888888888888888888888recinpfile1

Output1
1111111111111111111111111111recinpfile1         recinpfile2
1111111111111111111111111111recinpfile1         recinpfile2
2222222222222222222222222222recinpfile1         recinpfile2
3333333333333333333333333333recinpfile1         recinpfile2
4444444444444444444444444444recinpfile1         recinpfile2
4444444444444444444444444444recinpfile1         recinpfile2
5555555555555555555555555555recinpfile1         recinpfile2
6666666666666666666666666666recinpfile1         recinpfile2

Output2
7777777777777777777777777777
8888888888888888888888888888

Output3
0000000000000000000000011111
9999999999999999999999999999


Before using match your input files must be sorted on keys.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed May 27, 2009 10:03 am    Post subject: Reply with quote

rkarthik22,

You are unbelievable bonk bonk . You tend to choose the difficult route. Good Luck

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rkarthik22
Beginner


Joined: 27 Sep 2008
Posts: 24
Topics: 9

PostPosted: Thu May 28, 2009 5:50 am    Post subject: Reply with quote

hi callanand

There is a slight change in my requirement.

I am not supposed to sort my first input file one on emp-key (28 bytes), Here duplicates are there

I am sorting the second file on emp-key (28 bytes) Duplicates are not here.

So, I cannot use IF MATCHED condition here Sad

I have to match this two files , (without using IF MATCHED condition)..like
IF inp1-emp-key = inp2-emp-key

and write all the records from both the input files to the output files. (output1)

And if present only in input file1 , i have to write this records to the same first output file (output1)

And if present only in input file2 write to output2

Is there any possibility to code this in COBOL (If at all not possible in easytrieve)

Hi kolusu,

I was asked not to use IF MATCHHED logic ..thats why i tried by calling a proc and reading the input files until EOF..
but unfortunately that was not working...
Back to top
View user's profile Send private message
callanand
Beginner


Joined: 12 Jun 2007
Posts: 23
Topics: 2

PostPosted: Fri May 29, 2009 6:20 am    Post subject: Reply with quote

rkarthik,

send me a sample input file and expected output file data. As far as I can understand from the above you can achieve your result by having the below modified code in else part

IF INPFIL1
EMP-NO-OUT2 = EMP-NO-INP1
PUT OUTPUT
END-IF
Back to top
View user's profile Send private message
cyber_snake
Beginner


Joined: 24 Dec 2006
Posts: 10
Topics: 1

PostPosted: Thu Jun 17, 2010 5:39 am    Post subject: Reply with quote

I have similar issues...

example:
input 1:
abcd
abcd
abcd
abcd
hijk
hijk


input 2:
abcd 123
defg 456
hijk 789

expected output:
abcd 123
abcd 123
abcd 123
abcd 123
hijk 789
hijk 789

if using "matched" function, the result is like this:
abcd 123
abcd
abcd
abcd
hijk 789
hijk

any idea?
Back to top
View user's profile Send private message AIM Address
cyber_snake
Beginner


Joined: 24 Dec 2006
Posts: 10
Topics: 1

PostPosted: Thu Jun 17, 2010 5:46 am    Post subject: Reply with quote

please disregard my post.... I already know what happen... The keys in my matching record is interchanged... =)
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group