Instance Variables in the Application Packages

Instance Variables in the Application Packages in Peoplesoft

One thing that I found odd with Application Class’ new syntax is the introduction of the instance keyword. The instance keyword acts like a variable scope modifier:

   instance string &my_instance;

Actually, all instance variables are private. Instead of simply having a private variable, we need to declare private instance variables! I was confused by this at first.

The uglier part is that instance variables are not recognized as variables by some key built-in functions, such as All(), None() and SQLExec(). SQLExec() accepts instance variables for input bind parameters, but not as output bind parameters. This is an inconvenience but not totally unusable. As a workaround for using SQLExec in your application classes, output bind values are received by local variables first, then moved to the instance variables.

For example, to achieve the following:

 
class test
   method a();
private
   instance date &maxdate;
end-class;
 
method a
  SQLExec("Select Max(effdt) from PS_TABLE", &maxdate);
end-method

The above code will result in an error when SQLExec is executed. Method a needs to be adjusted:

method a
  Local date &out;
  SQLExec("Select Max(effdt) from PS_TABLE", &out);
  &maxdate = &out;
end-method;

Another disadvantage I see now is error reporting in using application classes. Runtime errors are not specific enough. Error messages identify which class in a heirarchy has the error but not the location of the error. For a class with many methods, this could be difficult to debug.

Application classes is a powerful tool for creating clean, scalable and reusable application logic for PeopleSoft pages, but at its current state a little improvement would be useful.

The observation illustrated above was made against PeopleTools 8.44

Update:Application class error messages displayed the method where error was detected. Looks like it just needs a little getting used to.
It turns out PeopleBooks has documented the limitation that properties has on functions. It states that a property couldn’t be output argument of a function. An instance variable is treated as a property.

Source :- http://xtrahot.chili-mango.net/

 

 

0 comments: