Custom Business Logic

Custom Business Logic

The MFGImport installation creates stored procedures you can edit to add custom business logic to the import process. They are:

  • wspBOMImportPRE
  • wspBOMImportPOST
  • wspRTImportPRE
  • wspRTImportPOST

Both BOM and Routing Import follow the same general process:

  • Import data from Excel, or an SQL table, into the corresponding import temp table (W7048BOMLoadTemp and W7048RouteLoadTemp)
  • Executes the PRE procedure
  • If an error code is returned t is reported to the user and the import stops
  • Performs data validations
  • If the data validations pass, data is imported into GP tables
  • Executes the POST procedure
  • If an error code is returned it is reported to the user, but the import is already complete

The PRE procedures can be used to perform additional error checking that may be required by your business, or to set default values, or perform other clean-up that is necessary on the raw imported data. For example, the Excel file may contain a Template Item for every row in the spreadsheet even if those items do not need to be created in GP. The PRE procedure could clear the Template Item field if the item already exists in the item master.

The POST procedures can be used to perform additional updates on the data in GP. For example, if the BOM Import is creating new items, you may want to clear certain fields from Item Maintenance that you want users to enter manually.

The PRE and POST procedures can (1) return an error code, and/or (2) add errors to the Error Log table. For the PRE procedures either method will result in stopping the import until the errors are resolved. If you return only an error code it will be added automatically to the Error Log so users can view it. The error code is an integer value above zero.

Adding errors to the error log is done with wspImportErr, as shown below:

There is an example in the PRE and POST procedures for how to use wspImportErr. The Temp Tables contain a LineSeq column which stores the Excel Ron Number. If you wish to report the row number in the error message it can be set using @RowNum. This can also be left as zero.

Debugging can be enabled by adding this switch to the DEX.INI file:

MFGImportDebug=true

When debugging is enabled the import routines will pause before and after the PRE and before and after the POST procedures. This is to allow you to look at the Temp Tables (or other tables in case of the POST procedures) before and after the procedures run to help verify your code is working correctly, and so you can re-run your updates on the raw data until everything is working correctly.