Updating/Changing Library File Questions



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

Updating/Changing Library File Questions

Postby crazycobol » Sat Oct 01, 2011 3:43 am

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. :)
crazycobol
 
Posts: 35
Joined: Fri Dec 04, 2009 3:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: Updating/Changing Library File Questions

Postby crazycobol » Sat Oct 01, 2011 3:48 am

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".
crazycobol
 
Posts: 35
Joined: Fri Dec 04, 2009 3:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: Updating/Changing Library File Questions

Postby NicC » Sat Oct 01, 2011 10:56 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Updating/Changing Library File Questions

Postby BillyBoyo » Sat Oct 01, 2011 3:23 pm

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

Re: Updating/Changing Library File Questions

Postby dick scherrer » Sun Oct 02, 2011 9:22 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Updating/Changing Library File Questions

Postby crazycobol » Mon Oct 03, 2011 10:16 pm

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. :)
crazycobol
 
Posts: 35
Joined: Fri Dec 04, 2009 3:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: Updating/Changing Library File Questions

Postby BillyBoyo » Mon Oct 03, 2011 11:38 pm

And is anything you are running on a mainframe?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Updating/Changing Library File Questions

Postby dick scherrer » Tue Oct 04, 2011 12:41 am

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?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Updating/Changing Library File Questions

Postby crazycobol » Wed Oct 05, 2011 9:34 pm

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.
crazycobol
 
Posts: 35
Joined: Fri Dec 04, 2009 3:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: Updating/Changing Library File Questions

Postby dick scherrer » Wed Oct 05, 2011 9:59 pm

Good luck - someone will be here if there are questions :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post