Keeping in mind that you said a "data" library.  Also keep in mind that 
you are going to access a file that is in that library to validate the 
company number.
CHKOBJ on the object itself is one method.  If you prompt it, move your 
cursor to the title line and press F1 you can see what messages you can 
monitor for.  Anything from library doesn't exist to file doesn't exist, 
etc.  I'd check for the end file you are looking for.
Another method is to open the desired file manually
FDataFile IF     E   disk                  USROPN EXTFILE(TheName)
D TheName                s            21a   varying
 /free
  TheName=%trimr(library + '/' + File);  // library came from prompt 
screen
  monitor;
  Open DataFile;
  on-error xxxxx;  // replace xxxxx with the error code for library 
doesn't exist
    // see file/exception handling in the rpg reference and/or program 
guide
  EndMon;
...
Another method
 /free
  x=0;
  execsql select count(*) into :x
    from qsys2/syscolumns
    where system_column_name=:fieldName 
      and system_table_name=:FileName
      and system_schema_name=:Library;
  If x=0;
    // column :fieldName from table :FileName is not in library :Library
  EndIf;
Rob Berendt
As an Amazon Associate we earn from qualifying purchases.
	
 
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.