Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some Help with Cobol code! 1

Status
Not open for further replies.

Remo1978

Technical User
May 1, 2002
8
NL
Hello,

can anyone help me please?! I'm from the Netherlands.
---
can someone put the next text in programming code:

As long as not all persons from PERSOON.seq
read persoon
search persnumber in BESTEL.seq
if there
than search persnumber in MODEM.seq
if there
than fill fields and write RESULT.seq

The field that have to be written to RESULT.seq are persnumber and persname from PERSOON.seq
---

PLEASE HELP. I allmost know nothing about Cobol.

Sincerely.

Remo
 
Of ben je niet meer te redden als je uit Nederland komt?? :) Oh help mij want ik kom uit Nederland.

Assuming all the files are sequential:

MAIN SECTION.
M001.
OPEN INPUT PERSOONFILE.
OPEN OUTPUT RESULTFILE.
M010.
READ PERSOONFILE AT END
CLOSE PERSOONFILE
CLOSE RESULTFILE
STOP RUN.
PERFORM ZOEKPERSOON.
GO TO M010.
M999.
EXIT.

ZOEKPERSOON SECTION.
ZP001.
OPEN INPUT BESTELFILE.
ZP010.
READ BESTELFILE AT END
CLOSE BESTELFILE
GO TO ZP999.
IF BESTEL-PERSOON = PERSOON-PERSOON
PERFORM ZOEKMODEM
CLOSE BESTELFILE
GO TO ZP999.
GO TO ZP010.
ZP999.
EXIT.

ZOEKMODEM SECTION.
ZM001.
OPEN INPUT MODEMFILE.
ZM010.
READ MODEMFILE AT END
CLOSE MODEMFILE
GO TO ZM999.
IF MODEM-PERSOON = PERSOON-PERSOON
PERFORM SCHRIJFNAARRESULT
CLOSE MODEMFILE
GO TO ZM999.
GO TO ZM010.
ZM999.
EXIT.

SCHRIJFNAARRESULT SECTION.
S001.
MOVE PERSOON-PERSOON TO RESULT-PERSOON.
MOVE PERSON-NAAM TO RESULT-NAAM.
WRITE RESULT-RECORD.
S999.
EXIT.

Another (faster) solution would be reading the files BESTEL and MODEM into an array so they only have to be opened and read once, or change them to indexed files, then you can check for their existance with a single READ statement and you don't need closing the files all the times. Also if the files are sequential, but sorted on PERSOON-PERSOON, BESTEL-PERSOON and MODEM-PERSOON, the solution is different by reading all the files only once.

Marcel

 
I meant that my English isn't so good because i'm from the Netherlands. :)

Thanks for helping me. But what must i write in the Working-Storage Section?

Remo
 
There is no working-storage.

IDENTIFICATION DIVISION.
PROGRAM-ID. REMO1978.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PERSOONFILE ASSIGN TO "PERSOON.DAT"
ORGANIZATION IS SEQUENTIAL.
<Three more select statements here for the other files>

DATA DIVISION.
FILE SECTION.
FD PERSOONFILE RECORD CONTAINS ... CHARACTERS.
01 PERSOON-RECORD.
05 PERSOON-PERSOON PIC 9(...).
05 PERSOON-NAAM PIC X(..).

<Three more FD, 01, 05 here for the other files>

PROCEDURE DIVISION.


<the part of the program I sent you yesterday will be inserted here>

 
If all files are sorted on persnumber order, there is no need for repeated opens/closes nor for internal tables; a three-file balance line program will do. I don't have the time to write it out in code; anyone? --------
Regards,
Ronald.
 
Ik ben bang dat de 'Dutchies' op deze manier weer een slechte naam krijgen: alles gratis in de schoot.... Is het een cursus of zo?

Translation: I am afraid that the Dutch are getting a bad name again this way: everying for free.... Is this about a course?
 
Next time it is better to say &quot;I'm from Barcelona&quot;
Greetings from sunny Barcelona,

Marcel

 
When i'm not mistaken, up 'till now this is an all dutch thread; nietwaar, jongens?
C'mon guys, throw in some international input! --------
Regards,
Ronald.
 
Hi All,

Haven't been keeping up w/this thread, but noticed Ron's comment about not doing repeated opens.

Beware doing opens/closes in a read loop!!! I came across a pgm that wrote data to a temp file for each account it processed, then rewrote the data to create a multi-page invoice for each account. There were 20,000 accounts. It ran for 3 1/2 hours.

I got permission (not as easy as it sounds) to rewrite it to eliminate the open/closes. It ran in 10 minutes!!! I knew going in that o/c's are expensive, but I never expected that kind of payback.

Just one of those things to keep an eye out for.

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top