Sequence Generation
If a substitution is followed by a NFA(GEN_NEW_SEQUENCE) this means that one can generate a unique number (only whole numbers are used) to act as a substitute to the order number.
Case: Substitution of fields with content.
Status: ACTIVE
SUBSTITUTION=(#4,ORDNO.#3), KEYS((#3,ORDNO.#1),(#4,ORDNO.#2)), NFA(GEN_NEW_SEQNUM)
Field #3 is Item String (char)
Field #4 is order number (Long)
these are used to generate unique order numbers.
If the file ORDNO is empty it will work.
There can be no empty lines in the ORDNO file.
If the file ORDNO contains orders such as:
INSIDE;1;1;
INSIDE;2;7;
PEN/GOLD;1;5;
It will look like:
INSIDE;1;1;
INSIDE;2;7;
PEN/GOLD;1;5;
TOP/GOLD;900003;8; <<
BOTTOM/GREY;900005;9;
Case: Creation
When a Record finds a SUBSTITUTION Token, it will call up the static Substitution::ReadSubstitution function for this Record.
Parsed keys will result in the creation of a new FileDefColl by calling the FileDef for the file. FileDef::CreateColl is parsed as a BaseFileData pointer for the correct/expected type). In addition information about the index number (the position of the column), the FileDef::CreateColl will return a pointer to the newly created FileDefColl. It is then stored in a new vector arKeys.
A new Substitution (,y, ? ) is then created.
The Substitution now contains all it needs.
Case: Read
When a Record has conducted a Read / FetchData it will call for the record substitutions one by one.
Each substitution will prompt the primary record for a value and perform a hash calculation. The hash calculation is used to access the primary Key Map for the primary Keys relevant indexes. They are accessed one at the time and the primary key is matched to the primary Record Entry. The primary record entrys BaseFileData performs this and comparisons/matches are conducted polymorphically. If a match is found the substitution prompt the next keys/FileDefColl for the entry with the same index and the record entry will perform the matching, etc.
If a match is found for the substitution, then it will extract the substitution value from the FileDefColl and call on the BaseFileData to substitute/update this value.
Case: Read with NFA Skip
If a match is not found, then the substitution will not do anything.
Case: Read with NFA Sequence Generation
If a match is not found, then the substitution will react by generating a new sequence number.
The Substitution will also ask the FileDef to add a new line, by appending a new entry to each FileDefColl it has, default is a dummy holding a string. It will then generate the new sequence entry / number by asking the FileDefColl.
FileDefColl will prompt the BaseFileData to create a new DataEntry of the correct type. This is placed in the last entry of the FileDefColl, (the one just added by FileDef.)
Substitution will also ask each of the keys (for example, FileDefColl) to replace the last added index.
Case: Write
The Record is called to perform the write data method.
The Record will have each BaseDataFile retrieve the data from the global data in Infor M3 SWB. This data is stored in the associated Data Entry.
The substitution is run. If a substitution is found, then this will replace the record Entry with the replacement value. This is done by locating the primary key from prime Key Map, searching for a match on the primary key and checking all other keys for match. This process continues until a match is found or until there are no additional prime Keys with a hash key.
Case: Write with NFA Skip
Entries not found are ignored.
Case: Write with NFA Sequence Generation
Should always find a substitution.