×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Title: Basic Cobol
Here is a simple COBOL program: to compile, use option
14 in PDM. The program reads all records from FILE1 and prints
them.
IDENTIFICATION
DIVISION.
PROGRAM-ID.
PGM1.
ENVIRONMENT
DIVISION.
INPUT-OUTPUT
SECTION.
FILE-CONTROL.
SELECT
File1
ASSIGN TO DATABASE-file1.
SELECT
Prntr
ASSIGN TO PRINTER-Prntr.
DATA
DIVISION.
FILE
SECTION.
FD
File1.
01
file1-rec.
COPY
DDS-ALL-FORMATS OF
file1.
FD
prntr.
01
prntr-rec pic
x(100).
WORKING-STORAGE
SECTION.
01
WS-FLAG-EOF PIC X
VALUE
SPACE.
88
EOF
VALUE
'Y'.
PROCEDURE
DIVISION.
****************************************************************
* MAIN
ROUTINES
****************************************************************
MAINLINE.
PERFORM
SETUP
PERFORM
main-process UNTIL
EOF
PERFORM
ENDUP
STOP
RUN.
SETUP.
OPEN INPUT
file1
output
prntr.
READ file1 at
end stop
run.
main-process.
write prntr-rec
from
file1-rec.
READ file1 at
end move 'Y' to ws-flag-eof.
ENDUP.
CLOSE File1
prntr.
I am an RPG developer and I have not used COBOL in the past.
Can anyone tell me how to write a basic COBOL program. An example would be how
to compile a COBOL program that uses a physical or logical file.
Thanks.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.