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

Do While loop is not working in EZT


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

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Fri May 29, 2009 2:13 pm
Reply with quote

Hi all,

I have two files file1 and file2

File1 LRECL is 250 bytes (duplicates is there)
emp-key1 which is of 28 bytes

File2 LRECL is 500 (duplicates are not there)
emp-key2 which is of 28 bytes

I have to match this two file on emp-key

Requirement:
READ ONE fILE( say file1)
SCAN THE WHOLE File for the 2nd File (say file2) if matching on emp key
Match is found- write the records to Matched File- records from File1, Records from file2
if match is not found- implies record is present only on the input file 1
write the record in the output1 file

this is what i tried..

I should not use IF MATCHED condition here

Quote:
FILE FILE1 FB (250 0)

INP1-REC 01 250 A
EMP-KEY1 13 28 A

FILE FILE2 FB (500 0)

INP2-REC 01 500 A
EMP-KEY2 01 28 A

FILE OUTPUT FB (800 0)

OUT-REC1 01 800 A

FILE OUTPUT1 (500 0)

OUT-REC2 01 500 A

JOB INPUT(NULL) +
START(FST-PROCESS) +
FINISH(LAST)
DO WHILE NOT EOF FILE1 AND WS-CNT LE 10
GET FILE1
DISPLAY 'READ FILE1'
DO WHILE NOT EOF FILE2
GET FILE2
DISPLAY 'READ FILE2'
PERFORM CHANGE-MAN-DIFF
END-DO
WS-CNT = WS-CNT + 1
END-DO

FST-PROCESS. PROC
WS-RECORD-CNT = 0
WS-RECORD-CNT1 = 0
WS-CNT = 0
END-PROC

CHANGE-MAN-DIFF. PROC
IF EMP-KEY1 = EMP-KEY2

DISPLAY 'MATCH COND'
[i am moving all the matched input records to the output file]
PUT OUTPUT
WS-RECORD-CNT = WS-RECORD-CNT + 1
ELSE
OUT-REC2 = INP2-REC
PUT OUTPUT1
WS-RECORD-CNT1 = WS-RECORD-CNT1 + 1
END-IF
END-PROC

LAST. PROC
DISPLAY 'NO OF MATCHED RECORDS : ', WS-RECORD-CNT
DISPLAY 'NO OF FFDONLY RECORDS : ', WS-RECORD-CNT1
END-PROC


my inner DO WHILE loop is working fine..i.e..(DO WHILE NOT EOF FILE2)

its processing fine for the first record in input file1.

But the outer loop is not working...i mean after completing the process for the first record ...the control is not moving to the second record of the input

file 1..
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri May 29, 2009 4:16 pm
Reply with quote

Please do not post the same topic on multiple helpboards.
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:18 pm
Reply with quote

Hello,

Quote:
I should not use IF MATCHED condition here
Probably should. . . After ensuring both files are in proper sequence.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


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

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

What output (displays) are you getting?
It looks to me that this code should:
read 1 record from file1
read and process all of the records from file2
read 9 more records from file1
end

Is this what the displays show?
Is this what you want it to do?
Back to top
View user's profile Send private message
rkarthik22

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Sat May 30, 2009 10:20 am
Reply with quote

when i execute this code...i got invalid file reference - FILE2. erorr
The inner Do-while loop is working....dut it doesnt come out and read the second record of the FILE1..[/quote]
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: Sat May 30, 2009 10:31 am
Reply with quote

Hello,

Quote:
I should not use IF MATCHED condition here

To repeat. . . . You probably should use MATCH. . .

Sort both files on the "key" and match them.

Quote:
i got invalid file reference - FILE2. erorr
As expected. . .

Why is there such determination to not use the provided match feature?
Back to top
View user's profile Send private message
rkarthik22

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Sat May 30, 2009 10:50 am
Reply with quote

dick scherrer

This time i sorted both the files...eventhough i got the same error

invalid file reference - FILE2

(input file 1 - sorted, with duplicates)
(input file 2 - sorted, without duplicates)
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: Sat May 30, 2009 3:13 pm
Reply with quote

Hello,

DId you also use the built-in match function or did you try to read file2 multiple times?

I the data is in key sequence, one pass thru the data should be all that is needed.
Back to top
View user's profile Send private message
rkarthik22

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Tue Jun 02, 2009 9:44 am
Reply with quote

ok..

instead of this complicated (i feel!!) DO - WHILE, i used IF NOT EOF logic

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

IF NOT EOF FFDFILE
GET FFDFILE
DISPLAY 'READING FFDFILE'
IF NOT EOF CARAWCC
GET CARAWCC
DISPLAY 'READING CARAWCC'
PERFORM CHANGE-MAN-DIFF
IF CARA-EOF = 'Y'
END-IF
END-IF
IF WS-FFD-EOF = 'Y'
END-IF
WS-CNT = WS-CNT + 1
END-IF


This is reading two files....

First its reading 1 records from Ffdfile and scanning/reading all the records from carawcc file...

if match is found its writing to the output file...

My problem after reading all the records from carawcc file ...its not coming out of that inner loop and its not reading the second record from ffd file...

is this looping is correct?!
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: Tue Jun 02, 2009 10:07 am
Reply with quote

Hello,

Quote:
First its reading 1 records from Ffdfile and scanning/reading all the records from carawcc file...
You have been told repeatedly that this is not how to meet your requirement.

Quote:
is this looping is correct?!
NO.

Match the files by the key that is common to both files. . . .

If you had properly matched the files when it was first suggested, your process would be running now. . .

There is a big difference between persistence and stubbornness.

There is also a "Sticky" near the top of the cobol part of the forum that demonstrates how to write a 2-file match/merge without using a builtin MATCH function. It is all done in the code.
Back to top
View user's profile Send private message
rkarthik22

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Fri Jun 19, 2009 5:53 pm
Reply with quote

dick scherrer wrote:
Hello,

Quote:
First its reading 1 records from Ffdfile and scanning/reading all the records from carawcc file...
You have been told repeatedly that this is not how to meet your requirement.

Quote:
is this looping is correct?!
NO.

Match the files by the key that is common to both files. . . .

If you had properly matched the files when it was first suggested, your process would be running now. . .

There is a big difference between persistence and stubbornness.

There is also a "Sticky" near the top of the cobol part of the forum that demonstrates how to write a 2-file match/merge without using a builtin MATCH function. It is all done in the code.



Hi d.sch,

The requirement itself changed , and i got the expected output files after implementing a simple IF MATCHED logic in EZT.

Thanks titan for your effort!!
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 Jun 19, 2009 7:34 pm
Reply with quote

You're welcome - good to hear it is working icon_smile.gif

Thank you for letting us know.

Someone will be here if there are questions later.

d
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
This topic is locked: you cannot edit posts or make replies. REXX - Do - Not able to LOOP CLIST & REXX 10
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts ICETOOL with JOINKEY for Big record l... DFSORT/ICETOOL 12
No new posts REXX - Dataset checking in a do forev... CLIST & REXX 6
Search our Forums:

Back to Top