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

PROBLEM WITH CHANGE OF RECORD LAYOUT

Status
Not open for further replies.

shaily123

Programmer
Feb 5, 2005
17
0
0
US
Hi,

I have cobol code like below.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
FILE-CONTROL.

SELECT ABC_FILE ASSIGN TO 'ABC_FILE'
ORGANIZATION IS INDEXED
RECORD KEY IS XXX OF ABC_FILE
ALTERNATE RECORD KEY IS ZZZ OF ABC_FILE
ACCESS MODE IS DYNAMIC
FILE STATUS IS FILE_STATUS.

DATA DIVISION

FILE SECTION.

FD ABC_FILE EXTERNAL
LABEL RECORDS ARE STANDARD.

01 ABC_PLAN_RECORD.
02 XXX.
ETC....
ETC....




IN THIS CODE MY RECORD LAYOUT GOT CHANGE SO I CREATED A NEW RECORD LAYOUT WITH NAME NEW_ABC_PLAN_RECORD AND IN MY CODE I JUST REPLACE FD PORTION TO BELOW

FD ABC_FILE EXTERNAL
LABEL RECORDS ARE STANDARD.

01 NEW_ABC_PLAN_RECORD.
02 XXX.
ETC....
ETC....



QUESTION: WHAT ELSE I NEED TO CHANGE. B'COS WHEN I RUN THE PROGRAM IT IS NOT SHOWING ANY RECORD. PREVIOUSLY IT WAS SHOWING RECORDS. i HAVE NOT CHANGED THE NAME OF DATA FILE. IT IS SAME AND ON THE SAME LOCATION AND SHOWN BY LOGICAL "ABC_FILE".

pLEASE TELL ME WHERE I AM DOING MISTAKE....
 
Why did you change the record name ?
All the WRITE and REWRITE statements are broken now.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I have to change the record name bcos the layout get change. Some field change to new size so I created a new record layout and replace the new one in place of old one. As file size is sane so i do not change the name of file.

Write and rewrite goes with the file name not with the record layout. If i an inputing the values individually in the record layout and the saying write to new record layout with new record name. It shaould work from my point of view.
 
if you change the layout of a file (in terms of FD or SELECT), then files created using the old layout can not be used anymore.

Common practice on this situations is to have a conversion program that holds two logical files.

File 1 - Old record layout. (assign filename = old filename)

File 2 - New record layout. (assign filename = old filename_tmp)


Open input file 1
open output file 2

read file 1 until end of file
for each record populate file 2 fields
and write file 2 record


At end of processing the file copy the "old filename_tmp" file over the "old filename"



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Which key are you using?

When you mention the Alternate key I think COBOL Expects you to use that key. If access mode is dynamic you can access with the START command, and also do consecutive reads after that point. If you want purely random reads you should use "ACCESS IS RANDOM".

If you do not like my post feel free to point out your opinion or my errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top