what is field reference file

310 pts.
Tags:
Field Reference File
RPG
RPGILE
hi, all i m working on RPGILE ,please tell me what is field reference file , what is use of it, please give any example.. thanks Ambrish
ASKED: August 9, 2008  7:42 AM
UPDATED: May 29, 2012  10:50 AM

Answer Wiki

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

Hi,

A field reference file is a physical file which is used for defining most of your commonly used fields. Then when you need to create / modify a physical file you can use the definitions from the field reference file by using the REF(reference file) and REFFLD (reference field) keywords. If you then need to change a field definition globally, you can change it in the field reference file and recompile everything that uses that field.

Example :

<b>Field Reference File</b>
REFNUM 9S0 COLHDG(‘Reference’ ‘number’)
TEXT 20A COLHDG(‘Text’ ‘Field’)

<b>Your Physical File</b>
INVNUM R REFFLD(REFNUM)
COLHDG(‘Invoice’ ‘Number’)
INVTXT R REFFLD(TEXT)
COLHDG(‘Invoice’ ‘Text’)

If you change the length of your reference number in the field reference file, then recompile the field reference file and the physical file, then the length will change in the physical file. This seems like a lot of work for 1 file, but if you have lots of files which use the same field reference it makes it very easy to make changes to many files and programs.

Regards,

Martin Gilbert.

Discuss This Question: 4  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
  • Mohan K
    Hi Gilly, i have one question which regards to your above explination. For example i have created 1 physical file FILEA with 10 fields in that PF by referencing each field from field reference file(FLDREFFILE). if i have populated the 10000 records of data to the file FILEA from production. after moving the file to production later on if i receive a request from client saying that FIELDA length needs to be changed from 10 character to 30 character in FILEA. in this case i can not change the field FIELDA length in FILEA, since i am referencing this field from REFFILE. if i want to change the field length from 10 character to 30 character in FILEA with out compiling the FILEA and with out losing the data in FILEA what should i have to do. Please suggest me. Thanks Mohan K.
    695 pointsBadges:
    report
  • Teandy
    I don't think you can change a field length in a file without recompiling it and the programs that use it. Even if you can, I think it would be extremely foolish, not to mention dangerous, to do so. Here is what I would do: First make a back up of the original file. CPYF FROMFILE(MYLIB/FILEA) TOFILE(MYLIB/FILEABAK) MBROPT(*REPLACE) CRTFILE(*YES) Second, change the dds for FEILDA from 10 to 30 and recompile the file. Third, copy the data from the back up back to the original file. CPYF FROMFILE(MYLIB/FILEABAK) TOFILE(MYLIB/FILEA) MBROPT(*REPLACE) FMTOPT( *NOCHK) Fourth, recompile the programs that use the file.
    5,860 pointsBadges:
    report
  • graybeard52
    To change the length of a field that has DDS defined, just fix the DDS and run CHGPF. You will then need to recompile any RPG programs that use the file, since you have now changed the file level. If you use CRTPF you will lose all you data, so use CHGPF instead.
    3,115 pointsBadges:
    report
  • RamvishakRamesh
    I have a query, I have a field reference file with say 10 fields and I have some files which refer to this field reference file, Is it possible to delete the field reference file now?
    2,410 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