project QadFinancials > class BPosting > method ValidateComponentPostCrossCompanyDeleteConstraint
Description
Delete constraint on cross company postings. (These constraints are not automatically generated, as we need to be able to by-pass them if the linked posting is being deleted in the same transaction).
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* ======================================================================================================== */
/* Delete constraint: PostingLine can not be deleted when there is another posting/postingline linked to it */
/* Unless if that linked posting is being deleted in the same transaction. */
/* ======================================================================================================== */
/* Validate if the linked PostingLine is also being deleted */
assign vcMessage = "".
if t_sPostingLine.CrossCompanyPostingLine_ID <> ? and
t_sPostingLine.CrossCompanyPostingLine_ID <> 0 and
(t_sPosting.tc_Status = 'D' or
t_sPostingLine.tc_Status = 'D')
then do:
find bPostingLine where
bPostingLine.PostingLine_ID = t_sPostingLine.CrossCompanyPostingLine_ID
no-error.
if available bPostingLine
then do:
if bPostingLine.tc_Status <> 'D' and
not can-find(bPosting where
bPosting.Posting_ID = bPostingLine.Posting_ID and
bPosting.tc_Status = 'D')
then do:
assign vcMessage = #T-26'Unable to delete; this Posting Line is in use by Posting Line':255(67526)T-26#
oiReturnStatus = -3.
end. /* if not can-find(bPosting where */
end. /* if available bPostingLine */
else assign vcMessage = #T-24'Unable to delete; this Posting Line is in use by Posting Line':255(67526)T-24#
oiReturnStatus = -3.
if vcMessage <> ""
then do:
<M-10 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.CrossCompanyPostingLine_ID' (icFieldName),
input t_sPostingLine.CrossCompanyPostingLine_ID (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'qadfin-141708':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if vcMessage <> "" */
end. /* if t_sPostingLine.CrossCompanyPostingLine_ID <> ? and */
/* Validate if the linked Posting is also being deleted */
if t_sPostingLine.CrossCompanyPosting_ID <> ? and
t_sPostingLine.CrossCompanyPosting_ID <> 0 and
(t_sPosting.tc_Status = 'D' or
t_sPostingLine.tc_Status = 'D') and
not can-find(first bPosting where
bposting.Posting_ID = t_sPostingLine.CrossCompanyPosting_ID and
bPosting.tc_Status = 'D')
then do:
assign vcMessage = #T-8'Unable to delete; this Posting Line is in use by Posting Line':255(67526)T-8#
oiReturnStatus = -3.
<M-12 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.CrossCompanyPosting_ID' (icFieldName),
input t_sPostingLine.CrossCompanyPosting_ID (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'qadfin-201299':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if t_sPostingLine.CrossCompanyPostingLine_ID <> ? and */