Redefine the Ancestor's Methods

To extend the functionality of the date display reusable part #EOEXAM04, modify the ancestor's methods in the inheriting reusable part. You do this by using a method routine with *REDEFINE option.

The ancestor date display reusable part #EOEXAM04 contains a method routine ValidateDate which validates the dates. Suppose you want to extend the date validation to ensure that the day is a week day.

To see how this works add a method routine to the inheriting reusable part #EOEXAM05 which overrides ValidateDate method in the ancestor:

 

MTHROUTINE name(ValidateDate) options(*REDEFINE)

ENDROUTINE

Make the redefined validation routine check whether the date is a weekday and show the day of the week. You can copy this code from the Source for Inheriting Date Display Reusable Part below.

Compile and execute your reusable part.

Source for Inheriting Date Display Reusable Part

FUNCTION options(*DIRECT)

BEGIN_COM role(*EXTENDS #EOEXAM04) HEIGHT(29) WIDTH(492)

* Override ancestor date validation add additional rules

* to ensure that the date is not just a valid date but

* also a valid day of the week .....

MTHROUTINE name(ValidateDate) options(*REDEFINE)

DEFINE field(#RETCODE) type(*CHAR) length(1) desc('Return Code')

DEF_COND name(*NOTOKAY) cond('#RetCode *ne Y')

DEFINE field(#CVTDATE) type(*CHAR) length(20)

* Do standard ancestor validaton

INVOKE method(#Com_Ancestor.ValidateDate)

* If a date exists and it is valid so far, check that it is a week day

IF cond('(#Showdate.Value *ne *Blanks) and (#Com_Owner.uInError = False)')

CHANGE field(#CVTDATE) to(*NULL)

CHANGE field(#DATEC) to('#SHOWDATE.VALUE')

USE builtin(CONVERTDATE) with_args(#DATEC F R) to_get(#CVTDATE #RETCODE)

CASE of_field(#CVTDATE)

WHEN value_is('= Mon' '= Tue' '= Wed' '= Thu' '= Fri')

USE builtin(CONVERTDATE) with_args(#DATEC F S) to_get(#CVTDATE #RETCODE)

USE builtin(TCONCAT) with_args(#SHOWTEXT.CAPTION ' (' #CVTDATE ')') to_get(#STD_TEXTL)

OTHERWISE

SET com(#Com_Owner) UINERROR(TRUE)

USE builtin(TCONCAT) with_args(#SHOWTEXT.CAPTION ' (Not a week day!)') to_get(#STD_TEXTL)

ENDCASE

SET com(#ShowText) CAPTION(#Std_Textl)

ENDIF

ENDROUTINE

END_COM