FreedomSoft - "the future is freedom"
Process Before - Derive

The following code is an example of deriving data, within Process Before Code. Usually this is only necessary where that data could not be derived using Freedombase Derivation calculations.

Please note that the Process will still apply all Derivation calculations before the data is written to file, allowing us to mix and match the two methods of deriving data (Freedombase Derivation calculations and custom code), and enables us to use the most efficient and effective methods for our particular circumstances.

The code is:

    SUBROUTINE MAILBOX_JOB_Before(Command,RawData,Instance,Instance_Key,ErrorMessage,Occurrence,DatabaseeClassList,KeyList,InstanceList,ErrorMessageList,SequenceList,NoUpdateFlagList,CurrentSelect,CascadeRecurse,Cascade_Cascade_KeyList,Cascade_CascadeToKeyList,PreviousDatabaseeClassList,PreviousKeyList,PreviousDateTimeWrittenList,PreviousNoUpdateFlagList,User,MetaErrorFlag)

$INCLUDE FB_BP Freedombase_Definition
$INCLUDE Process_BP MAILBOX_JOB_Definition

     IF Command = 'Save' AND Instance NE '' THEN
        IF (Instance<MAILBOX_JOB_PAID>) AND Instance<MAILBOX_JOB_PAID> NE Freedombase_BlankAttribute_String THEN
           StartDate = Instance<MAILBOX_JOB_PAID>
           GOSUB GetPeriod
           Instance<MAILBOX_JOB_PERIOD> = Period
        END
     END

     RETURN

GetPeriod:

     IF NOT(StartDate) THEN
        StartDate = DATE()
     END

     StartDate = OCONV(StartDate,'D4')
     Period = FIELD(StartDate,' ',3)

     LOCATE FIELD(StartDate,' ',2) IN 'JAN':@AM:'FEB':@AM:'MAR':@AM:'APR':@AM:'MAY':@AM:'JUN':@AM:'JUL':@AM:'AUG':@AM:'SEP':@AM:'OCT':@AM:'NOV':@AM:'DEC' SETTING Position THEN
        Position = Position / 3
        IF Position NE INT(Position) THEN
           Position = INT(Position) + 1
        END
        Period := Position
     END

     RETURN

  END

previousnext
123456789101112131415161718192021222324252627