project QadFinancials > class BPosting > method DataLoadByInputSafDefaulting
Description
DataLoadByInputSafDefaulting: submethod of DataLoadByInput that will handle the defaulting of the safs.
Make sure this method and its caller are in the same segment
Parameters
blQStartedGetSafConceptsForStr | input-output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program2/bposting.p)
/* ================================================================================================================= */
/* Function: This method will create the default saf-records in case the caller did not pass any values for the safs */
/* and in case the eGL, Prj or CC needs safs. The saf-records will be created in t_sPostingSaf and in tPostingSaf */
/* ================================================================================================================= */
/* ================== */
/* Exception handling */
/* Start block */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
SAFDEFAULTINGBLOCKDATALOADBYINPUT: DO :
/* ======================================================================================= */
/* Prerequisits: a t_sPostingLine record and a tPostingLine record is available */
/* ======================================================================================= */
assign vcMessage = "".
if not available t_sPostingLine
then assign vcMessage = trim(substitute(#T-6'Internal error: no &1 record is available in method &2.':255(999890483)T-6#,"t_sPostingLine":U,"DataLoadByInputSafDefaulting":U)).
else if not available tPostingLine
then assign vcMessage = trim(substitute(#T-7'Internal error: no &1 record is available in method &2.':255(999890483)T-7#,"tPostingLine":U,"DataLoadByInputSafDefaulting":U)).
if vcMessage <> "":U
then do :
assign viLocalReturnStatus = -3.
<M-8 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9119':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
Leave SAFDEFAULTINGBLOCKDATALOADBYINPUT.
end. /* if vcMessage <> "":U */
/* ================================================================================= */
/* Determine SAF structure to be used by the PostingLine */
/* 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 */
/* Clear the returned temp-table so we are sure the output is just for this call */
/* The returned tt will only contain the SafParantType and the SafStructure */
/* ================================================================================= */
Empty temp-table tSafStructuresForPosting.
<M-1 run ApiGetSafStructuresForPosting
(input tPosting.Company_ID (iiCompanyID),
input t_sPostingLine.tcGLCode (icGLCode),
input t_sPostingLine.tcCostCentreCode (icCostCenterCode),
input t_sPostingLine.tcProjectCode (icProjectCode),
output tSafStructuresForPosting (tApiSafStructuresForPosting),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave SAFDEFAULTINGBLOCKDATALOADBYINPUT.
/* ============================================== */
/* Go through all SafStructures in the temp-table */
/* ============================================== */
for each tSafStructuresForPosting :
/* ================================================================= */
/* Retrieve corresponding SAF concepts for the structures */
/* ================================================================= */
if blQStartedGetSafConceptsForStr = false
then do :
<Q-2 run GetSafConceptsForStructure (Start) in BSafStructure >
assign blQStartedGetSafConceptsForStr = true.
end. /* if blQStartedGetSafConceptsForStr */
<Q-3 run GetSafConceptsForStructure (all) (Read) (Cache)
(input tSafStructuresForPosting.tiPostingSafStructureId, (SafStructureID)
output dataset tqSafConceptsForStructure) in BSafStructure >
assign vcSafConceptList = "":U
vcComponentList = "":U
vcComponentValueList = "":U.
/* ========================================================================================== */
/* Create a tPostingSaf record for each SAF concept of the SafStructure */
/* Build-up vcSafConceptList containing the concepts in the order as defined on the stricture */
/* ========================================================================================== */
for each tqSafConceptsForStructure
by tqSafConceptsForStructure.tiSafStructure_ID
by tqSafConceptsForStructure.tiSafStructureLineNumber :
<M-4 run AddDetailLine
(input 'PostingSaf':U (icTable),
input tPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave SAFDEFAULTINGBLOCKDATALOADBYINPUT.
assign tPostingSaf.PostingLine_ID = tPostingLine.PostingLine_ID
tPostingSaf.SafStructure_ID = tSafStructuresForPosting.tiPostingSafStructureId
tPostingSaf.tcSafStructureCode = tSafStructuresForPosting.tcPostingSafStructureCode
tPostingSaf.PostingSafParentType = tSafStructuresForPosting.tcPostingSafParentType
tPostingSaf.PostingSafInputSequence = tqSafConceptsForStructure.tiSafStructureLineNumber
tPostingSaf.tcSafConceptCode = tqSafConceptsForStructure.tcSafConceptCode.
assign vcSafConceptList = if vcSafConceptList = "":U
then tPostingSaf.tcSafConceptCode
else vcSafConceptList + chr(2) + tPostingSaf.tcSafConceptCode.
end. /* for each tqSafConceptsForStructure */
/* ================================================== */
/* Fill-in vcComponentList and vcComponentValueList */
/* Retrieve default SAF code in the following order: */
/* 1: Cost Center/Project */
/* 2: GL */
/* 3: SafStructure */
/* ================================================== */
assign vcComponentList = "":U.
/* Add GL */
if vcComponentList = "":U
then assign vcComponentList = "BGL":U
vcComponentValueList = t_sPostingLine.tcGLCode.
else assign vcComponentList = vcComponentList + chr(2) + "BGL":U
vcComponentValueList = vcComponentValueList + chr(2) + t_sPostingLine.tcGLCode.
/* Add Prj or CC */
case tPostingSaf.PostingSafParentType:
when {&POSTINGSAFPARENTTYPE-COSTCENTRE}
then if t_sPostingLine.tcCostCentreCode <> ? and
t_sPostingLine.tcCostCentreCode <> "":U
then assign vcComponentList = vcComponentList + chr(2) + "BCostCentre":U
vcComponentValueList = vcComponentValueList + chr(2) + t_sPostingLine.tcCostCentreCode.
when {&POSTINGSAFPARENTTYPE-PROJECT}
then if t_sPostingLine.tcProjectCode <> ? and
t_sPostingLine.tcProjectCode <> "":U
then assign vcComponentList = vcComponentList + chr(2) + "BProject":U
vcComponentValueList = vcComponentValueList + chr(2) + t_sPostingLine.tcProjectCode.
end case.
/* Add SafStructure */
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-5 run GetSafDefaults
(input vcComponentList (icComponentList),
input vcComponentValueList (icComponentValueList),
input vcSafConceptList (icSafConceptList),
output vcSafList (ocSafList),
output viFcReturnSuper (oiReturnStatus)) in BSafDefault>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave SAFDEFAULTINGBLOCKDATALOADBYINPUT.
/* ====================================================================== */
/* Assign the SAF code in tPostingSaf with the default-value we retrieved */
/* ====================================================================== */
for each tPostingSaf where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid and
tPostingSaf.SafStructure_ID = tSafStructuresForPosting.tiPostingSafStructureId and
tPostingSaf.tcSafCode = "":U:
assign viPositionInString = lookup(tPostingSaf.tcSafConceptCode, vcSafConceptList, chr(2)).
if viPositionInString <> 0
then assign tPostingSaf.tcSafCode = entry(viPositionInString, vcSafList, chr(2)).
end. /* for each tPostingSaf where */
end. /* for each tSafStructuresForPosting */
/* =========================================================================================== */
/* For every tPostingSaf of the PostingLine: create a t_sPostingSaf and copy from tPostingSaf */
/* =========================================================================================== */
for each tPostingSaf where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid :
create t_sPostingSaf.
buffer-copy tPostingSaf to t_sPostingSaf.
end. /* for each tPostingSaf where */
END. /* SAFDEFAULTINGBLOCKDATALOADBYINPUT */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.