easytrieve problem



Unicenter CA-Easytrieve Plus Report Generator: CA's information retrieval and data management tool

easytrieve problem

Postby ruel » Sat Jun 27, 2009 4:09 pm

Hi all,

I'm a newbie using easytrieve and i created one recently but is encountering invalid file reference problem. The program i created is reading a sequential file and then search the read record in another sequential file until found or eof and then read the next record in first file and search again in he second file. If the record is not found in second file then i just write the first file to output file an read the next record in first file. If the record read in first file is found in second file, replace the cust-id field in first file position 4-8 with the master cust-id field in second file position 10-14 and then write th record read. Both files have same length. Below is the pseudocode of my program:

job input(null)
do while not eof file-a
get file-a
if eof file-a
stop
else
search read file-a record in file-b until eof or found
if not found and reached eof of file-b
write file-a to output file
else
if found
replace cust-id of file-a with master cust-id of file-b then write the record in output file
end-if
end-if
end-if
end-do

when i run the job running the easytrieve, it went thru the first record in file-a and search in file-b, the first record was not found in file-b and so it was written to the output file as is (without replacing the cust-id), and then the program read the next record in file-a and then when it search in file-b it got terminated with invalid-file-reference error due to i think that file-b is already in eof. Is there anything i could do to reset the pointer to read again at the beginning of file-b? or is there any other option i can use like let's say icetool who could perform the same logic this easytrive suppose to do?

Thanks and appreciate your help on this.
ruel
 
Posts: 6
Joined: Sat Jun 27, 2009 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: easytrieve problem

Postby ruel » Sat Jun 27, 2009 8:52 pm

by the way, additional information, file-a and file-b have account number field which is in the same position for both files, this is the criteria i'm checking to match the two files. Sorry to say that the column position i said in the previous post is incorrect. By the way, my expected output is to just rewrite exactly file-a into the output file, meaning read-write per record as i need to send the same file in it's original sequence as sent by interface team, the only thing i need to do is to change the customer id field value with master id field value when the record is found in file-b, if not found then write as is. To illustrate further, below is a sample file i'm comparing:

field positions for you reference:
ACCOUNT NUMBER FIELD is in position 4-8 i.e. 12345
CUSTOMER ID FIELD is in position 9-13 i.e. CUST1
MASTER ID FIELD is in position 24-28 i.e. MAST1

file-a:
G0100906270000000001938745898696969000
G20112345CUST11234567890MAST16547389
G20222345CUST21234567890MAST26547389
G20132345CUST31234567890MAST36547389
G20242345CUST41234567890MAST46547389
G20352345CUST51234567890MAST56547389
G020090627000000000000000000000000005
G0100906280000000001938745898696969000
G20142345CUST11234567890MAST16547389
G20252345CUST21234567890MAST26547389
G20162345CUST31234567890MAST36547389
G20272345CUST41234567890MAST46547389
G20382345CUST51234567890MAST56547389
G020090628000000000000000000000000005
G0100906290000000001938745898696969000
G20192345CUST11234567890MAST16547389
G20299345CUST21234567890MAST26547389
G020090629000000000000000000000000005


file-b:
G20162345CUST31234567890MAST36547389
G20192345CUST11234567890MAST16547389
G20112345CUST11234567890MAST16547389
G20132345CUST31234567890MAST36547389
G20142345CUST11234567890MAST16547389

expected output:
G0100906270000000001938745898696969000
G20112345MAST11234567890MAST16547389
G20222345CUST21234567890MAST26547389
G20132345MAST31234567890MAST36547389
G20242345CUST41234567890MAST46547389
G20352345CUST51234567890MAST56547389
G020090627000000000000000000000000005
G0100906280000000001938745898696969000
G20142345MAST11234567890MAST16547389
G20252345CUST21234567890MAST26547389
G20162345MAST31234567890MAST36547389
G20272345CUST41234567890MAST46547389
G20382345CUST51234567890MAST56547389
G020090628000000000000000000000000005
G0100906290000000001938745898696969000
G20192345MAST11234567890MAST16547389
G20299345CUST21234567890MAST26547389
G020090629000000000000000000000000005

Thanks in advance for helping.
ruel
 
Posts: 6
Joined: Sat Jun 27, 2009 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: easytrieve problem

Postby dick scherrer » Sat Jun 27, 2009 11:17 pm

Hello,

The worst possible way to "match" 2 files is to read one and then read all of the other repeatedly looking for "hits". I did not closely read thru the code as it needs to be re-done. If your organization has any decent review of code, it will be rejected.

What you need is a 2-file match/merge (there happens to be a working cobol example in a "Sticky" at the top of the COBOL part of our forum :) ). If you use this as a model, you can write the proper Easytrieve code. You might use a JOB INPUT NULL (as you have) and then use GETs to access both of the 2 files. You would not use SEARCH.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: easytrieve problem

Postby ruel » Sun Jun 28, 2009 1:12 pm

Hi Dick,

Thanks for your advise, sorry as i'm not that familiar with easytrieve. Thanks, i'll try to read the sticky.
ruel
 
Posts: 6
Joined: Sat Jun 27, 2009 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: easytrieve problem

Postby dick scherrer » Sun Jun 28, 2009 9:44 pm

Hello,

i'm not that familiar with easytrieve
Yet. . . ;)

To read the Sticky, you may be able to simply click on it. If this does not work correctly, right-click and Save As.

Good luck :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: easytrieve problem

Postby ruel » Mon Jun 29, 2009 5:01 pm

thanks dick, i already downloaded the file. i'll give it a try tomorrow at the office. thanks
ruel
 
Posts: 6
Joined: Sat Jun 27, 2009 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: easytrieve problem

Postby dick scherrer » Tue Jun 30, 2009 2:12 am

You're welcome - good luck :)

Someone will be here if there are questions.

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: easytrieve problem

Postby ruel » Wed Jul 01, 2009 5:22 pm

hi Dick,

The sticky is quite straight-forward and i think is not suitable for easytrieve as i cannot use GO TO a particular PROC in easytrieve because it got error during compile saying GO TO cannot be use to point to a PROC. Is there anyway that i can close and then open the file again for usage of the job? Or it's not possible as files are automatically open and close by easytrieve. Because when EOF of file was reached already, it cannot be use anymore for searching and invalid file referece was hit.

Or could you advise other way to do my goal of reading one file and searching it in second file, once found, i need to replace a particular field of the first file with the value of a field in second file before writing the record from first file agai

input (FIRST FILE):

12345678901234567890123456789012345678901234567890123456789012345678901234567890 --> COLUMN POSITION

G010HK HOGANCASPDOA090620134711090619000000000000000000000000F
G20112CASST000SUB0000130819998750 A123456789012345
G20212CASST000SUB0000130819998750 B123456789012345
G20112CASST000SUB0000130819998769 C123456789012345
G20212CASST000SUB0000130819998769 D123456789012345
G20112CASST000SUB0000130819998777 E123456789012345
G20212CASST000SUB0000130819998777 F123456789012345
G20112CASST000SUB0000130819998785 G123456789012345
G20212CASST000SUB0000130819998785 H123456789012345
G20112CASST000SUB0000130819998793 I123456789012345
G20212CASST000SUB0000130819998793 J123456789012345
G20112CASST000SUB0000130819998807 K123456789012345
G20212CASST000SUB0000130819998807 L123456789012345
G02000002246 50335724.200
G010HK HOGANCASPDOA090620134711090620000000000000000000000000F
G20112CASST000SUB0001230819996138 M123456789012345
G20212CASST000SUB0001230819996138 N123456789012345
G20312CASST000SUB0001230819996138 O123456789012345
G20112CASST000SUB0001430819996065 P123456789012345
G20212CASST000SUB0001430819996065 Q123456789012345
G20312CASST000SUB0001430819996065 R123456789012345
G20112CASST000SUB0001430819996073 S123456789012345
G20212CASST000SUB0001430819996073 T123456789012345
G20312CASST000SUB0001430819996073 U123456789012345
G20112CASST000SUB0001430819996081 V123456789012345
G20212CASST000SUB0001430819996081 W123456789012345
G20312CASST000SUB0001430819996081 X123456789012345
G02000000012 582753.960

input (SECOND FILE): all G201 records only

G20112CASST000SUB0000130819998750 A123456789012345
G20112CASST000SUB0000130819998769 C123456789012345
G20112CASST000SUB0000130819998777 E123456789012345
G20112CASST000SUB0000130819998785 G123456789012345
G20112CASST000SUB0000130819998793 I123456789012345
G20112CASST000SUB0000130819998807 K123456789012345
G20112CASST000SUB0001230819996138 M123456789012345
G20112CASST000SUB0001430819996065 P123456789012345
G20112CASST000SUB0001430819996073 S123456789012345
G20112CASST000SUB0001430819996081 V123456789012345

expected OUTPUT:

if account number read in file 1 is equal to account number read in file 2 which are both in postion 24-34 of both files, replace file 1 customer id which is in position 8-23 with master customer id which is in column 48-63 of file 2 then rewrite file1, if not equal then write file-1 as is and then proceed to next record until all file-1 is read and is eithere replace before written or written as is in output file.

Thanks in advance
ruel
 
Posts: 6
Joined: Sat Jun 27, 2009 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: easytrieve problem

Postby dick scherrer » Thu Jul 02, 2009 2:39 am

Hello,

i cannot use GO TO a particular PROC in easytrieve because it got error during compile saying GO TO cannot be use to point to a PROC
Correct, but you CAN go to JOB which will get you back to the top of the loop (which for your requirement would be JOB INPUT NULL as i mentioned before) and you can GOTO label . . . which would be the equivelant of paragraphs in cobol.

If you do not have the documentation for the release of Easytrieve you are using, you need to get it and store it on your system.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: easytrieve problem

Postby ruel » Thu Jul 02, 2009 8:38 am

Hi Dick,

Thanks for your patience, i read thru the sticky and applied it with my easytrieve but is still getting invalid file reference after reaching EOF of second file, please see my code below and feel free to examine what mistake i'm doing. Thanks.

*===================================================================*
* INPUT FILES *
*===================================================================*
*
FILE XI87645 FB(512 0)
XI87645-REC 1 512 A
XI87645-GREC 1 4 A
XI87645-CUST-ID 5 18 A
XI87645-ACCT-NUM 23 34 A
XI87645-CAS-MSTR-CUSTID 240 18 A
*
FILE XI87645A FB(512 0)
XI87645A-REC 1 512 A
XI87645A-GREC 1 4 A
XI87645A-CUST-ID 5 18 A
XI87645A-ACCT-NUM 23 34 A
XI87645A-CAS-MSTR-CUSTID 240 18 A
*
*===================================================================*
* OUTPUT FILE *
*===================================================================*
* FILE WITH SUB-ACCOUNTS REPLACED WITH MASTER CUST-ID
FILE XO87645 FB(512 0)
XO87645-REC 1 512 A
XO87645-CUST-ID 5 18 A
*-----------------------------------------------------------------
* WORKING STORAGE
*-----------------------------------------------------------------
WS-EOF-XI87645 W 1 A VALUE 'N'
WS-EOF-XI87645A W 1 A VALUE 'N'
WS-REC-FOUND W 1 A VALUE 'Y'
WS-REC-SEARCH W 1 A VALUE 'Y'
WS-FILE1-ACCT W 34 A
WS-FILE2-ACCT W 34 A
*
*===================================================================*
* JOB STARTS - PROCEDURE DIVISION *
*===================================================================*
*
JOB INPUT(NULL)

IF WS-EOF-XI87645 = 'Y' +
OR WS-REC-FOUND = 'N'
GO TO QUIT-JOB
END-IF

GET XI87645
IF EOF XI87645
MOVE 'Y' TO WS-EOF-XI87645
MOVE 'N' TO WS-REC-FOUND
GO TO QUIT-JOB
END-IF

MOVE XI87645-ACCT-NUM TO WS-FILE1-ACCT
MOVE 'N' TO WS-REC-FOUND
QUIT-JOB
PERFORM AA000-SEARCH-MATCH
*
AA000-SEARCH-MATCH. PROC

IF WS-EOF-XI87645A = 'Y' +
OR WS-REC-SEARCH = 'N'
GO TO QUIT-AA000
END-IF

GET XI87645A
IF EOF XI87645
MOVE 'Y' TO WS-EOF-XI87645A
MOVE 'N' TO WS-REC-SEARCH
GO TO QUIT-AA000
END-IF

MOVE XI87645A-ACCT-NUM TO WS-FILE2-ACCT
MOVE 'N' TO WS-REC-SEARCH
QUIT-AA000
PERFORM BB000-MATCH-RECS

END-PROC
*
BB000-MATCH-RECS. PROC

IF WS-EOF-XI87645 = 'Y' +
AND WS-EOF-XI87645A = 'Y'
STOP
END-IF

IF WS-EOF-XI87645A = 'Y' +
AND WS-REC-FOUND = 'N'
WS-REC-FOUND = 'Y'
XO87645-REC = XI87645-REC
PUT XO87645
GO TO JOB
END-IF

IF WS-FILE1-ACCT = WS-FILE2-ACCT
WS-REC-FOUND = 'Y'
XO87645-REC = XI87645-REC
XO87645-CUST-ID = XI87645A-CAS-MSTR-CUSTID
PUT XO87645
GO TO JOB
ELSE
WS-REC-SEARCH = 'Y'
PERFORM AA000-SEARCH-MATCH
END-IF

END-PROC
ruel
 
Posts: 6
Joined: Sat Jun 27, 2009 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to CA-Easytrieve

 


  • Related topics
    Replies
    Views
    Last post