Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

algorithm
Hello,

I've got two files describe like this :

First file (with three keys : GCFCL-CLE, GCFCL-CLE2 and GCFCL-CLE3) :

FD  FGCFCL LABEL RECORD STANDARD.
01  GCFCL-FILE.
02 GCFCL-CLE.
04 GCFCL-JR          PIC 999.
04 GCFCL-DATE.
06 GCFCL-ANNEE    PIC 9(4).
06 GCFCL-MOIS     PIC 99.
06 GCFCL-JOUR     PIC 99.
04 GCFCL-NOPIECE     PIC 9(7).
04 GCFCL-TIERS       PIC 9(6).
*
02 GCFCL-CLE2.
04 GCFCL-TIERS2      PIC 9(6).
04 GCFCL-DATE2.
06 GCFCL-ANNEE2   PIC 9(4).
06 GCFCL-MOIS2    PIC 99.
06 GCFCL-JOUR2    PIC 99.
04 GCFCL-NOPIECE2    PIC 9(7).
*
02 GCFCL-CLE3.
04 GCFCL-DATECH.
06 GCFCL-ANNEECH  PIC 9(4).
06 GCFCL-MOISECH  PIC 99.
06 GCFCL-JOURECH  PIC 99.
...

second file (with two keys : GCECL-CLE and GCECL-CLE2) :

FD  FGCECL LABEL RECORD STANDARD.
01  GCECL-FILE.
02 GCECL-CLE.
04 GCECL-JR        PIC 999.
04 GCECL-DATE.
06 GCECL-ANNEE  PIC 9(4).
06 GCECL-MOIS   PIC 99.
06 GCECL-JOUR   PIC 99.
04 GCECL-BORDEREAU PIC 9(10).
04 GCECL-NOPIECE   PIC 9(7).
04 GCECL-NOFAC     PIC 9(7).
*
02 GCECL-CLE2.
04 GCECL-TIERS2    PIC 9(6).
04 GCECL-DATE2.
06 GCECL-ANNEE2 PIC 9(4).
06 GCECL-MOIS2  PIC 99.
06 GCECL-JOUR2  PIC 99.
04 GCECL-NOPIECE2  PIC 9(7).
04 GCECL-NOFAC2    PIC 9(7).
...
(There is a trap : GCFCL-NOPIECE is different from GCECL-NOPIECE, in
fact GCFCL-NOPIECE should be equal, if a record exist, to GCECL-NOFAC)

I must read the first file sequentially. OK, no problem.

Then, for each record of the first file, I search one or more records in
the second file. And I don't know how to do that.

I tried this :

OPEN INPUT FGCFCL.
OPEN INPUT FGCECL.
OPEN OUTPUT OUTFACT.

INITIALIZE GCFCL-CLE.
INITIALIZE GCECL-CLE.

START FGCFCL KEY IS GREATER THAN GCFCL-CLE
INVALID KEY GO TO AFFICHAGE.

READ FGCFCL NEXT RECORD
AT END SET EndOfFile OF FGCFCL TO TRUE
END-READ


PERFORM UNTIL EndOfFile OF FGCFCL

MOVE GCFCL-CLE2(1:14) TO TMP-CLE
MOVE ZEROS TO TMP-CLE(15:13)
MOVE TMP-CLE TO GCECL-CLE2

START FGCECL KEY IS GREATER THAN GCECL-CLE2
READ FGCECL RECORD
KEY IS GCECL-CLE2
INVALID KEY CONTINUE
END-READ
MOVE GCECL-RGT TO OUT-RGT

WRITE OUT-INFO-FACT
READ FGCFCL NEXT RECORD
AT END SET EndOfFile OF FGCFCL TO TRUE
END-READ
END-PERFORM.

FERMETURE.
CLOSE FGCFCL.
CLOSE FGCECL.
CLOSE OUTFACT.

Best regards

Jerome

Report this thread to moderator Post Follow-up to this message
Old Post
Jerome
07-10-06 11:55 PM


Re: algorithm
Jerome wrote:

> (There is a trap : GCFCL-NOPIECE is different from GCECL-NOPIECE, in
> fact GCFCL-NOPIECE should be equal, if a record exist, to GCECL-NOFAC)
>
> I must read the first file sequentially. OK, no problem.
>
> Then, for each record of the first file, I search one or more records in
> the second file. And I don't know how to do that.

Your fields name bring to mind 'you are in a maze of little twisted
passages'.

The way to do this, using key names that I can follow:

PERFORM UNTIL Main-Key = HIGH-Values

MOVE LOW-VALUES TO Main-Key
START Main-File
KEY NOT < Main-Key
INVALID KEY
MOVE HIGH-VALUES TO Main-Key
END-START
PERFORM UNTIL Main-Key = HIGH-Values
READ Main-File
NEXT RECORD
AT END
MOVE HIGH-VALUES TO Main-Key
NOT AT END
MOVE Main-Key TO Trans-Key
START Trans-File
KEY NOT < Trans-Key
INVALID KEY
MOVE HIGH-VALUES TO Trans-Key
END-START
PERFORM UNTIL Trans-Key-Main NOT =
Main-Key
READ Trans-Key
NEXT RECORD
AT END
MOVE HIGH-VALUES TO
Trans-Key
END-READ
IF ( Trans-Key-Main = Main-Key )
process
END-IF
END-PERFORM
END-READ
END-PERFORM

Note 'Trans-Key-Main' is that part of the Trans-Key that matches
Main-Key.
NEXT RECORD will read sequentially


Report this thread to moderator Post Follow-up to this message
Old Post
Richard
07-10-06 11:55 PM


Re: algorithm
Jerome wrote:

Hint:

LOOP.
READ SEQUENTIAL-FILE.
MOVE SEQUENTIAL-FILE-KEY TO ISAM-FILE-KEY.
READ ISAM-FILE
INVALID KEY PERFORM OOPS
NOT INVALID KEY PERFORM MATCHED
END-READ.





Report this thread to moderator Post Follow-up to this message
Old Post
HeyBub
07-10-06 11:55 PM


Re: algorithm
Dear Jerome:
I would suggest looking at using the file status feature instead of
invalid key.
Also, use start verb with not less than:

select gcfcl-file
assign to whatever
file status is ws-file-status.


working-storage section.
01  ws-file-status pic 9(02) value zeroes.


start gcfcl-file key not less than some-key.

if ws-file-status equal zeroes
* found it....
else
*not on file......
display 'not found'
end-if.

read gcfcl-file next record.

* still need to check the key value...might be another key(using the
generic key, greater than or equal to...
if the-key equal key-i-was-looking-for.
found it....
else
not found
end-if.
Jerome wrote:
> Hello,
>
> I've got two files describe like this :
>
> First file (with three keys : GCFCL-CLE, GCFCL-CLE2 and GCFCL-CLE3) :
>
>         FD  FGCFCL LABEL RECORD STANDARD.
>         01  GCFCL-FILE.
>             02 GCFCL-CLE.
>                04 GCFCL-JR          PIC 999.
>                04 GCFCL-DATE.
>                   06 GCFCL-ANNEE    PIC 9(4).
>                   06 GCFCL-MOIS     PIC 99.
>                   06 GCFCL-JOUR     PIC 99.
>                04 GCFCL-NOPIECE     PIC 9(7).
>                04 GCFCL-TIERS       PIC 9(6).
>        *
>             02 GCFCL-CLE2.
>                04 GCFCL-TIERS2      PIC 9(6).
>                04 GCFCL-DATE2.
>                   06 GCFCL-ANNEE2   PIC 9(4).
>                   06 GCFCL-MOIS2    PIC 99.
>                   06 GCFCL-JOUR2    PIC 99.
>                04 GCFCL-NOPIECE2    PIC 9(7).
>        *
>             02 GCFCL-CLE3.
>                04 GCFCL-DATECH.
>                   06 GCFCL-ANNEECH  PIC 9(4).
>                   06 GCFCL-MOISECH  PIC 99.
>                   06 GCFCL-JOURECH  PIC 99.
> ...
>
> second file (with two keys : GCECL-CLE and GCECL-CLE2) :
>
>         FD  FGCECL LABEL RECORD STANDARD.
>         01  GCECL-FILE.
>             02 GCECL-CLE.
>                04 GCECL-JR        PIC 999.
>                04 GCECL-DATE.
>                   06 GCECL-ANNEE  PIC 9(4).
>                   06 GCECL-MOIS   PIC 99.
>                   06 GCECL-JOUR   PIC 99.
>                04 GCECL-BORDEREAU PIC 9(10).
>                04 GCECL-NOPIECE   PIC 9(7).
>                04 GCECL-NOFAC     PIC 9(7).
>        *
>             02 GCECL-CLE2.
>                04 GCECL-TIERS2    PIC 9(6).
>                04 GCECL-DATE2.
>                   06 GCECL-ANNEE2 PIC 9(4).
>                   06 GCECL-MOIS2  PIC 99.
>                   06 GCECL-JOUR2  PIC 99.
>                04 GCECL-NOPIECE2  PIC 9(7).
>                04 GCECL-NOFAC2    PIC 9(7).
> ...
> (There is a trap : GCFCL-NOPIECE is different from GCECL-NOPIECE, in
> fact GCFCL-NOPIECE should be equal, if a record exist, to GCECL-NOFAC)
>
> I must read the first file sequentially. OK, no problem.
>
> Then, for each record of the first file, I search one or more records in
> the second file. And I don't know how to do that.
>
> I tried this :
>
>             OPEN INPUT FGCFCL.
> 	   OPEN INPUT FGCECL.
>             OPEN OUTPUT OUTFACT.
>
>             INITIALIZE GCFCL-CLE.
> 	   INITIALIZE GCECL-CLE.
>
>             START FGCFCL KEY IS GREATER THAN GCFCL-CLE
>                 INVALID KEY GO TO AFFICHAGE.
>
>             READ FGCFCL NEXT RECORD
>                 AT END SET EndOfFile OF FGCFCL TO TRUE
>             END-READ
>
>
>             PERFORM UNTIL EndOfFile OF FGCFCL
>
>          	 MOVE GCFCL-CLE2(1:14) TO TMP-CLE
> 		 MOVE ZEROS TO TMP-CLE(15:13)
>          	 MOVE TMP-CLE TO GCECL-CLE2
>
>                 START FGCECL KEY IS GREATER THAN GCECL-CLE2
>        		 READ FGCECL RECORD
> 		     KEY IS GCECL-CLE2
> 		     INVALID KEY CONTINUE
> 		 END-READ
>        		 MOVE GCECL-RGT TO OUT-RGT
>
>          	 WRITE OUT-INFO-FACT
>         	        READ FGCFCL NEXT RECORD
>                     AT END SET EndOfFile OF FGCFCL TO TRUE
>        	        END-READ
>             END-PERFORM.
>
> 	FERMETURE.
> 	    CLOSE FGCFCL.
> 	    CLOSE FGCECL.
>             CLOSE OUTFACT.
>
> Best regards
>
> Jerome


Report this thread to moderator Post Follow-up to this message
Old Post
hcmason@sbcglobal.net
07-10-06 11:55 PM


Re: algorithm
Thank you very much for your answers.

I'm going to try all your advices and hints.

Best regards

Jerome

Report this thread to moderator Post Follow-up to this message
Old Post
Jerome
07-11-06 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:28 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.