55 pts.
 Adding Field to a PF
I have to add some new fileds to an existing PF without compiling the PF how can i do that? can i use this updated PF in my RPG ILE program without facing any error/exception?

Software/Hardware used:
ASKED: May 19, 2008  6:50 AM
UPDATED: April 21, 2010  2:54 PM

Answer Wiki:
Hi, If you're adding fields to a PF you can update the object description using the CHGPF command :- CHGPF FILE(yourlib/yourfile) SRCFILE(yoursrclib/yoursrcfile) SRCMBR(*FILE) You may get level check errors at runtime if you don't recompile your RPG programs. Regards, Martin Gilbert.
Last Wiki Answer Submitted:  May 19, 2008  8:55 am  by  Gilly400   23,625 pts.
All Answer Wiki Contributors:  Gilly400   23,625 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

if i have data in existing file and i add some new fields to PF then i have to re-compile PF again, but i will re-compile PF then existing data will be erased, but i don’t want to erase the existing data and i want use updated PF in my RPG program then what i have to do?

 55 pts.

 

Using CHGPF command
First change the Fields thru the DDS of the file
then Use CHGPF Command.

 455 pts.

 

Hi,

If you use the CHGPF command you won’t need to recompile the PF (the CHGPF command updates the format of the file using your DDS) and your data should stay intact, although I suggest you take a copy first, just in case. You will probably need to recompile your RPG program to reference the new file format, otherwise you’ll get level check errors at runtime.

Regards,

Martin Gilbert.

 23,625 pts.

 

You will probably need to recompile your RPG program to reference the new file format…

This is one of the reasons that LFs exist — so that you can change the underlying PF without needing to recompile programs. A PF probably should only be referenced in a single ‘maintenance’ program. All other programs should be compiled over appropriate LFs. The LFs should have explicit field lists rather than defaulting to “all fields”.

If an application is written correctly, PFs can be modified in a variety of ways, giving new format level IDs every time, and requiring just a single ‘maintenance’ program to be recompiled.

A field may be added to a PF. Until the field is added to an existing LF, programs using that LF can be left alone. In many cases, a new LF can be created where the new field is exposed. A new field often has very limited exposure, so it’s possible to keep changes very limited.

Tom

 110,165 pts.

 

You may use SQL to add coloumn(s):

ALTER TABLE mylib/mypf ADD COLUMN mynewield VARCHAR (30) NOT NULL WITH DEFAULT

The add fieldheading(s):

LABEL ON COLUMN mypf.mynewfield IS 'Header line1        Header line2        Header line 3'

Not: each headerline takes 20 chars.

DanF

 2,555 pts.

 

Ouup….
my previous went wron.. Here’s my new try:

You may use SQL to add coloumn(s):

ALTER TABLE mylib/myfile 
ADD COLUMN mynewfield VARCHAR (30) NOT NULL WITH DEFAULT

Then add fieldheading(s):

LABEL ON COLUMN mylib/myfile.mynewfield 
IS 'Headerline1         Headerline2         Headerline3'

Note: each headerline takes 20 chars.

DanF

 2,555 pts.