EIS Developer Forum

April 4, 2007

Application Packages
Wrapped Neatly in a Bow

Agenda
What are Application Packages and Classes?  Why would I want to use App Packages/Classes?  When would I use App Packages/Classes?  General Structure of an App Class  Exception Handling (try/catch)  App Packages/Classes and App Messaging in 8.48

What are Application Packages/Classes?
It’s just PeopleCode  Application Packages contain Application Classes  You can create your own classes or extend the functionality of the existing PeopleCode classes  A subclass can inherit all the properties and methods of the class it extends.

Why would I want to use Application Packages/Classes?  Provide all the advantages of true object-oriented programming: easier to debug because all the pieces are separate  easier to maintain because functionality is gathered into a single place  extensible by subclass  Provide more structure  Because the Tools team says it’s a good idea!  .

When would I use an Application Package/Classes?  To structure your existing PeopleCode functions to make them easier to debug and maintain. .

When would I use an Application Package/Classes? For example. consider this FUNCLIB record… It’s full of functions. but where do I find the one I want? .

.When would I use an Application Package/Classes? …compared to this Application Class The structure of the Application Package makes it easier to group similar functions.

When would I use an Application Package/Classes? To structure your existing PeopleCode functions to make them easier to debug and maintain.  To extend the functionality of an existing PeopleCode class or a custom class.  .

When would I use an Application Package/Classes? For example. a custom “Person” class could have these properties:  Name  City  State .

end-class.Person class class Person method getBioDemo(&sEMPLID As string) Returns boolean. property string State. . property string City. property string Name.

SQLExec("SELECT NAME_DISPLAY. &sName. &sState). &City = &sCity. CITY. end-method. automatically – don’t mess with these statements! . Local string &sName. Return &bReturn. &sState. &sCity. &Name = &sName.Person class getBioDemo method method getBioDemo /+ &sEMPLID as String +/Created /+ Returns Boolean +/ Local boolean &bReturn. End-If. If All(&sName) Or All(&sCity) Or All(&sState) Then &bReturn = True. Else &bReturn = False. STATE FROM PS_PERSONAL_DATA where EMPLID = :1". &State = &sState. &sCity. &sEMPLID.

.City | ".Name | " lives in " | &personBioDemo. " | &personBioDemo. Local GBUT_PEOPLE:Person &personBioDemo. 0. "". 0. End-If. If &personBioDemo. Else MessageBox(0.PeopleCode using Person class import GBUT_PEOPLE:Person. &personBioDemo = create GBUT_PEOPLE:Person().State). 0. &personBioDemo.EMPLID.Value. "". "No Bio Demo Data Found").getBioDemo(&sEMPLID) Then MessageBox(0. 0. &sEMPLID = GBUT_TEST_WRK.

 By making Employee a subclass of Person.  . the Employee class has access to the properties/methods of Person as well as any additional properties/methods defined for Employee.Employee subclass extends Person class An Employee would have the same properties as a Person along with additional attributes like Job Title.

property string JobTitle. . end-class.Employee subclass class Employee extends GBUT_PEOPLE:Person method getJobData(&sEMPLID As string) Returns boolean.

empl_rcd = a_ed. &sEMPLID. &sJobTitle). Else &bReturn = False. Return &bReturn.getBioDemo(&sEMPLID) Then Created automatically – don’t mess with these statements! This method is in class “Person” SQLExec("Select b.Employee subclass getJobData method method getJobData /+ &sEMPLID as String +/ /+ Returns Boolean +/ Local boolean &bReturn.jobcode = a. PS_JOBCODE_TBL b where a. If %This. If All(&sJobTitle) Then &JobTitle = &sJobTitle. .empl_rcd) and b.effdt = (select max(a_ed.effdt) from ps_job a_ed where a.DESCR from PS_JOB a. &bReturn = True. End-If. End-If. end-method.emplid and a.jobcode".EMPLID = :1 and a.emplid = a_ed. Else &bReturn = False.

Value.EMPLID. Local GBUT_PEOPLE:Employee &employeeData.PeopleCode using Employee subclass import GBUT_PEOPLE:Employee. If &employeeData. "". .JobTitle | ". " | &employeeData. "Either no BioDemo data or no job title found"). &employeeData.State). &employeeData = create GBUT_PEOPLE:Employee().City | ". 0. 0. Else MessageBox(0. End-If. "".Name | ".getJobData(&sEMPLID) Then MessageBox(0. &sEMPLID = GBUT_TEST_WRK. " | &employeeData. lives in " | &employeeData. 0. 0.

General Structure of an Application Class         Class name Class extensions Declaration of public external interface Declaration of private instance variables and methods Declaration of protected instance variables and methods Definition of methods Constructors External function declarations .

the package that contains that package and so on.Class name A fully qualified name that is formed hierarchically by the name of the toplevel package that contains them. property string JobTitle. end-class. .  Must be unique within the App package.  class Employee extends GBUT_PEOPLE:Person method getJobData(&sEMPLID As string) Returns boolean.

Class name Example Application Packages Application Classes Class names CRM:Address CRM:Customer CRM:Utilities:Address CRM:Utilities:Incident .

 Before you can extend a class. class Employee extends GBUT_PEOPLE:Person method getJobData(&sEMPLID As string) Returns boolean. end-class. property string JobTitle. .  import GBUT_PEOPLE:Person. you must import it.Class extension Represents the “is a” relationship.  Inherits all the public methods and properties of the class it extends.

Declaration of public external interface  Specifies the methods and properties that the class provides to other PeopleCode programs. class Employee extends GBUT_PEOPLE:Person method getJobData(&sEMPLID As string) Returns boolean. end-class. property string JobTitle. .

and private class constants. instance variable.  .  Private methods or instance variables cannot be overridden by subclasses because they are completely private to the declaring class.Declaration of private instance variables and methods The private part of a class declaration gives the declaration of any private methods.

method isValid() Returns boolean. property string Subject. property string BC. &sTitle As string). &nMsgNum As number. … property string TU. Public property string CC. method send() Returns boolean. outside class Emailer. … private method getUserEMail(&sOPRID As string) Returns string. property string Body. method errorThrower(&nMsgSetNum As number.Declaration of private instance variables and methods class Emailer method Emailer(&bDebug As boolean). P r i v a t e . method addAttachment(&sFile As string. method getRoleEMail(&sROLENAME As string) Returns string. … available to programs end-class. These methods are not instance string &currentMethod. &aSubstitution As array of string). instance boolean &bInError.

 .  Can be accessed only by objects of this application class and those derived from this application class.  Use protected methods and properties when you want to hide them from outside use.Declaration of protected instance variables and methods Fall between public and private. but allow the flexibility of using them in derived classes.

Public property string Q. . property string P. P r o t e c t e d method MP() is available only to class A and its subclasses (like Class b). property string X.Declaration of private instance variables and methods class A. method B(). Class b extends A. end-class. protected method MP() Returns string. method A(). end-class.

Definition of methods  Come after the definition of any global or component variables and external functions needed by the method Passing parameters    By value method increment (&val as number. . &text as string). &text as string). By reference method increment (&val as number out.

Constructors    A constructor is a public method with the same name as the class. &employeeData = create GBUT_PEOPLE:Employee(). . A class that does not extend some other class does not need any constructor. The function takes the name of the class and any parameters needed for the constructor method. Instantiate new objects of an app class by using the Create function.

 Allowed in application classes In the global and component variable declarations  After the class declaration (after the end-class statement)  Before the method definitions  .External function declarations  Declare Function xyz PeopleCode FUNCLIB_MISC.MISC_FUNCTIONS FieldFormula.

Other AppClass Concepts that we aren’t going into today…  Abstract Methods and Properties  Interfaces  Using Methods and Properties for Collections  Downcasting  … Please refer to PeopleBooks 8. .48 > PeopleCode API reference > Application Classes for more information.

referencing a method or property that doesn't exist. For example. You can handle errors in PeopleCode using the catch statement. or trying to use a method or property on a null object are all exceptions that should be handled. The places in your code where you want exceptions handled must be enclosed by the try and end-try statements. . Exception handling is the processing you initiate when an exception occurs.Exception Handling    An exception can be defined as any unusual event that requires special handling in your PeopleCode program. dividing by zero.

Exception Handling  The process of exception handling can be broken down as follows: An error occurs (either a hardware or software error).  .  Your exception handler provides the response.  The error is detected and an exception is thrown (either by the system or by your program).

Name | ".TableName | ". %This.Result = "Error"." | %This.currentMethod | " Error during doAlter"). 13. end-try. End-If." | %This. "A". &fLogFile. ". Return False. &fLogFile.currentMethod." | %This.Close(). catch Exception &cl %This.")).Exception Handling try SQLExec(&sCurrentDDL). Split(%This.errorThrower(20101. If &bInDebug Then &fLogFile = GetFile(&sLogFileName.WriteLine(%Datetime | " | " | %This. .Name | ". %FilePath_Absolute).

such as the DoModal.  Catches are only caught for exceptions thrown within the current component.Exception Handling An exception to exception handling:  Using functions that transfer the end user to a new component. or Transfer functions (in some cases) inside a try block do not catch PeopleCode exceptions thrown in the new component. . DoModalComponent.

but…  Message channels become Queues  New objects: Services and Service Operations  Node Transactions (Routing tab in 8.AppClasses and the LS 8.21) become Routings  Message Subscriptions become Application Classes and Service Operation Handlers  .9 Upgrade  Application Messaging changes in the 8.48 version of PeopleTools A Node is still a Node and a Message is still a Message.

9 Upgrade .AppClasses and the LS 8.

AppClasses and the LS 8.9 Upgrade .

April 5) 9:00 am – 12:00 pm 1:00 pm – 4:00 pm RP .EIS Training Room 1 . sign up for one of the workshops to be held tomorrow (Thursday.Workshops on Friday For more information on this topic.

The End .

7730.6503.1 5:..6: 191964.45191 03.::: ..:56./3:.50.:6 ..61:.49646.61 .57/30.51 79679.0.33/. 3/3.03.514..::.7730.6503.9.:.336..656796. .9.:1: /.5179.0.14...:: :796.00::1653/6/0.61: .6:5.5/.51.5.:.

9..61  #/30 79679.:: 4.95# 51.5:.61 # %.65679.9.95 79679.0.:..03.50 .:.514.61: 03./3:..95::.95$ 796.1 4.

::/.03.:.:: 3.61  79679.51: 4.95 51.

::/ .  0 .03.603.51.::.  1 4.:: # 9 6 .61 # :../3653 .::: 323.::/03.3.

51 .6564.::57.5.3690647655.5 36/../3:.6150945.6150945.15. .95  9950 4.:54/9  ..3.3 4.::.350.61 #.9.9: .95  .3. 4.4.9.656.9..95. ..::.  .:54/96..61: 64..65:511/.

90.03. :..7/304.9.9.69 5:. 50.90..69 4.51.'.5.69: 065:..16:56.5 7.:6.065:.:.9 03.5.45.61 4736..4.9:51169..65:.09.46.65 '50.65 ..5..56/0.4..::/ :5.90.61.51:646.7703.#"#4736  .::.69:..::16:56..51.::.:: 03.2:.03..5065:.90..

.510647655.6503. 33615.9./3 103.9.95.65 ..9.36/.!'"!&316943.950..03.65#67361 !..9.3.65: 03.::: 5.350. & &.9....7730.65103.65: . 51.9.::103.

4.03.45.. 69..:::.65: .6115.

 .".9773.61:.51#9679.::: 69469 5694.: 5..65: 650.51#9679.9.61..95.5  #3..653.9.0: :5 .655.61:.:99.: .6.::6507.:.:69 6330..65 . /:.0.6#673662:   #67361#9950  7730..

65.5/151.5.473 115/96 99505...0.4.5336/0.5135:.0:56906196.656009: 60..5135569#67361 7969.65.07..:. 5..616979679..9 .16:5 . 4.33 07. 69.07.45.5.9.5131  07.507.. ' 73.35.51314:.650.5151.95..4 69.7960::565. .65: .5135 507...65.3.989::70..0 :.:631/.616979679...6 :.65:.5139969: 5#67361:5.:..55:./5036:1/.

.9 :...:  .45.

99969 '9969:1.0.65.91.5//9625165.::.:6336: 599696009: .5135 0.965 .507.07.9/..9..65.4 6907.65.51.65: . 9:765: .5135 '7960::607.1.969 :6.469/69 7969.51397961:.

4=  = ': 0995.3 :63!.9969 ': 9969'969   &73..9 &$0 :995.9  63 36:  51. .4=== ': !. ...07..  63 9.007.4=   /5/'5 63..4  3#.61 = ': './3!.  0.65 03 ': %:3.61=9969195 163. ': !.5135 .5 .65.4= = ': 0995./:63.

95.3: 51. %.

.9 .

5.: . 0647655.69 07.::  5:1.65:.6.5:9.0..3 6 61.6 61.9655..9..96530..0 #6736107..607.0995.65.65.65:.50647655.65.5:950.5135 :550.5135 507. :0.65: 5:640.3647655.9/36021656. 69 '9.07.51 :9.65:. 50647655...  .965.0:.  .

51&90 "79. ::.5139: .51.65:/064 7730. & 79.51.50..:::..1 7730.65: %6..51&90 "79.65: !61'9.5:.: :.33..:::.65 ::./5   /064%6.&/:097.0.5:5. ::.  9:656#673'663: !61::.553:/064$: !6/0.65.!61.5: ::..:&90:.0. /.5.653.773.33. ::.

1 .:::.51. & 79.773.

1 .51. & 79.:::.773.

33#442 . 83:5147430 419047845894-00/9424774 %:78/.2  52  52  52 #! $%7.  57  . 47247031472.692:67:6591.9434398945.

%0 3/ .

Sign up to vote on this title
UsefulNot useful