Page 1 of 1

Updating/Changing Library File Questions

PostPosted: Sat Oct 01, 2011 3:43 am
by crazycobol
hello everyone. I have a question about library file. Is it okay to change a length of a field within the library file without any issue occuring?

For example:

I have a library file called employer file has the following:

01 Employee

05 ID                  PIC X (10).
05 NAME             PIC X (50).
05 ADDRESS        PIC X (60).
05 PERCENT        PIC 9(3).
     10 PERCENT2 REDEFINES PERCENT PIC 9V99.
05 ZIP CODE        PIC X (10).
05 COUNTRY       PIC X (10).
05 FILLER           PIC X (100).


If I want to change the Percent field to be PIC 9(4) instead of PIC 9(3). Would it hurt anything? or will I experience a file error. Thank you for any help. :)

Re: Updating/Changing Library File Questions

PostPosted: Sat Oct 01, 2011 3:48 am
by crazycobol
To add addition information:

The program start as follows:

IDENTIFICATION DIVISION.
PROGRAM-ID. EMPLOYER.
AUTHOR. PROGRAMMER.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. COMPAQ.
OBJECT-COMPUTER. COMPAQ.

INPUT-OUTPUT SECTION.
FILE-CONTROL.

SELECT EMPLOYER ASSIGN TO DISK WS-EMPLOYER
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
STATUS IS FILE-LOCK
LOCK MODE IS MANUAL
RECORD KEY IS ID
ALTERNATE KEY IS NAME WITH DUPLICATES.

DATA DIVISION.
FILE SECTION.

COPY "C:\LIBRARY\EMPLOYER.LIB".

Re: Updating/Changing Library File Questions

PostPosted: Sat Oct 01, 2011 10:56 am
by NicC
You seem to be running on a PC - this is a mainframe forum. I also do not understand the terminology used in your question - even for a PC.

Re: Updating/Changing Library File Questions

PostPosted: Sat Oct 01, 2011 3:23 pm
by BillyBoyo
As NicC has pointed out, you are running on a PC. This is an IBM mainframe Cobol forum. There are sufficient differences between mainframes and PCs for us to give you the wrong advice, so try looking for a forum for your particular Cobol compiler or at least for your operating system.

A general point about a record-layout. If you change a field's length, and there is already data after that field, then you have to "convert" the file so that the data conforms to the new record-layout. You should (on a mainframe, anyway) reduce the length of the filler by one.

The "cheap" way to do it is to change your existing PERCENT to FILLER and then take four bytes from the FILLER at the end of the record, leaving the remaining filler as the last field, and put your four bytes percent and redefinition there. If it is a system for yourself, you can do it that way, if it is a system where you are on a team, find out from the leader of the team, who is responsible for changing the record, converting the file if necessary.

Good luck in your new forum.

Re: Updating/Changing Library File Questions

PostPosted: Sun Oct 02, 2011 9:22 am
by dick scherrer
Hello,

If there is currently no data from the "old" format, you should be able to change the layout with no penalty.

If there is existing data in the old format, the code will probably have problems trying to read it.

You could always convert the existing data to the new format at the time the layout (copybook) is changed.

Re: Updating/Changing Library File Questions

PostPosted: Mon Oct 03, 2011 10:16 pm
by crazycobol
thank you for the response.

There is existing data so I would change the layout (library file) and then write a program to convert the existing data to the new layout.

With any suggestion I get, I always perform it in a test environment before moving it into production. I'm fairly new to cobol so I appreciate all the assistance I can get. :)

Re: Updating/Changing Library File Questions

PostPosted: Mon Oct 03, 2011 11:38 pm
by BillyBoyo
And is anything you are running on a mainframe?

Re: Updating/Changing Library File Questions

PostPosted: Tue Oct 04, 2011 12:41 am
by dick scherrer
Hello,

To reformat the records, simply read the "old" and write the "new".

What have you done so far? What happened?

Are you stuck somewhere?

Re: Updating/Changing Library File Questions

PostPosted: Wed Oct 05, 2011 9:34 pm
by crazycobol
Hello. I understand the concept. I haven't had a chance to work on it yet but I will soon. It seem to be pretty straight forward. Thank you for your help. It is very much appreciated.

Re: Updating/Changing Library File Questions

PostPosted: Wed Oct 05, 2011 9:59 pm
by dick scherrer
Good luck - someone will be here if there are questions :)

d