Page 1 of 1

file handling using open cobol

PostPosted: Sun Apr 14, 2013 8:57 pm
by theju112
before posting my doubt, i request the admin not to lock this thread like my previous thread as this is an open cobol question...those foruns have suspended new user registrations...
....i am currently undergoing mainframe training in my company...i have installed cygwin and opencobol in my system...and the basic programs are working fine...but please tell me how to work with files in cygwin... i mean in our simulator in office, we give file names in the jcl used to run the cobol program...and use it in the cobol program using addign dd1 to file-name, where dd1 is the ddname in the jcl..how to do this in open cobol? please give me a way to do this without jcl

Re: file handling using open cobol

PostPosted: Sun Apr 14, 2013 10:00 pm
by enrico-sorichetti
everything is explained pretty well here

http://opencobol.add1tocobol.com/ocfaq. ... ment-ocfaq

and search for the ASSIGN cobol keyword

to arrive at
http://opencobol.add1tocobol.com/ocfaq.html#assign
and
http://opencobol.add1tocobol.com/ocfaq. ... tion-files

where You can read about the behavior of the ASSIGN clause under open cobol

assign-clause: mf

# If yes, file names are resolved at run time using environment variables.
# For example, given ASSIGN TO "DATAFILE", the actual file name will be
# 1. the value of environment variable `DD_DATAFILE' or
# 2. the value of environment variable `dd_DATAFILE' or
# 3. the value of environment variable `DATAFILE' or
# 4. the literal "DATAFILE"
# If no, the value of the assign clause is the file name.
#
# Value: `yes', `no'
filename-mapping: yes

Re: file handling using open cobol

PostPosted: Sun Apr 14, 2013 10:18 pm
by BillyBoyo
OpenCobol is now at SourceForge.

If you go here, http://sourceforge.net/p/open-cobol/discussion/, you should see that the first section is "Help getting started". Get yourself a user-id there (else you'll find a long delay before your post is "reviewed") and ask there. Browse around a little as well.

At least one way to get the files is to code the file-name on the SELECT.

Re: file handling using open cobol

PostPosted: Mon Apr 15, 2013 2:16 am
by Robert Sample
One way:
000180     SELECT DEL-STATS         ASSIGN TO DELSTATS
                ORGANIZATION INDEXED
                ACCESS SEQUENTIAL
                RECORD KEY DSR-KEY
                FILE STATUS DELSTATS-STAT.
000190     SELECT RATE-OUT          ASSIGN TO PSTLRATE
                ORGANIZATION LINE SEQUENTIAL
                FILE STATUS PSTLRATE-STAT.
.
.
.
000520 WORKING-STORAGE SECTION.
       01  OPEN-COBOL-VARIABLES.
           05  DELSTATS                     PIC X(128) VALUE
      '../data/Delstats/Delstats.master.file'.
           05  DELSTATS-STAT                 PIC 9(02).
           05  PSTLRATE                     PIC X(128) VALUE
      '../data/CDS/postal.rate.file'.
           05  PSTLRATE-STAT                PIC 9(02).