getSchema
getSchema(): Schema;
The getSchema method of the Application class returns a reference to the
When working with imported packages, the getSchema method and the
Compare the output from the code fragments from a non-imported method and from an imported package method.
// In a non-imported method write "schema=" & app.getSchema.name; // outputs "ImportingSchema" write "schema=" & currentSchema.name; // outputs "ImportingSchema"
// In an imported method write "schema=" & app.getSchema.name; // outputs "ImportingSchema" write "schema=" & currentSchema.name; // outputs "PackageSchema"
An exception is raised if the receiver of the getSchema method is not the application object of the schema context in which the code is executing. The application object changes as the process switches from one schema to another as a result of a call into a package.
The following method attempts to list all applications for a process. An exception is raised when the getSchema method is called and the appObj receiver references an application object other than that referenced by the app system variable.
listApplications(); vars appArray : ApplicationArray; appObj : Application; begin create appArray transient; process.getAllApps(appArray); // appArray contains the standard app object // and app objects for any imported packages foreach appObj in appArray do write "application=" & appObj.name; // next instruction raises an exception if appObj is not app write "schema=" & appObj.getSchema.name; write "schema=" & appObj.class.schema.name; endforeach; epilog delete appArray; end;
The exception can be avoided by not calling the getSchema method. Replace the call to appObj.getSchema.name with appObj.class.schema.name.