BatchReviseOnTransactionCommit

Batch - Revise On Transaction Commitment

Major Business Rule

Object Name: B0000007

Parent DLL: CALLBSFN

Location: Client/Server

Language: C

Functional Description

Purpose

This function is used to update a batch with amounts and documents.


Setup Notes and Prerequisites

This function is normally called from ER on the Ok Button Is Clicked event, however it can be called 

anytime from ER or another function.  This function should be called each time a transaction or 

document is created or changed.  This function requires a valid Override Mode to be passed (A-Add, C-Change, 

D-Delete, V-Void), if not an error will be set.  For transaction processing that is very repetitive, 

such as updates performed by a UBE, you may wish to call this function once instead of many times for 

performance reasons.  If so, you may pass the total number of documents in the batch in the function's 

parameter.  Continue to pass the total Batch Amount in the appropriate function parameter.  This will 

cause the same net result of calling this function individually for each document.  Normally, you 

will use this function merely to update the batch.  You should close the batch using the B0000008 

function.  You may however close the batch using this function by passing a "1" in the Form Is Exited On Add 

Flag, if necessary.  If you are closing the batch using this function and not the B0000008 function 

then this function will send a PPAT message if Batch Control is allowed and the Batch is Out Of Balance. 

 It will also go through the same checks to close a batch as the B0000008 function.  Don't forget 

that System Constants are determined by Batch Type, if you are using a Batch Type that the function 

cannot determine System Constants for, the G/L System Constants will be defaulted.  Refer to the 

documentation for B0000008 - Batch Revise On Exit function to understand closing a Batch.


Special Logic

If adding to a batch, you will use an "A" in the Override Mode and populate the Transaction Amount 

with the amount you want added to the batch.


If changing a batch you will use a "C" in the Override Mode, populate the Transaction Amount Previous 

with the amount you want subtracted from the batch and populate Transaction Amount with the amount 

you want added to the batch.


If deleting a document from a batch you will use a "D" in the Override Mode, populate the Transaction 

Amount Previous with the amount you want subtracted from the batch.


If voiding a document within a batch you will use a "V" in the Override Mode, populate Transaction 

Amount with the amount you want added to the batch.


If you are doing heavy UBE-like processing and do not want to call the function for each transaction 

you may use the Total Number Of Documents parameter.  This will allow you to total the Batch Documents 

and Amounts yourself and call the function once.  Use the Transaction Amount and Transaction Amount 

Previous parameters as you normally would and then pass the Batch Documents total in the Total Number 

Of Documents parameter.  (i.e. For performance reasons, a 10,000 document batch can call this function 

once rather than 10,000 times)


The following logic is executed only if you are closing the batch will calling this function (Passing 

a "1" in the Form Is Exited On Add parameter):


If the Batch Documents total is "0" (the batch is empty) when the batch is closed, the batch will 

automatically be deleted.  If you need to force an empty batch, close the batch using B0000008 and use 

the Suppress Delete flag.


Batch Control can be overridden by passing a "1" in the Suppress Batch Control parameter.  You should 

only use this if you are positive you never want to see Batch Control (i.e. Calling this BSFN from a 

UBE).


A PPAT message will be sent if Batch Control is allowed and the Batch is Out Of Balance.


If you wish to force the Batch Status or reset the Batch Status when the batch is closed, pass the 

desired Batch Status in the Previous Batch Status and set the Batch Status Flag parameter to "1".  If 

you want to set the Batch to "Error" then pass a "2" in the Batch Status Flag parameter, the Batch will 

be set to "E".  If anything else is passed in the Batch Status Flag parameter, the System Constants 

will determine the Batch Status.


If the batch is in balance for both Batch Amounts Expected and Entered and Batch Documents Expected 
and Entered, the the function will set the corresponding flag to a "Y", else it will set it an "N".


If your transaction is in balance, set the Transaction In Balance Flag to a "Y" or a "1".  This will 

set the corresponding batch flag to a "Y" else, it will set to an "N".



Technical Specification


Main BSFN:

If Override Mode is not "A" or "C" or "D" or "V"

   Set Error

Open F0011 table

Fetch Batch from F0011 table

Retrieve Batch Control/Management Approval Constants

If Override Mode is "A" or "V"

   Add Transaction Amount to Batch Amount

If Override Mode is "C"

   Subtract Transaction Amount Previous from Batch Amount

   Add Transaction Amount to Batch Amount

If Override Mode is "D"

   Subtract Transaction Amount Previous from Batch Amount

If Total Number Of Documents is not "0"

   If Override Mode is "A"

      Add Total Number Of Documents to Batch Documents

   If Override Mode is "D"

      Subtract Total Number Of Documents from Batch Documents

Else

   If Override Mode is "A" or "V"

      Add 1 to Batch Documents

   If Override Mode is "D"

      Subtract 1 from Batch Documents

If Form Is Exited On Add Flag is "1"

   If Batch Documents is "0"

      Delete Batch from F0011 table

      End BSFN

   If Batch Control is "ON" and Suppress Batch Control is not "1"

      If Batch is Out Of Balance (Amounts or Documents are not equal)

         Send PPAT Message

   If Batch Status Flag is "1"

      Set Batch Status to Previous Batch Status

   If Batch Status Flag is "2"

      Set Batch Status to "E" (Batch is In Error)

   If Batch Status Flag is not "1" or "2"

      If Management Approval is "ON"

         Set Batch Status to " " (Batch is Pending)

      Else

         Set Batch Status to "A" (Batch is Approved)

   If Batch Documents Entered and Expected are equal

      Set Balanced Documents and Amounts Flag to "Y"

   Else

      Set Balanced Documents and Amounts Flag to "N"

   If Transaction Is In Balance Flag is "Y" or "1"

      Set Balanced Transaction Flag to "Y"

   Else

      Set Balanced Transaction Flag to "N"

Else

   Set Batch Status to "U" (Batch is "In Use")

Update Batch F0011 table

Close F0011 table


Retrieve M & D Constants:

Open F41001 table

Fetch M & D Constant based on Batch Type

Close F41001 table

Data Structure

D0000007 - Batch - Revise On Transaction Commitment


Parameter NameData ItemData TypeReq/OptI/O/Both
mnBatchNumberICUMATH_NUMERICNONENONE

Special Input Expected
Pass the Batch Number of the batch you want to update.

szBatchTypeICUTcharNONENONE



^

mnTransactionAmountAMEMATH_NUMERICNONENONE

Special Input Expected
This parameter is to specify what amount should be added to the batch.  Use this parameter when 

adding to the batch or a voiding a document from the batch (Override Mode "A" or "V").

^

mnTransactionAmountPreviousAMEMATH_NUMERICNONENONE

Special Input Expected
This parameter is to specify what amount should be subtracted  from the batch.  Use this parameter 

when changing the batch or a deleting a document from the batch (Override Mode "C" or "D").  Note: When 

changing an amount in the batch, you will pass the amount to subtract from the batch in the 

Transaction Amount Previous parameter, and the amount to add to the batch in the Transaction Amount parameter.


^

cPreviousBatchStatusEV01charNONENONE

Special Input Expected
This parameter is only valid if the parameter Form Is Exited On Add Flag is a "1".


If you want to force or reset the Batch Status, pass the desired Batch Status in this parameter and a 

"1" in the Batch Status Flag parameter.

^

cFLAGBatchStatusEV02charNONENONE

Special Input Expected
This parameter is only valid if the parameter Form Is Exited On Add Flag is a "1".


This parameter controls the Batch Status when the function is closed.


If you want to force or reset the Batch Status, pass the desired Batch Status in the Previous Batch 

Status parameter and pass a "1" in this parameter.


If you want to set the batch to Error, pass a "2", the Batch Status will be set to "E".


Anything else in this parameter will set the Batch Status to whatever the System Constants dictates.

^

cFLAGTransactionInBalanceEV03charNONENONE

Special Input Expected
This parameter is only valid if the parameter Form Is Exited On Add Flag is a "1".


If your transaction is in balance, pass a "Y" or a "1" in this parameter and the corresponding batch 

flag will be set to a "Y", else it will be set to an "N".

^

cFLAGSuppressBatchControlEV04charNONENONE

Special Input Expected
This parameter is only valid if the parameter Form Is Exited On Add Flag is a "1".


If you want to suppress Batch Control, pass a "1" in this parameter.  You should only suppress Batch 

Control if you are positive you will never use it (i.e. calling this function from a UBE).

^

cFLAGFormExitedOnAddEV01charNONENONE

Special Input Expected
This parameter is to be used if you wish to close the batch while updating it.  If you pass a "1" in 

this parameter the function will close this batch after updating it.  Normally, you should use the 

B0000008 Batch - Revise On Exit function to close a batch.

^

cOverrideModeEV05charNONENONE

Special Input Expected
This parameter is a required field.  If a "A", "C", "D", or "V" is not passed, an error will be set.


Valid Values:

A - Add

C - Change/Update

D - Delete

V - Void


^

mnTotalNumberOfDocumentsMATH01MATH_NUMERICNONENONE

Special Input Expected
This parameter is used when heavy transaction processing is being performed and you need to update 

the batch only once for a repetitive process.  Calculate your Batch Amount and Batch Documents totals 

yourself and pass the Batch Documents Total in this parameter and your Batch Amount total in the 

appropriate Transaction Amount parameter.


For Example:

If you have a process that will create a 10,000 document batch , you can call the function once 

rather than 10,000 times.

^

Related Functions

B0100011 Error Message Processor to PPAT System
B0100025 Initialize PPAT Error Message API
BLM0015 Batch Out Of Balance PPAT Error Message

Related Tables

F0011 Batch Control Records
F41001 Inventory Constants