Parameters
icAction | input | character | |
bcLstReturn | input-output | character | |
bcLstPrimKey | input-output | character | |
bcLstRowId | input-output | character | |
blSaveAsDraft | input-output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program7/bsafstructure.p)
/*==========================================================*/
/* create/modify SafStructureLine records */
/*==========================================================*/
for each tApiSafStructureLine where
tApiSafStructureLine.tc_ParentRowid = tApiSafStructure.tc_Rowid
by tApiSafStructureLine.tc_Rowid :
/* ==================================== */
/* Find the appropriate exsiting record */
/* ==================================== */
find tSafStructureLine where
tSafStructureLine.tc_ParentRowid = tSafStructure.tc_Rowid and
tSafStructureLine.SafStructureLineNumber = tApiSafStructureLine.SafStructureLineNumber
no-error.
if not avail tSafStructureLine
then find tSafStructureLine where
tSafStructureLine.tc_ParentRowid = tSafStructure.tc_Rowid and
tSafStructureLine.SafStructureLine_ID = tApiSafStructureLine.SafStructureLine_ID
no-error.
/* ================================= */
/* Check for Create / Update */
/* ================================= */
if available tSafStructureLine
then do:
assign tSafStructureLine.tc_Status = '':U.
buffer-compare tApiSafStructureLine except
SafStructureLine_ID
SafStructure_ID
tc_Rowid
tc_ParentRowid
tc_Status
to tSafStructureLine save vlBufferCompareResult.
if vlBufferCompareResult = true
then next.
assign tSafStructureLine.tc_Status = 'C':U.
end. /* if available tSafStructureLine */
else do:
<M-2 run AddDetailLine (input 'SafStructureLine':U (icTable),
input tSafStructure.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BSafStructure>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then do:
assign blSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE})
bcLstReturn = bcLstReturn + chr(4) + string(viFcReturnSuper)
bcLstPrimKey = bcLstPrimKey + chr(4) + "*":U
bcLstRowid = bcLstRowid + chr(4) + "*":U.
return.
end. /* if oiReturnStatus < 0 */
end. /* if viFcReturnSuper <> 0 */
end. /* NOT if available tSafStructureLine */
buffer-copy tApiSafStructureLine except
SafStructureLine_ID
SafStructure_ID
tc_Rowid
tc_ParentRowid
tc_Status
to tSafStructureLine.
end. /* for each tApiSafStructureLine where */
/* =============================================== */
/* Remove the longer used Vatformat of the Saf */
/* =============================================== */
for each tSafStructureLine where
tSafStructureLine.tc_ParentRowid = tSafStructure.tc_Rowid :
/* Check if the record still exists */
find first tApiSafStructureLine where
tApiSafStructureLine.tc_ParentRowid = tApiSafStructure.tc_Rowid AND
tApiSafStructureLine.SafStructureLine_ID = tSafStructureLine.SafStructureLine_ID
no-error.
if not available tApiSafStructureLine
then find first tApiSafStructureLine where
tApiSafStructureLine.tc_ParentRowid = tApiSafStructure.tc_Rowid and
tApiSafStructureLine.SafStructureLineNumber = tSafStructureLine.SafStructureLineNumber
no-error.
if not available tApiSafStructureLine
then if tSafStructureLine.tc_Status = "N":U
then delete tSafStructureLine.
else assign tSafStructureLine.tc_Status = "D":U.
end. /* for each tApiSafStructureLine where ... */