The difference between the type of variables has to do with their life spans:
Global Valid for the entire session
Component Valid while any page in the component in which it's defined stays active
Local valid for the life of the PeopleCode program in which it's defined
Global variables remain defined and keep their values throughout a PeopleSoft session and can be accessed from different components and applications, including an Application Engine program. A Global variable must be declared, however, in each PeopleCode program where it's used. We recommend that you use Global variables rarely, because they are difficult to maintain. Global variables are not available to a portal or applications on separate databases. They are only available on applications and Portals in the same database.
Component variables provide an intermediate ground between Global and Local scope. They remain defined and keep their values while any page in the component in which they're defined stays active. Like a Global variable, a Component variable must be declared in each PeopleCode program where it's used. Component variables act the same as Global variables when an Application Engine program is called from a page (using CallAppEngine.). Component variables remain defined after a TransferPage, DoModal or DoModalComponent function. However, variables declared as Component do not remain defined after using the Transfer function, whether you're transferring within the same component or not.
Local variables remain in scope for the life of a PeopleCode program.
You should initialize user-defined variables by setting them equal to a constant or a record field before you use them. If you do not initialize them, strings are initialized as null strings, dates and times as nulls, and numbers as zero.
System variables are preceded by a percent (%) symbol whenever they appear in a program. You can use these variables to get the current date and time, information about the user, the current language, the current record, page, or component, and more.
No comments:
Post a Comment