Description
safs
Parameters
| iiSafStructureID | input | integer | SAF structure |
| icSafStructureCode | input | character | code |
| icPostingLineRowid | input | character | tPostingLine.tc_Rowid |
| icParentType | input | character | ParentType |
| icGLCode | input | character | |
| icCostCentreCode | input | character | |
| icProjectCode | 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. |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bjournalentry.p)
if can-find(first tPostingSaf where
tPostingSaf.tc_ParentRowid = icPostingLineRowid and
tPostingSaf.PostingSafParentType = icParentType and
tPostingSaf.tc_Status <> 'D':U and
tPostingSaf.tcSafStructureCode = icSafStructureCode)
then leave.
/* Delete tPostingSaf before defaulting new */
for each tUpdatePostingSaf where
tUpdatePostingSaf.tc_ParentRowid = icPostingLineRowid 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.tc_Status <> 'D':U:
if tPostingSaf.tc_Status = 'N':U
then delete tPostingSaf.
else assign tPostingSaf.tc_Status = 'D':U.
end.
if iiSafStructureID = 0
then return.
assign vcComponentList = if icComponentList = "":U or
icComponentList = ?
then "BGL":U
else icComponentList + chr(2) + "BGL":U
vcComponentValueList = if icComponentList = "":U or
icComponentList = ?
then icGLCode
else icComponentValueList + chr(2) + icGLCode
vcSafConceptList = "":U.
if icParentType = {&POSTINGSAFPARENTTYPE-COSTCENTRE} and
icCostCentreCode <> "":U and
icCostCentreCode <> ?
then assign vcComponentList = vcComponentList + chr(2) + "BCostCentre":U
vcComponentValueList = vcComponentValueList + chr(2) + icCostCentreCode.
if icParentType = {&POSTINGSAFPARENTTYPE-PROJECT} and
icProjectCode <> "":U and
icProjectCode <> ?
then assign vcComponentList = vcComponentList + chr(2) + "BProject":U
vcComponentValueList = vcComponentValueList + chr(2) + icProjectCode.
/* Add Structure to the component list */
assign vcComponentList = vcComponentList + chr(2) + "BSafStructure":U
vcComponentValueList = vcComponentValueList + chr(2) + icSafStructureCode.
<Q-1 run GetSafConceptsForStructure (all) (Read) (NoCache)
(input iiSafStructureID, (SafStructureID)
output dataset tqSafConceptsForStructure) in BSafStructure >
/* Add concepts */
for each tqSafConceptsForStructure break by tqSafConceptsForStructure.tiSafStructure_ID
by tqSafConceptsForStructure.tiSafStructureLineNumber:
<M-2 run AddDetailLine (input 'PostingSaf':U (icTable),
input icPostingLineRowid (icParentRowid),
output oiReturnStatus (oiReturnStatus)) in BPosting>
if oiReturnStatus <> 0
then return.
if vcSafConceptList <> "":U
then assign vcSafConceptList = vcSafConceptList + chr(2).
assign tPostingSaf.PostingSafInputSequence = tqSafConceptsForStructure.tiSafStructureLineNumber
tPostingSaf.SafStructure_ID = iiSafStructureID
tPostingSaf.tcSafStructureCode = icSafStructureCode
tPostingSaf.tcSafConceptCode = tqSafConceptsForStructure.tcSafConceptCode
tPostingSaf.PostingSafParentType = icParentType
vcSafConceptList = vcSafConceptList + tqSafConceptsForStructure.tcSafConceptCode.
create tUpdatePostingSaf.
buffer-copy tPostingSaf to tUpdatePostingSaf.
end.
if vcSafConceptList <> "":U
then do:
assign vhFcComponent = ?.
<M-3 run GetSafDefaults (input vcComponentList (icComponentList),
input vcComponentValueList (icComponentValueList),
input vcSafConceptList (icSafConceptList),
output vcSafList (ocSafList),
output viFcReturnSuper (oiReturnStatus)) in BSafDefault>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
do viA = num-entries(vcSafList, chr(2)) to 1 by -1:
if entry(viA, vcSafList, chr(2)) = "":U
then next.
find tUpdatePostingSaf where
tUpdatePostingSaf.tc_ParentRowid = icPostingLineRowid and
tUpdatePostingSaf.tc_Status <> 'D':U and
tUpdatePostingSaf.tcSafConceptCode = entry(viA, vcSafConceptList, chr(2))
no-error.
if available tUpdatePostingSaf
then assign tUpdatePostingSaf.tcSafCode = entry(viA, vcSafList, chr(2)).
end.
end.