Preprocess scripts are VB script or .cs files integrated with the import services which imports everything to the Brokerage system as well as , adding / updating records from or into the same table.
These scripts are kept under the SETUP > Local (Implementation) Scripts > PREPROCESS folder.
There will be separate preprocess script file for each product types. Because for each product types, the trade data would be processed differently.
How preprocess script works?
When trades are getting processed, the import service invokes the preprocess script file include in the location SCHEDULER > select scheduler from the dropdown (SERVICE_CLNT1_1) > check SHOW ALL > select THE CONTROL SCRIPT > click EDIT > click PREPROCESS button.
Preprocess scripts have below properties:
Incols – details of each columns with the header taken from the input file that used to import.
Outcols – Standard names of the related columns in the table
FldInfo – Description of each column.
While a trade file from the bank imported to the brokerage system, there are other files like HMS BOOK, TRADER MAPPING, COUNTERPARTY files along with the trade file available in each cobdate folder. These files keep the master data for those references there in the trade files.
As you we can see in the below image, each COBDATE folder hold these files.
When import service executes for a particular COBDATE, each trade entries will read from the trade file and keep it in a temporary file in the temporary folder. This data will be available in the preprocess script. Then we loop through each trade entries from the temporary file and read data from BOOK MAPPING, COUNTERPARTY and TRADE MAPPING files corresponding to the reference values available in the trade entries.
When will we use preprocess script?
In case of any logic need to apply on a trade data before further processing, we can do it in the preprocess script.
How to save value to a new field using preprocess script?
If we want to add a new column in the trades table and to insert a calculated value to that column, we must add this new column in the preprocess script’s incols and outcols properties. The value can then be assigned to the properties and will get saved to the database.
The fields we added in the preprocessor script needs to reflect in the scheduler as below example:
1. Here we have added a new field RATE_BAND_DURATION in the preprocess incols and outcols properties.
2. Now go to the SCHEDULER, select the schedule, select the service, and open the service by click Edit. You will be able to see below screen
3. Then click on the PREPROCESS button and you will be able to see a code window which either have a include statement or a code block.
4. Now click OK. This will reload the preprocess script and the newly added field, and its description will reflect in the mapping section as below.
5. Next step is to map the field we specified in the preprocess script and the actual field in the table i.e., in the left-hand side displaying the standard names of fields in the table. Drag and drop the field from the right-side list to the table fields on the left side. This will do the mapping.
6. Do the calculation in the preprocess script and set the value to the index of the field in the array.
After completing the preprocess, the VB tree will execute for further processing.
Comments
0 comments
Please sign in to leave a comment.