CHGPF command

pts.
Tags:
AS/400
IBM DB2
RPG
I am starting a project where I have to expand a field within a file and also add another field to the end of the same file. My question is this: I've never used the CHGPF command to change the file in the following situation. I've heard that you can use this command to create the new object and at the same time, the system will copy the data from the old file version to the new file version. (a combination of the CRTPF and CPYF all in one) Am I correct in assuming that when the system does this (CHGPF) it will map the data correctly to the proper fields?

Answer Wiki

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

yes. works great. It is possible to run into problems if you try to convert an existing field to a different type.

Discuss This Question: 2  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
  • TheQuigs
    Effectively, yes. As long as you don't delete any fields or take any other action which could result in data loss (e.g., shortening a character field), the CHGPF command works great. Any logical files which share the record format of the physical file are also updated. However, be forwarned that a logical which does not share the physical file's record format will not be updated --- that includes join logical files. The system actually creates a new physical file in QTEMP, then copies the data in and changes the underlying structure to hook everything back up to the original file. It's very slick.
    0 pointsBadges:
    report
  • TomLiotta
    Minor note... LFs that do not share the format of the PF are allowed by CHGPF. However, the warning is that the field definitions will remain as they were when the LF was created. I.e., if you increase a PF field length from 10 to 15 characters, a LF that explicitly includes that field in its field list will continue to see only 10 characters. For many circumstances, this is a very good thing. You can change the PF and the LFs and all programs compiled over that LF continue to work as always. No level checks -- the programs work as expected. This means that you can run CHGPF at almost any time without affecting your application. The change would only need to be picked up by any new LF and new program that needed to access the added characters. Since LFs shouldn't be sharing formats with PFs anyway, this is how you should expect it all to work. (Why create a LF if it's merely going to present exactly the same format as the PF?) If you explicitly list the LF fields, you can always add fields to the underlying PF without needing to recompile programs based on the LF. Tom
    125,585 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