Safepay Integration

Dave DusekRecently, I have been getting a lot of customization requests for Safepay, specifically, adding information into the detail line in the safepay file.  Safepay customizations like that are pretty much all the same thing, no matter what field you want to add, so I figured I would share my integration point and how to handle these types of customizations.  I have done probably 4 or 5 of these in the last couple of months. 

Obviously, the first thing that you want to do is run a script log and script profiler and do some testing, I already did that part, so I won't go through that again here.  If you generate a Safepay file, and you want extra data to show up in the detail line, then basically, you want to trigger on the script ME_Configurator_Get_Field_Output.  This script determines what the field output will be and passes that field data back.  The parameters for the script are:

ME_Configurator_Get_Field_Output Global Procedure

 {ME_Configurator_Get_Field_Output}
in     table       ME_Configurator_Tables_DTL;
in   table       ME_Configurator_Tables_HDR;
in   table       ME_Upload_Transactions;

in   currency        IN_ChecksTotal,
         IN_VoidsTotal,
          INFieldAmount;
in    long        IN_NumberOfChecks,
          IN_NumberOfVoids;
out    string      OUT_field_output;
inout  integer     IOError;
inout   string      ErrorMessage;
inout  boolean     FromConfigurator;

A few things about this global procedure.  First, it is in the Safepay dictionary, so you will need to use Trigger_RegisterProcedureByName() to register a trigger on it.  The trigger would be after original.  Second, you will need to change the out OUT_field_output parameter to inout so you can set it.  Third, you will need to add anonymous to all the table parameters since they don't exist in your dictionary.  When you access these tables, you will need to use the column() function to get the data. 

All the table buffers are positioned. 

The ME_Configurator_Tables_DTL table is the table that holds the detail information of the safepay line being generated. 

The ME_Configurator_Tables_HDR is the header table. 

The ME_Upload_Transactions is the table that holds the transaction information that the safepay line is being generated for. 

Let's assume that the client wants to add an extra field from the cash payment (check) in the Safepay file.  Here is the overall design strategy for this type of customization. 

  1. In the Safepay configurator, create the safepay file as normal.  When you create the detail line, add a field and give it a field name of something that you can recognize later when your trigger runs.  Set the field as a constant and set the number of characters, padding, etc.  This is your extra field.  So right now it is just a constant, but you are going to intercept this later and give it the real data.  Save the configuration file.
     
  2. The idea is that you have a cross dictionary trigger on ME_Configurator_Get_Field_Output, this script runs for every field on every line.  In the trigger processing procedure, you watch for the field name that you set up in step one, or you can watch for the constant.  Both the field name and the constant are in the ME_Configurator_Tables_DTL table, so you use the column() function and watch for your field name.  When you get the field name, then you run your code to retrieve your extra data. 
     
  3. Also, watch the ME_Configurator_Tables_HDR table buffer for when the bank id that you configured comes through.  You would only want this code to run for that bank ID. 
     
  4. The ME_Upload_Transactions table buffer has the transaction information in it.  So from this data, you can go to the CM_Transaction table.  The one thing to watch out for here is that the CM_Transaction table, key 1 does allow duplicates.  So in this case, for each record in the ME_Upload_Transactions table, there could be multiple in the CM_Transaction table, so you have to make sure that the client isn't allowing duplicate checks in payables management. 
     
  5. From the CM_Transaction table, you can get to the PM_Transaction_Open and the PM_Paid_Transaction_History tables.  From there, you could get the apply information if you needed that for anything. 
     
  6. Once you have your data, you set the OUT_field_output parameter and then justify it and fill it.  The justification and fill information is also in the ME_Configurator_Tables_DTL table. 
     
  7. Safepay takes care of the rest and puts your data in the text file that is generated. 

That's really all there is to it.  Most of the customizations are all very similar.  Set up a constant in the configurator and then watch for it to come through in your trigger and change that constant to your data that you want on the safepay file and set the out parameter. 

Dave