Description
Controls the processing of the update to data from the Financials into MFG/PRO.
Parameters
ihFinancialDataBuffer | input | handle | |
icMfgBufferHandleList | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bmfgglcalendar.p)
/* ====================================================== */
/* Set the return status to unexpected system error (-98) */
/* ====================================================== */
assign oiReturnStatus = -98.
/* ============================================================================= */
/* Build the temp table that contains the list of buffer handles that we need to */
/* during the processing of the financial table. */
/* ============================================================================= */
<M-1 run CreateMfgTableToUpdate (input icMfgBufferHandleList (icMfgBufferHandleList),
output viFcReturnSuper (oiReturnStatus)) in BMfgGLCalendar>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ===================================================================== */
/* Build a query that will loop though the Data that has been passed */
/* in from the finnancial application that we are going to loop through */
/* and copy to the MFG/PRO application database. */
/* ===================================================================== */
create query vhFinancialDataQuery in widget-pool "non-persistent".
vhFinancialDataQuery:set-buffers(ihFinancialDataBuffer).
vhFinancialDataQuery:query-prepare("for each ":U +
ihFinancialDataBuffer:name +
" where ":U + ihFinancialDataBuffer:name + ".tc_status <> ''":U).
vhFinancialDataQuery:query-open().
vhFinancialDataQuery:get-first().
/* ================================================================================ */
/* Loop through all of the financial records returned from the query created above. */
/* The query will only process record that have had changes applied to the record, */
/* we determine this by only processing records with a tc_status field that is not */
/* blank. */
/* ================================================================================ */
FinancialDataLoop:
do while not vhFinancialDataQuery:query-off-end:
/* ================================================================================ */
/* Determine whether or not the current row from the financial buffer should */
/* be processed and if it shouldn't then get the next row from the query and */
/* start the next iteration of the FinancialDataLoop. */
/* ================================================================================ */
if not <M-2 ProcessRow (input ihFinancialDataBuffer (ihFinancialDataBuffer)) in BMfgGLCalendar>
then do:
vhFinancialDataQuery:get-next().
next FinancialDataLoop.
end.
/* =================================================================== */
/* Synchronize the static buffer with the buffer handle to ensure that */
/* both are pointing to the same record. Otherwise the static buffer */
/* record will not be available in the overriden method such as */
/* LoadMfgData. */
/* =================================================================== */
assign viCalendarDomainId = ihFinancialDataBuffer:buffer-field('Domain_ID':U):buffer-value
viCalendarYear = ihFinancialDataBuffer:buffer-field('GLCalendarYear':U):buffer-value
viCalendarPeriod = ihFinancialDataBuffer:buffer-field('GLCalendarPeriod':U):buffer-value.
find first tGLCalendar1 where
tGLCalendar1.Domain_ID = viCalendarDomainId and
tGLCalendar1.GLCalendarYear = viCalendarYear and
tGLCalendar1.GLCalendarPeriod = viCalendarPeriod
no-error.
/* ============================================================= */
/* Process each of the MFG/PRO buffers that have been passed in */
/* as they all have to be populated with data from the current */
/* table in the financials that we are processing. This save us */
/* having to loop through the finacials table multiple times to */
/* ============================================================= */
for each tMfgTableToUpdate:
/* ============================================================================================ */
/* Get the name of the MFG/PRO & Financial table that we are processing. */
/* If the name starts with "t_" */
/* then we remove the first 3 characters so something like t_oac_mstr becomes ac_mstr etc... */
/* else we remove the first 1 character so something like tCostCentre becomes CostCentre etc... */
/* ============================================================================================ */
assign vhCurrentMfgBuffer = tMfgTableToUpdate.thMfgBuffer
vcCurrentMfgTable = if vhCurrentMfgBuffer:name begins "t_":U
then substring(vhCurrentMfgBuffer:name,4,-1,"CHARACTER":U)
else if vhCurrentMfgBuffer:name begins "tCopy":U
then substring(vhCurrentMfgBuffer:name,6,-1,"CHARACTER":U)
else substring(vhCurrentMfgBuffer:name,2,-1,"CHARACTER":U)
vcCurrentFinancialTable = if ihFinancialDataBuffer:name begins "t_":U
then substring(ihFinancialDataBuffer:name,4,-1,"CHARACTER":U)
else if ihFinancialDataBuffer:name begins "tCopy":U
then substring(ihFinancialDataBuffer:name,6,-1,"CHARACTER":U)
else substring(ihFinancialDataBuffer:name,2,-1,"CHARACTER":U).
/* ============================================================================================ */
/* In case of Change or Delete: */
/* Load the MFG/PRO Data that matches the current row in the financial table. */
/* ============================================================================================ */
if ihFinancialDataBuffer:buffer-field("tc_status":U) <> ? and
(ihFinancialDataBuffer:buffer-field("tc_status":U):buffer-value = "C":U or
ihFinancialDataBuffer:buffer-field("tc_status":U):buffer-value = "D":U)
then do :
<M-3 run LoadMfgData (input vcDomainCode (icMfgDomain),
input vcCurrentMfgTable (icMfgTableName),
input vcCurrentFinancialTable (icFinancialTableName),
output viFcReturnSuper (oiReturnStatus)) in BMfgGLCalendar>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do :
vhFinancialDataQuery:query-close() no-error.
delete object vhFinancialDataQuery no-error.
return.
end. /* if viFcReturnSuper < 0 */
end. /* if ihFinancialDataBuffer:buffer-field("tc_status":U) <> ? and */
/* ============================================================================================ */
/* Now we have the mfg table we are processing the next thing we need to is invoke he general */
/* processing of the record that is common to shared set & system wide table in MFG/PRO. */
/* ============================================================================================ */
<M-4 run ProcessMfgData (input ihFinancialDataBuffer (ihFinancialDataBuffer),
input vhCurrentMfgBuffer (ihMfgDataBuffer),
input vcDomainCode (icMfgDomain),
input vcCurrentMfgTable (icMfgTableName),
input vcCurrentFinancialTable (icFinancialTableName),
output viFcReturnSuper (oiReturnStatus)) in BMfgGLCalendar>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do :
vhFinancialDataQuery:query-close() no-error.
delete object vhFinancialDataQuery no-error.
return.
end. /* if viFcReturnSuper < 0 */
end. /* each t_sMfgTableToUpdate */
vhFinancialDataQuery:get-next().
end. /* not vhFinancialDataQuery:query-off-end */
/* ===================================================================================== */
/* Close and delete the query object so that they get removed from the progress session. */
/* ===================================================================================== */
vhFinancialDataQuery:query-close() no-error.
delete object vhFinancialDataQuery no-error.
/* ======================== */
/* Set ReturnStatus = OK */
/* ======================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.