The following code is an example of modifying the data being returned, so that data not actually held on file, or that is held but in a different format, can be returned as though it is held on file.
Please note that this method is particularly useful when business rules change after data has been written to file, and you do not want to create or run a conversion program over the existing data. This method allows you to convert the data into the new format as and when the older data is needed. Consider, however, that a one off conversion program may be more efficient.
This method can also be used to modify the data depending on the user, for example if one user needed data in one format, and another user needed data in a different format, the Process After Code could check what format this user required, and could modify the data accordingly.
Sample code is:
SUBROUTINE Freedombase_Code_After(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
IF FIELD(Command,' ',1) NE 'Delete' AND (Instance<Code_File>) THEN
GOSUB GetCode
END
RETURN
GetCode:
Code = ''
OPENSEQ Instance<Code_Location>,Instance<Code_File> TO CodeFile ELSE
RETURN
END
LOOP
READSEQ Line FROM CodeFile ELSE
EXIT
END
Code := Line:@AM
REPEAT
CLOSESEQ CodeFile
Instance<Code_Code> = Code
* If there has been an update error, then Freedombase will not get this
* Instance from file before outputting it. Instead, if there has been an update error,
* Freedombase will use the Instance in memory, ie the Instance in InstanceList.
* So we will update the Instance in InstanceList if there has been an error.
IF (ErrorMessage) OR (ErrorMessageList) THEN
DatabaseeClass = 'Freedombase':Delimiter_Name:'Code'
LOCATE DatabaseeClass IN DatabaseeClassList SETTING DatabaseeClassPosition THEN
LOCATE Instance<Code_File> IN KeyList<DatabaseeClassPosition> SETTING KeyPosition THEN
InstanceList<DatabaseeClassPosition,KeyPosition> = LOWER(LOWER(Instance))
END
END
END
RETURN
END
| previous | next |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |

