| opPrimeKey | output | longchar | Primary Key field value of loaded record(s). Keys are chr(4) separated. Key fields are chr(2) separated. |
| oiReturnStatus | output | integer | Return status of the method. |
PROCESSBLOCK:
for each t_sGrossIncAcc on error undo, throw:
if t_sGrossIncAcc.Company_ID = 0 or
t_sGrossIncAcc.Company_ID = ?
then assign t_sGrossIncAcc.Company_ID = viCompanyId.
/* ================================================================= */
/* Lookup object by logical key */
/* When in create mode, skip lookup. */
/* ================================================================= */
if vcActivityCode <> "Create":U
then do:
/* ====================================================== */
/* Resolve the ID fields to make the prim query go faster */
/* ====================================================== */
assign viSalesGLID = 0
viSalesDivisionID = 0
viSalesCostCentreID = 0
viSalesProjectID = 0
viTaxPayableGLID = 0
viTaxPayableDivisionID = 0.
if t_sGrossIncAcc.tcSalesGLCode <> "" and
t_sGrossIncAcc.tcSalesGLCode <> ?
then do:
<Q-18 run GLPrim (all) (Read) (Cache)
(input t_sGrossIncAcc.Company_ID, (CompanyId)
input t_sGrossIncAcc.tcSalesGLCode, (GLCode)
input 0, (GLId)
output dataset tqGLPrim) in BGL >
find tqGLPrim where
tqGLPrim.tcGLCode = t_sGrossIncAcc.tcSalesGLCode
no-lock no-error.
if available tqGLPrim
then assign viSalesGLID = tqGLPrim.tiGL_ID.
else assign viSalesGLID = 0.
end. /* if t_sGrossIncAcc.tcSalesGLCode <> "" and */
if t_sGrossIncAcc.tcSalesDivisionCode <> "" and
t_sGrossIncAcc.tcSalesDivisionCode <> ?
then do:
<Q-3 run DivisionPrim (all) (Read) (Cache)
(input t_sGrossIncAcc.Company_ID, (CompanyId)
input 0, (DivisionID)
input t_sGrossIncAcc.tcSalesDivisionCode, (DivisionCode)
output dataset tqDivisionPrim) in BDivision >
find tqDivisionPrim where
tqDivisionPrim.tcDivisionCode = t_sGrossIncAcc.tcSalesDivisionCode
no-lock no-error.
if available tqDivisionPrim
then assign viSalesDivisionID = tqDivisionPrim.tiDivision_ID.
else assign viSalesDivisionID = 0.
end. /* if t_sGrossIncAcc.tcSalesDivisionCode <> "" and */
if t_sGrossIncAcc.tcSalesCostCentreCode <> "" and
t_sGrossIncAcc.tcSalesCostCentreCode <> ?
then do:
<Q-31 run CostCentrePrim (all) (Read) (Cache)
(input t_sGrossIncAcc.Company_ID, (CompanyId)
input 0, (CostCentreID)
input t_sGrossIncAcc.tcSalesCostCentreCode, (CostCentreCode)
output dataset tqCostCentrePrim) in BCostCentre >
find tqCostCentrePrim where
tqCostCentrePrim.tcCostCentreCode = t_sGrossIncAcc.tcSalesCostCentreCode
no-lock no-error.
if available tqCostCentrePrim
then assign viSalesCostCentreID = tqCostCentrePrim.tiCostCentre_ID.
else assign viSalesCostCentreID = 0.
end. /* if t_sGrossIncAcc.tcSalesCostCentreCode <> "" and */
if t_sGrossIncAcc.tcSalesProjectCode <> "" and
t_sGrossIncAcc.tcSalesProjectCode <> ?
then do:
<Q-24 run ProjectPrim (all) (Read) (NoCache)
(input t_sGrossIncAcc.Company_ID, (CompanyId)
input 0, (ProjectID)
input t_sGrossIncAcc.tcSalesProjectCode, (ProjectCode)
output dataset tqProjectPrim) in BProject >
find tqProjectPrim where
tqProjectPrim.tcProjectCode = t_sGrossIncAcc.tcSalesProjectCode
no-lock no-error.
if available tqProjectPrim
then assign viSalesProjectID = tqProjectPrim.tiProject_ID.
else assign viSalesProjectID = 0.
end. /* if t_sGrossIncAcc.tcSalesProjectCode <> "" and */
if t_sGrossIncAcc.tcTaxPayableGLCode <> "" and
t_sGrossIncAcc.tcTaxPayableGLCode <> ?
then do:
<Q-80 run GLPrim (all) (Read) (Cache)
(input t_sGrossIncAcc.Company_ID, (CompanyId)
input t_sGrossIncAcc.tcTaxPayableGLCode, (GLCode)
input 0, (GLId)
output dataset tqGLPrim) in BGL >
find tqGLPrim where
tqGLPrim.tcGLCode = t_sGrossIncAcc.tcTaxPayableGLCode
no-lock no-error.
if available tqGLPrim
then assign viTaxPayableGLID = tqGLPrim.tiGL_ID.
else assign viTaxPayableGLID = 0.
end. /* if t_sGrossIncAcc.tcTaxPayableGLCode <> "" and */
if t_sGrossIncAcc.tcTaxPayableDivisionCode <> "" and
t_sGrossIncAcc.tcTaxPayableDivisionCode <> ?
then do:
<Q-68 run DivisionPrim (all) (Read) (Cache)
(input t_sGrossIncAcc.Company_ID, (CompanyId)
input 0, (DivisionID)
input t_sGrossIncAcc.tcTaxPayableDivisionCode, (DivisionCode)
output dataset tqDivisionPrim) in BDivision >
find tqDivisionPrim where
tqDivisionPrim.tcDivisionCode = t_sGrossIncAcc.tcTaxPayableDivisionCode
no-lock no-error.
if available tqDivisionPrim
then assign viTaxPayableDivisionID = tqDivisionPrim.tiDivision_ID.
else assign viTaxPayableDivisionID = 0.
end. /* if t_sGrossIncAcc.tcTaxPayableDivisionCode <> "" and */
/* =================================================== */
/* Get the GrossIncAcc_ID based on the logical key */
/* =================================================== */
<Q-71 run GrossIncAccPrim (all) (Read) (NoCache)
(input t_sGrossIncAcc.Company_ID, (CompanyId)
input 0, (GrossIncAccID)
input '', (SalesGLCode)
input '', (SalesDivisionCode)
input '', (SalesCostCentreCode)
input '', (SalesProjectCode)
input '', (TaxPayableGLCode)
input '', (TaxPayableDivisionCode)
input viSalesGLID, (SalesGLID)
input viSalesDivisionID, (SalesDivisionID)
input viSalesCostCentreID, (SalesCostCentreID)
input viSalesProjectID, (SalesProjectID)
input viTaxPayableGLID, (TaxPayableGLID)
input viTaxPayableDivisionID, (TaxPayableDivisionID)
output dataset tqGrossIncAccPrim) in BGrossIncomeAccounting >
find tqGrossIncAccPrim where
tqGrossIncAccPrim.tiCompany_ID = t_sGrossIncAcc.Company_ID and
tqGrossIncAccPrim.tcSalesGLCode = t_sGrossIncAcc.tcSalesGLCode and
tqGrossIncAccPrim.tcSalesDivisionCode = t_sGrossIncAcc.tcSalesDivisionCode and
tqGrossIncAccPrim.tcSalesCostCentreCode = t_sGrossIncAcc.tcSalesCostCentreCode and
tqGrossIncAccPrim.tcSalesProjectCode = t_sGrossIncAcc.tcSalesProjectCode and
tqGrossIncAccPrim.tcTaxPayableGLCode = t_sGrossIncAcc.tcTaxPayableGLCode and
tqGrossIncAccPrim.tcTaxPayableDivisionCode = t_sGrossIncAcc.tcTaxPayableDivisionCode
no-lock no-error.
if available tqGrossIncAccPrim
then assign t_sGrossIncAcc.GrossIncAcc_ID = tqGrossIncAccPrim.tiGrossIncAcc_ID.
/* ================ */
/* Load GrossIncAcc */
/* ================ */
if t_sGrossIncAcc.GrossIncAcc_ID = ? or
t_sGrossIncAcc.GrossIncAcc_ID = 0
then assign viFcReturnSuper = -4.
else do:
<M-76 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input string(t_sGrossIncAcc.GrossIncAcc_ID) (icObjectIds),
input '' (icFreeform),
input yes (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BGrossIncomeAccounting>
end. /* else do: */
if viFcReturnSuper >= 0
then do:
find tGrossIncAcc where
tGrossIncAcc.GrossIncAcc_ID = t_sGrossIncAcc.GrossIncAcc_ID
no-error.
if available tGrossIncAcc and tGrossIncAcc.tc_Status <> "":U
then do:
assign vcMessage = trim(#T-72'This Gross Income Accounting record was already processed in this transaction.':255(265675632)T-72#) + chr(10) +
substitute(#T-47'Sales GL Account: &1':255(396032617)T-47#, trim(t_sGrossIncAcc.tcSalesGLCode)) + chr(10) +
substitute(#T-14'Sales Sub-Account: &1':30(65104161)T-14#, trim(t_sGrossIncAcc.tcSalesDivisionCode)) + chr(10) +
substitute(#T-20'Sales Cost Center: &1':30(131895780)T-20#, trim(t_sGrossIncAcc.tcSalesCostCentreCode)) + chr(10) +
substitute(#T-83'Sales Project: &1':20(711936451)T-83#, trim(t_sGrossIncAcc.tcSalesProjectCode)) + chr(10) +
substitute(#T-90'Tax Payable GL Account: &1':255(139397117)T-90#, trim(t_sGrossIncAcc.tcTaxPayableGLCode)) + chr(10) +
substitute(#T-70'Tax Payable Sub-Account: &1':255(457076917)T-70#, trim(t_sGrossIncAcc.tcTaxPayableDivisionCode)) + chr(10) +
substitute(#T-95'Company ID: &1':255(69637)T-95#, trim(string(t_sGrossIncAcc.Company_ID)))
oiReturnStatus = -1.
<M-54 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sGrossIncAcc.tc_Rowid (icRowid),
input 'qadfin-26985':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BGrossIncomeAccounting>
return.
end. /* if available tGrossIncAcc and tGrossIncAcc.tc_Status <> "":U */
end. /* if viFcReturnSuper >= 0 */
end. /* if vcActivityCode <> "Create":U */
/* ================================================================= */
/* When in delete mode, ignore input data. */
/* When object not found, do not return an error. */
/* ================================================================= */
if vcActivityCode = "Delete":U
then do:
if viFcReturnSuper = -4
then delete t_sGrossIncAcc.
else do:
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sGrossIncAcc.tc_Rowid = tGrossIncAcc.tc_Rowid
t_sGrossIncAcc.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tGrossIncAcc.GrossIncAcc_ID).
end. /* else do: */
next.
end. /* if vcActivityCode = "Delete":U */
if vcActivityCode = "Create":U or
viFcReturnSuper = -4
then do:
/* ================================================================= */
/* When object not found and in modify only mode, return an error. */
/* ================================================================= */
if vcActivityCode = "Modify":U
then do:
assign vcMessage = trim(#T-73'Object with this key does not exist.':255(789938300)T-73#) + chr(10) +
substitute(#T-60'Sales GL Account: &1':255(396032617)T-60#, trim(t_sGrossIncAcc.tcSalesGLCode)) + chr(10) +
substitute(#T-63'Sales Sub-Account: &1':30(65104161)T-63#, trim(t_sGrossIncAcc.tcSalesDivisionCode)) + chr(10) +
substitute(#T-78'Sales Cost Center: &1':30(131895780)T-78#, trim(t_sGrossIncAcc.tcSalesCostCentreCode)) + chr(10) +
substitute(#T-1'Sales Project: &1':20(711936451)T-1#, trim(t_sGrossIncAcc.tcSalesProjectCode)) + chr(10) +
substitute(#T-44'Tax Payable GL Account: &1':255(139397117)T-44#, trim(t_sGrossIncAcc.tcTaxPayableGLCode)) + chr(10) +
substitute(#T-45'Tax Payable Sub-Account: &1':255(457076917)T-45#, trim(t_sGrossIncAcc.tcTaxPayableDivisionCode)) + chr(10) +
substitute(#T-34'Company ID: &1':255(69637)T-34#, trim(string(t_sGrossIncAcc.Company_ID)))
oiReturnStatus = -1.
<M-17 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sGrossIncAcc.tc_Rowid (icRowid),
input 'qadfin-164699':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BGrossIncomeAccounting>
leave PROCESSBLOCK.
end. /* if vcActivityCode = "Create":U or */
/* ================================================================= */
/* When object not found or in create mode, create it. */
/* ================================================================= */
<M-50 run AddDetailLine
(input 'GrossIncAcc' (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BGrossIncomeAccounting>
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sGrossIncAcc.tc_Status = "N":U
tGrossIncAcc.tc_Status = "N":U. /* we need to assign this to make our test for doubles work */
end. /* if vcActivityCode = "Create":U or */
else do:
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sGrossIncAcc.tc_Status = "C":U
tGrossIncAcc.tc_Status = "C":U. /* we need to assign this to make our test for doubles work */
end. /* else do: */
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCK.
/* ================================================================= */
/* override value for identity fields in input */
/* ================================================================= */
assign t_sGrossIncAcc.GrossIncAcc_ID = tGrossIncAcc.GrossIncAcc_ID
t_sGrossIncAcc.Company_ID = tGrossIncAcc.Company_ID
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
t_sGrossIncAcc.tc_Rowid = tGrossIncAcc.tc_Rowid
t_sGrossIncAcc.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tGrossIncAcc.GrossIncAcc_ID).
end. /* for each t_sGrossIncAcc on error undo, throw: */