project QadFinancials > class BPosting > method ApiStdMaintainTTSub11
Description
Sub-method of ApiStdMaintainTTSub1
Parameters
| blQStartedGetSafConceptsForStr | input-output | logical | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program9/bposting.p)
/* ======================================================================================= */
/* Prerequisits: a tPosting line record is available and tApiPostingSafcan can be accessed */
/* ======================================================================================= */
Empty temp-table tSafStructuresForPosting.
/* ================================================================================= */
/* Determine SAF structures to be used by the posting */
/* The queries executed in method ApiGetSafStructuresForPosting are not started and */
/* stopped as that method is called from several places and the impact may be to big */
/* ================================================================================= */
<M-10 run ApiGetSafStructuresForPosting
(input tPosting.Company_ID (iiCompanyId),
input tPostingLine.tcGLCode (icGLCode),
input tPostingLine.tcCostCentreCode (icCostCenterCode),
input tPostingLine.tcProjectCode (icProjectCode),
output tSafStructuresForPosting (tApiSafStructuresForPosting),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if viFcReturnSuper <> 0 */
/* ============================================== */
/* Go through all SafStructures in the temp-table */
/* ============================================== */
for each tSafStructuresForPosting:
/* ================================================================= */
/* Retrieve corresponding SAF concepts for the structures */
/* ================================================================= */
if blQStartedGetSafConceptsForStr = false
then do :
<Q-11 run GetSafConceptsForStructure (Start) in BSafStructure >
assign blQStartedGetSafConceptsForStr = true.
end. /* if blQStartedGetSafConceptsForStr */
<Q-7 run GetSafConceptsForStructure (all) (Read) (Cache)
(input tSafStructuresForPosting.tiPostingSafStructureId, (SafStructureID)
output dataset tqSafConceptsForStructure) in BSafStructure >
assign vlRetrieveSafDefaults = false
vcSafConceptList = "":U
vcComponentList = "":U
vcComponentValueList = "":U.
/* ================================================================= */
/* Create a tPostingSaf record for each SAF concept */
/* ================================================================= */
for each tqSafConceptsForStructure
by tqSafConceptsForStructure.tiSafStructure_ID
by tqSafConceptsForStructure.tiSafStructureLineNumber:
<M-8 run AddDetailLine
(input 'PostingSaf':U (icTable),
input tPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if viFcReturnSuper <> 0 */
assign tPostingSaf.PostingLine_ID = tPostingLine.PostingLine_ID
tPostingSaf.PostingSafInputSequence = tqSafConceptsForStructure.tiSafStructureLineNumber
tPostingSaf.SafStructure_ID = tSafStructuresForPosting.tiPostingSafStructureId
tPostingSaf.tcSafStructureCode = tSafStructuresForPosting.tcPostingSafStructureCode
tPostingSaf.PostingSafParentType = tSafStructuresForPosting.tcPostingSafParentType
tPostingSaf.tcSafConceptCode = tqSafConceptsForStructure.tcSafConceptCode.
/* ================================================================= */
/* Assign SAF code from the interface, if specified. Otherwise, */
/* construct the list of SAF concept so default SAF code can be */
/* retrieved. */
/* ================================================================= */
find first tApiPostingSaf where
tApiPostingSaf.tcSafConceptCode = tPostingSaf.tcSafConceptCode and
tApiPostingSaf.PostingLine_ID = tPostingSaf.PostingLine_ID
no-error.
if available tApiPostingSaf and
tApiPostingSaf.tcSafCode <> ? and
tApiPostingSaf.tcSafCode <> "":U
then do:
assign tPostingSaf.tcSafCode = tApiPostingSaf.tcSafCode.
<M-12 run SetRowidConvert
(input tApiPostingSaf.tc_Rowid (icOldRowid),
input tPostingSaf.tc_Rowid (icNewRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
else assign vlRetrieveSafDefaults = true
vcSafConceptList = if vcSafConceptList = "":U
then tPostingSaf.tcSafConceptCode
else vcSafConceptList + chr(2) + tPostingSaf.tcSafConceptCode.
end. /* for each tqSafConceptsForStructure */
/* ================================================================= */
/* Retrieve default SAF code in the following order: */
/* Cost Center/Project */
/* GL */
/* SAF Structure */
/* ================================================================= */
if vlRetrieveSafDefaults
then do:
case tPostingSaf.PostingSafParentType:
when {&POSTINGSAFPARENTTYPE-COSTCENTRE}
then do:
if tPostingLine.tcCostCentreCode <> ? and tPostingLine.tcCostCentreCode <> "":U
then assign vcComponentList = "BCostCentre":U
vcComponentValueList = tPostingLine.tcCostCentreCode.
end.
when {&POSTINGSAFPARENTTYPE-PROJECT}
then do:
if tPostingLine.tcProjectCode <> ? and tPostingLine.tcProjectCode <> "":U
then assign vcComponentList = "BProject":U
vcComponentValueList = tPostingLine.tcProjectCode.
end.
end case.
if vcComponentList = "":U
then assign vcComponentList = "BGL":U
vcComponentValueList = tPostingLine.tcGLCode.
else assign vcComponentList = vcComponentList + chr(2) + "BGL":U
vcComponentValueList = vcComponentValueList + chr(2) + tPostingLine.tcGLCode.
assign vcComponentList = vcComponentList + chr(2) + "BSafStructure":U
vcComponentValueList = vcComponentValueList + chr(2) + tSafStructuresForPosting.tcPostingSafStructureCode.
/* =================================================================== */
/* Find the default SAF code from the component in the order specified */
/* =================================================================== */
assign vhFcComponent = ?.
<M-9 run GetSafDefaults (input vcComponentList (icComponentList),
input vcComponentValueList (icComponentValueList),
input vcSafConceptList (icSafConceptList),
output vcSafList (ocSafList),
output viFcReturnSuper (oiReturnStatus)) in BSafDefault>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end. /* if viFcReturnSuper <> 0 */
/* ================================================================= */
/* Assign the SAF code from the default value retrieved */
/* ================================================================= */
for each tPostingSaf where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid and
tPostingSaf.SafStructure_ID = tSafStructuresForPosting.tiPostingSafStructureId and
tPostingSaf.tcSafCode = "":U:
assign vii = lookup(tPostingSaf.tcSafConceptCode, vcSafConceptList, chr(2)).
if vii <> 0
then assign tPostingSaf.tcSafCode = entry(vii, vcSafList, chr(2)).
end. /* for each tPostingSaf where */
end. /* if vlRetrieveSafDefaults */
end. /* for each tSafStructuresForPosting */