310 pts.
 what is field reference file
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

Software/Hardware used:
ASKED: August 9, 2008  7:42 AM
UPDATED: May 29, 2012  10:50 AM

Answer Wiki:
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.
Last Wiki Answer Submitted:  August 11, 2008  8:39 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:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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 pts.

 

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,830 pts.

 

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 pts.

 

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?

 1,975 pts.