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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable data file names 1

Status
Not open for further replies.

kjdames

Technical User
Feb 18, 2004
2
US
Greetings to all. I'm new to COBOL and I have been given a stumper.

First, I'm using rm/cobol85 version 7.5 on redhat linux.

My problem: I need my program to build a data file named for the current year and month in YYMM format. For example, every time the program is executed in February 2004, it would output data to a file named 0402DATA. Starting March 1st, the data should be output to 0403DATA. If the file 0403DATA already exists when the program is ran, the new data should overwrite the old data.

Is this even possible? Could anybody point me in the right direction to do this?
 
I almost forgot...our data file organization is indexed, and I need this one to be also. I need to be able to read, write, and rewrite records in this file.
 
kjdames asks, "Is this even possible? Could anybody point me in the right direction to do this?"

Yes.

Yes. Check page 3-25 of the RM/COBOL Language Reference Manual for a description of the ASSIGN clause. Pay specific attention to the description of data-name-1 (on the next page, 3-26). the value of which is used at OPEN time.

Use ACCEPT identifier FROM DATE to fetch the date information used to compute the filename (ibid page 6-2).

Use OPEN OUTPUT file-name to assure that new data overwrites existing data (ibid page 6-116).

Missing the appropriate documentation? Try
Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top