project QadFinancials > class BDivision > method CalcAllSelectDivisionForCOAMaskAll
query calculated fields procedure
Description
Assign a value to query calculated fields
Parameters
iiCompanyId | input | integer | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdivision.p)
/* Because of database structure and limitation of componenet builder, additional *
* filtering of resulting records have to be done (this is related to outer join */
/* For one sub-account more records can be retrieved. In result only one should be there */
/* the one which has linked COA Mask in the domain */
/* Or one sub-account records with blank COA Mask, when Mask is not linked to subaccount in this domain */
/* Get Shared Set Id of the COA Mask CC */
assign vhFcComponent = vhCacher.
<M-1 run GetIntegerValueFromSession
(input viSessionID (iiSessionId),
input 'SharedSetForSUBACCOUNTCOAMASK':U (icDataItemName),
output viCOAMaskDivSharedSetId (oiValue),
output viFcReturnSuper (oiReturnStatus)) in Cacher>
if viFcReturnSuper <> 0 then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
create query vhQuery in widget-pool "non-persistent".
vhQuery:set-buffers(ih_Buffer).
vhQuery:query-prepare("for each ":U + ih_Buffer:table + " break by tcDivisionCode").
vhQuery:query-open().
vhQuery:get-first().
do while not vhQuery:query-off-end:
RECORD_BLOCK:
do on error undo, return:
/* if this is the first record of Division, set flag indicating whether *
* any Division record is retrieved or not */
if vhQuery:first-of(1)
then assign vlExactMatchFound = false.
/* if this record has linked any COA Mask profile link but not valid for this *
* domain, clear out also id of the Profile Link Id */
if {&tiProfLnkCOADivSharedSet_ID} <> 0 and
{&tiProfLnkCOADivSharedSet_ID} <> ? and
{&tiProfLnkCOADivSharedSet_ID} <> viCOAMaskDivSharedSetId and
({&tcCOAMaskDivCode} = ? or
{&tcCOAMaskDivCode} = "":U)
then assign {&tiProfLnkCOADivSharedSet_ID} = ?.
/* If still not any Division records have been found (the one with linked COA mask in Domain) then *
* the last one (with not linked COA Mask is retrieved */
if vhQuery:last-of(1) and
not vlExactMatchFound
then leave RECORD_BLOCK.
/* If this is exact match, just keep record, otherwise selete it */
if {&tcCOAMaskDivCode} <> ? and
{&tcCOAMaskDivCode} <> "":U
then assign vlExactMatchFound = true.
else ih_Buffer:buffer-delete().
end. /* RECORD_BLOCK: */
vhQuery:get-next().
end.
vhQuery:query-close().
delete object vhQuery.