Description
Get next batch number
Parameters
icDomain | input | character | |
oiBatch | output | integer | New batch number |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bmfgaccountpayablectrl.p)
/* ======================================================================== *
* Method : GetNextBatchNumber *
* Description : This procedure return next batch number *
* ------------------------------------------------------------------------ *
* Params (I): Domain Domain *
* (O): Batch Next batch number *
* ======================================================================== */
/* Error handling */
assign oiReturnStatus = -98
viLocalReturn = 0.
/* Default output values */
assign oiBatch = ?.
MAIN_BLOCK:
do on error undo, return:
/* Normalize input parameters */
if icDomain = "":U then assign icDomain = ?.
/* Validate input paramters */
if icDomain = ?
then do:
assign vcMessage = #T-3'You have not entered all the mandatory values.':255(63250)t-3#
vcContext = substitute("icDomain=&1", icDomain).
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9028':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMfgAccountPayableCtrl>
assign oiReturnStatus = -1.
return.
end.
/* Get Account Payable Control file */
<M-5 run DataLoad
(input ? (icRowids),
input icDomain (icPkeys),
input ? (icObjectIds),
input ? (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BMfgAccountPayableCtrl>
if viFcReturnSuper = -4
then do:
/* if the record does not exist, then create it */
<M-6 run AddDetailLine
(input 'apc_ctrl':U (icTable),
input '':U (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BMfgAccountPayableCtrl>
assign tapc_ctrl.apc_domain = icDomain.
end.
if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
find tapc_ctrl where
tapc_ctrl.apc_domain = icDomain no-error.
if not available tapc_ctrl
then do:
assign vcMessage = #T-8'Missing Account Payable Control file record.':255(999890329)T-8#
vcContext = substitute("icDomain=&1", icDomain).
<M-7 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9029':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMfgAccountPayableCtrl>
assign oiReturnStatus = -1.
return.
end.
/* Calculate new batch number */
assign oiBatch = tapc_ctrl.apc_batch
tapc_ctrl.apc_batch = tapc_ctrl.apc_batch + 1
tapc_ctrl.tc_Status = (if tapc_ctrl.tc_Status = "":U
then "C":U
else tapc_ctrl.tc_Status).
/* If new batch number is outside the range, start from 1 again */
if length(string(tapc_ctrl.apc_batch), "CHARACTER":U) > 8
then assign tapc_ctrl.apc_batch = 1.
end. /* of MAIN_BLOCK */
/* Error handling */
assign oiReturnStatus = viLocalReturn.