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

LImit for the WHEN CLAUSE in the EVALUATE statement


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
smile_rajeev

New User


Joined: 22 Apr 2005
Posts: 24

PostPosted: Wed Nov 15, 2006 5:14 pm
Reply with quote

Hi all,

I would be great if some one reply me back with answers.

1. Let me know the LImit for the WHEN CLAUSE in the EVALUATE statement.

2. I have two flat files with one field as key in both files with few more fields on it.
By using the key i want to compare the records in two flat files.
If it's equal then i have to store in the separate file.
This should be done using cobol program.
Let me know how can we do this.

Thanks in advance
Rajeev
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Wed Nov 15, 2006 5:47 pm
Reply with quote

The answer to your first question is 256.

O.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Nov 15, 2006 5:57 pm
Reply with quote

Hi Rajeev,


I am provide u the Psudo code for the same

read file a
read file b

Perform until end-of-filea or end-of-fileb
if key of file a = key of file b
write record in file c
read file a
read file b
else
if key of file a > key of file b
read file b
else
read filea
end-if
end-if
End-perform

Here I am assuming that both the file are in sorted order of the key .
Back to top
View user's profile Send private message
vijay_bn79

New User


Joined: 20 Nov 2006
Posts: 48
Location: Hyderabad

PostPosted: Mon Nov 20, 2006 2:56 pm
Reply with quote

Hi...,

this code of cobol may help you,

WORKING-STORAGE SECTION.
01 WS-EOF-CHECK-FILE1 PIC X(1) VALUE 'N'.
88 88-FILE-EOF1 VALUE 'Y'.
88 88-FILE-NOT-EOF1 VALUE 'N'.

01 WS-EOF-CHECK-FILE2 PIC X(1) VALUE 'N'.
88 88-FILE-EOF2 VALUE 'Y'.
88 88-FILE-NOT-EOF2 VALUE 'N'.

PRODECURE DIVISION.

OPEN INPUT FILE1 FILE2.
OPEN OUTPUT FILE3.

PERFORM READ-FILE1-PARA UNTIL 88-FILE-EOF1.
GO TO NORMAL-EOJ-PARA.

READ-FILE1-PARA.

READ FILE1 AT END MOVE 'Y' TO WS-EOF-CHECK-FILE1
NOT AT END
MOVE ?N? TO WS-EOF-CHECK-FILE2
PERFORM READ-FILE2-PARA UNTIL 88-FILE-EOF2

READ-FILE2-PARA.
READ FILE2 AT END MOVE ?Y? TO WS-EOF-CHECK-FILE2
NOT AT END
IF KEY1 OF FILE1 IS EQUAL TO KEY2 OF FILE2
PERFORM WRITE-FILE3-PARA
MOVE ?Y? TO WS-EOF-CHECK-FILE2
ELSE
CONTINUE
END-IF


WRITE-FILE3-PARA.

MOVE FILE2-DETAIL TO FILE3-DETAIL( AS PER THE REQUIREMENT)
WRITE FILE3-DETAIL.

NORMAL-EOJ-PARA.

CLOSE FILE1 FILE2 FILE3.
STOP RUN.
Back to top
View user's profile Send private message
vijay_bn79

New User


Joined: 20 Nov 2006
Posts: 48
Location: Hyderabad

PostPosted: Mon Nov 20, 2006 2:57 pm
Reply with quote

Hi...,

this code of cobol may help you,

WORKING-STORAGE SECTION.
01 WS-EOF-CHECK-FILE1 PIC X(1) VALUE 'N'.
88 88-FILE-EOF1 VALUE 'Y'.
88 88-FILE-NOT-EOF1 VALUE 'N'.

01 WS-EOF-CHECK-FILE2 PIC X(1) VALUE 'N'.
88 88-FILE-EOF2 VALUE 'Y'.
88 88-FILE-NOT-EOF2 VALUE 'N'.

PRODECURE DIVISION.

OPEN INPUT FILE1 FILE2.
OPEN OUTPUT FILE3.

PERFORM READ-FILE1-PARA UNTIL 88-FILE-EOF1.
GO TO NORMAL-EOJ-PARA.

READ-FILE1-PARA.

READ FILE1 AT END MOVE 'Y' TO WS-EOF-CHECK-FILE1
NOT AT END
MOVE ?N? TO WS-EOF-CHECK-FILE2
PERFORM READ-FILE2-PARA UNTIL 88-FILE-EOF2

READ-FILE2-PARA.
READ FILE2 AT END MOVE ?Y? TO WS-EOF-CHECK-FILE2
NOT AT END
IF KEY1 OF FILE1 IS EQUAL TO KEY2 OF FILE2
PERFORM WRITE-FILE3-PARA
MOVE ?Y? TO WS-EOF-CHECK-FILE2
ELSE
CONTINUE
END-IF


WRITE-FILE3-PARA.

MOVE FILE2-DETAIL TO FILE3-DETAIL( AS PER THE REQUIREMENT)
WRITE FILE3-DETAIL.

NORMAL-EOJ-PARA.

CLOSE FILE1 FILE2 FILE3.
STOP RUN.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Mon Nov 20, 2006 3:40 pm
Reply with quote

Hi !

By reading both files in a matching-record-key function, you have always
three conditions to handel.

File-1-Key = File-2-Key ...do something then read both files
File-1-Key > File-2-Key ...read file-2 compare again
File-1-Key < File-2-Key ...read file-1 compare again

Regards, UmeySan
Back to top
View user's profile Send private message
vijay_bn79

New User


Joined: 20 Nov 2006
Posts: 48
Location: Hyderabad

PostPosted: Mon Nov 20, 2006 4:49 pm
Reply with quote

UmeySan wrote:
Hi !

By reading both files in a matching-record-key function, you have always
three conditions to handel.

File-1-Key = File-2-Key ...do something then read both files
File-1-Key > File-2-Key ...read file-2 compare again
File-1-Key < File-2-Key ...read file-1 compare again

Regards, UmeySan


Hi..,

i posted the code for the sequential files which is not in sorted order

in that code
it will read the file1
and read the file2 and compares the Keys if matches writes into file3 and set the end-of-file flag, so it wont read any more records of file2 and come out of that and set the flag again as 'N'
after that it will read the next record of the file1 and read the file2 from the begining and compares...
same process will happen until the end of the FILE1
this means it will process all the records of the File1


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

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Mon Nov 20, 2006 5:04 pm
Reply with quote

Hi !

@vijay_bn79

I didn't criticize yor coding. I was only clarifying what's happening by reading files in matching-record manner.


The question was :

I have two flat files with one field as key in both files with few more fields on it. By using the key i want to compare the records in two flat files.
If it's equal then i have to store in the separate file. This should be done using cobol program. Let me know how can we do this.

Regards, UmeySan
Back to top
View user's profile Send private message
giiiriii

New User


Joined: 07 Nov 2006
Posts: 2

PostPosted: Mon Nov 20, 2006 5:45 pm
Reply with quote

Try this logic:
In the Initialize section:
Read the two files, file1 and file2 and move the key to temporary WS-field, for explanation consider Ws-temp-key-file1 & Ws-temp-key-file2

In the Main process:
Perform Main-Logic until EOF-file1

Main-Logic SECTION:
Initialize all the output variables
?
IF Ws-temp-key-file1 NOT = Ws-temp-key-file2
Perform Read-file2-part
Until Ws-temp-key-file2 >= Ws-temp-key-file1
Or Eof-file2
END-IF

IF Eof-file2
OR Ws-temp-key-file1 NOT = Ws-temp-key-file2
Write a log-file if needed or continue..
Else
Write to file 3. (ie, key in both the file are matched)
End-If

Perform Read-File1-part

Main-Logic-Exit
Exit

Read-file1-part

Read file1 at end set EOF-file1 to true?

If EOF-file1
Continue
Else
Move key to Ws-temp-key-file1
End-if

Read-part-exit
Exit
Back to top
View user's profile Send private message
vijay_bn79

New User


Joined: 20 Nov 2006
Posts: 48
Location: Hyderabad

PostPosted: Mon Nov 20, 2006 6:35 pm
Reply with quote

UmeySan wrote:
Hi !

@vijay_bn79

I didn't criticize yor coding. I was only clarifying what's happening by reading files in matching-record manner.


The question was :

I have two flat files with one field as key in both files with few more fields on it. By using the key i want to compare the records in two flat files.
If it's equal then i have to store in the separate file. This should be done using cobol program. Let me know how can we do this.


Regards, UmeySan


Hi ..,

my code also doing the same na..,

see it will read 1st record of FILE1 and take the KEY1
and start reading FILE2 1 by 1 record sequentially
and compares the 1st record(KEY1) of FILE1 with each record (KEY2) of the FILE2 untill it matches with the KEY1 if matches then it will stop reading the records of FILE2 and write into new file
if it is not matching then it will read until end of the FILE2

same process will happen until end of FILE1 file
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts To search DB2 table based on Conditio... DB2 1
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Evaluate variable to execute a jcl step JCL & VSAM 3
No new posts Expand ISPF field up to a limit - is ... TSO/ISPF 9
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
Search our Forums:

Back to Top