file handling using open cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

file handling using open cobol

Postby theju112 » Sun Apr 14, 2013 8:57 pm

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
theju112
 
Posts: 3
Joined: Sat Apr 06, 2013 3:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: file handling using open cobol

Postby enrico-sorichetti » Sun Apr 14, 2013 10:00 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3003
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: file handling using open cobol

Postby BillyBoyo » Sun Apr 14, 2013 10:18 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: file handling using open cobol

Postby Robert Sample » Mon Apr 15, 2013 2:16 am

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).
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post