Adding Field to a PF

55 pts.
Tags:
RPG ILE
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?

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Chandra93
    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 pointsBadges:
    report
  • ReshmaG
    Using CHGPF command First change the Fields thru the DDS of the file then Use CHGPF Command.
    455 pointsBadges:
    report
  • Gilly400
    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,730 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • DanTheDane
    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 pointsBadges:
    report
  • DanTheDane
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following