4. Working with Classes : How You Can Create a User Class : Examples of Method: Hire Method : TempEmployee Version
 
Share this page                  
TempEmployee Version
Because all temporary employees have a known termination date and a standard termination reason at the time of hire, the purpose of redefining the method for this user class is to guarantee that these values are inserted into the emp table. After gathering the first of these values and providing the second, this method invokes its parent's method by using the SendSuperclass method.
The TempEmployee invokes this method after setting values for the two critical attributes (TerminationDate and TerminationReason) so that the parent's version of the Hire method runs with real values for these attributes.
The following 4GL code is the entire Hire method script for TempEmployee:
method Hire() =
declare
  errstat = integer not null;
enddeclare
begin
    if CurObject.TerminationDate = '' then
        CurMethod.InfoPopup(messagetext =
        'Temporary employees must have a termination ' +
        date specified.', messagetype = MT_ERROR);
        errstat = -1;
    else
    CurObject.TerminationReason = 'Contract
    period end';.errstat =
            CurMethod.SendSuperclass();
    endif;
    return errstat;
end
Because the TempEmployee subclass requires termination information for a new employee to be added to the database, it sets this information prior to calling its superclass's version of the method.