project QadFinancials > class BJournalEntry > method UpdateManualPostingCostcentre
Description
Update the cost centre code on a posting line that was created by manual input.
Parameters
icPostingLineRowid | input | character | tPostingLine.tc_Rowid |
bcCostCentreCode | input-output | character | cost centre |
icGLCode | input | character | |
icComponentList | input | character | Chr(2) separated list of extra components to check during SAF defaulting. |
icComponentValueList | input | character | Chr(2) separated list of extra component values to check during SAF defaulting. |
tUpdatePostingSaf | input-output | temp-table | saf |
tPostingLineSafStructures | output | temp-table | SAF Structures |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program1/bjournalentry.p)
empty temp-table tPostingLineSafStructures.
if bcCostCentreCode = "":U or
bcCostCentreCode = ?
then return.
/* Find posting line and posting header */
find tPostingLine where
tPostingLine.tc_rowid = icPostingLineRowid
no-error.
if available tPostingLine
then find tPosting where
tPosting.tc_Rowid = tPostingLine.tc_ParentRowid
no-error.
if not available tPostingLine or
not available tPosting
then do:
assign oiReturnStatus = -1
vcMsgJE = trim(subst(#T-11'Internal error: cannot default the cost center information because the posting line cannot be found in the business instance based on its row ID &1.':255(17896)t-11#,icPostingLineRowid)).
<M-10 run SetMessage
(input vcMsgJE (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5947':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
return.
end.
/* Get cost centre definition */
<Q-12 run CostCentreBeginsCode (all) (Read) (NoCache)
(input tPosting.Company_ID, (CompanyId)
input bcCostCentreCode, (Code)
output dataset tqCostCentreBeginsCode) in BCostCentre >
find first tqCostCentreBeginsCode
where tqCostCentreBeginsCode.tcCostCentreCode = bcCostCentreCode no-error.
if not available tqCostCentreBeginsCode
then do:
find tqCostCentreBeginsCode
where tqCostCentreBeginsCode.tcCostCentreCode BEGINS bcCostCentreCode no-error.
/* if there's only one record */
if available tqCostCentreBeginsCode
then assign bcCostCentreCode = tqCostCentreBeginsCode.tcCostCentreCode.
/* Ambiguous records will not be found and available will be false */
else do:
oiReturnStatus = -4.
return.
end.
end.
<M-9 run GetSafStructureForCostCentre
(input tPosting.Company_ID (iiCompanyId),
input ? (iiGLId),
input icGLCode (icGLCode),
input ? (iiCostCentreId),
input bcCostCentreCode (icCostCentreCode),
output viDefaultSafStuctureId (oiSafStructureId),
output vcSafStructureCode (ocSafStructureCode),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viDefaultSafStuctureId <> ? and
viDefaultSafStuctureId <> 0 and
vcSafStructureCode <> ? and
vcSafStructureCode <> "":U
then do:
create tPostingLineSafStructures.
assign tPostingLineSafStructures.tcSafStructureCode = vcSafStructureCode
tPostingLineSafStructures.tiSafStructureID = viDefaultSafStuctureId
tPostingLineSafStructures.tcParentType = {&POSTINGSAFPARENTTYPE-COSTCENTRE}.
end.
assign tPostingLine.tcCostCentreCode = bcCostCentreCode.
/* Delete Saf's before re-create */
for each tUpdatePostingSaf where
tUpdatePostingSaf.tc_ParentRowid = icPostingLineRowid and
tUpdatePostingSaf.PostingSafParentType = {&POSTINGSAFPARENTTYPE-COSTCENTRE} and
tUpdatePostingSaf.tc_status <> "D":U:
if tUpdatePostingSaf.tc_status = "N":U
then delete tUpdatePostingSaf.
else assign tUpdatePostingSaf.tc_status = "D":U.
end.
for each tPostingSaf where
tPostingSaf.tc_ParentRowid = icPostingLineRowid and
tPostingSaf.PostingSafParentType = {&POSTINGSAFPARENTTYPE-COSTCENTRE} and
tPostingSaf.tc_Status <> "D":U:
if tPostingSaf.tc_Status = "N":U
then delete tPostingSaf.
else assign tPostingSaf.tc_Status = "D":U.
end.
if viDefaultSafStuctureId > 0
then do:
<M-2 run PostingLineSafs
(input viDefaultSafStuctureId (iiSafStructureID),
input vcSafStructureCode (icSafStructureCode),
input icPostingLineRowid (icPostingLineRowid),
input {&POSTINGSAFPARENTTYPE-COSTCENTRE} (icParentType),
input icGLCode (icGLCode),
input tPostingLine.tcCostCentreCode (icCostCentreCode),
input '':U (icProjectCode),
input icComponentList (icComponentList),
input icComponentValueList (icComponentValueList),
output oiReturnStatus (oiReturnStatus)) in BJournalEntry>
if oiReturnStatus <> 0
then return.
end.