project QadFinancials > class BQCrossCyPosting > method ApiProcessQCrossCyPostingForReverse
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bqcrosscyposting.p)
/* Note: the tQCrossCyPosting record is available here as this method is running in the same segment as the calling method */
assign oiReturnStatus = -98.
/* ================================= */
/* start/open journal entry instance */
/* ================================= */
if viBJournalEntryQCrossCyPostID = 0 or viBJournalEntryQCrossCyPostID = ?
then do:
<I-78 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "'True'"
&CLASS = "BJournalEntry"}>
end.
else do:
<I-88 {bFcOpenInstance
&CLASS = "BJournalEntry"}>
end.
PROCESSBLOCK:
do:
assign viLocalReturn = 0.
/* Reversal cross-company posting processing */
if tQCrossCyPosting.ComplPostingRevPosting_ID <> 0 and tQCrossCyPosting.ComplPostingRevPosting_ID <> ?
then do:
<M-68 run DataLoad
(input ? (icRowids),
input ? (icPkeys),
input string(tQcrossCyPosting.ComplPostingRevPosting_ID) (icObjectIds),
input ? (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
assign vcMessage = trim(substitute(#T-61'Cannot reverse the posting: &1':255(83611179)T-61#, tQCrossCyPosting.ComplPostingRevPosting_ID)).
<M-60 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tQCrossCyPosting.ComplPostingRevPosting_ID (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input tQCrossCyPosting.tc_Rowid (icRowid),
input 'QadFin-736131':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
Leave PROCESSBLOCK.
end. /* if viFcReturnSuper < 0 */
end. /* if tQCrossCyPosting.ComplPostingRevPosting_ID <> 0 or tQCrossCyPosting.ComplPostingRevPosting_ID <> ? */
<M-74 run GetPostingRowidBasedOnPostingID
(input tQCrossCyPosting.ComplPostingRevPosting_ID (iiPostingID),
output vcPostingRowid (ocPostingRowid),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave PROCESSBLOCK.
/* Get the original cross-company detail - CompanyID and JournalCode */
<Q-24 run PostingPrim (all) (Read) (NoCache)
(input ?, (CompanyId)
input ?, (JournalCode)
input ?, (PeriodYear)
input ?, (PostingVoucher)
input tQCrossCyPosting.ComplPostingRevPosting_ID, (PostingID)
output dataset tqPostingPrim) in BPosting >
find first tqPostingPrim where
tqPostingPrim.tiPosting_ID = tQCrossCyPosting.ComplPostingRevPosting_ID
no-error.
if not available tqPostingPrim
then do:
assign viLocalReturn = -1
vcMsgCrossCy = trim(substitute(#T-21'Unable to find the Cross Company Posting: &1':255(410305515)T-21#, tQCrossCyPosting.ComplPostingRevPosting_ID)).
<M-25 run SetMessage
(input vcMsgCrossCy (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-651024':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
Leave ProcessBlock.
end.
assign viCrossCompanyID = tqPostingPrim.tiPostingCompanyID
vcCrossCyJournalCode = tqPostingPrim.tcPostingJournalCode.
/* Get the posting year and period for the current SI Reverse */
<Q-96 run PostingByPostingId (all) (Read) (NoCache)
(input ?, (CompanyId)
input tQCrossCyPosting.OriginatorPosting_ID, (PostingId)
input ?, (JournalTypeCode)
output dataset tqPostingByPostingId) in BPosting >
find first tqPostingByPostingId where
tqPostingByPostingId.tiPosting_ID = tQCrossCyPosting.OriginatorPosting_ID
no-error.
if not available tqPostingByPostingId
then do:
assign viLocalReturn = -1
vcMsgCrossCy = trim(substitute(#T-52'Unable to find the Reverse Matching Posting: &1':255(45639633)T-52#, tQCrossCyPosting.OriginatorPosting_ID)).
<M-55 run SetMessage
(input vcMsgCrossCy (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-74598':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
leave PROCESSBLOCK.
end.
<M-85 run CreateReverseEntry
(input vcPostingRowid (icPostingTcRowid),
input tqPostingByPostingId.tiPeriodYear (iiNewPeriodYear),
input tqPostingByPostingId.tiPeriodPeriod (iiNewPeriodPeriod),
input vcCrossCyJournalCode (icNewJournalCode),
input 0 (iiNewVoucher),
input tqPostingByPostingId.ttPostingDate (itNewPostingDate),
input tQCrossCyPosting.QCrossCyPostingInfo (icNewPostingText),
output viNewPostingID (oiNewPostingID),
input tQCrossCyPosting.CrossCompanyGLIsCredit (ilReverseBySign),
input tqPostingByPostingId.tiPostingVoucher (iiOriginVoucher),
input false (ilIsValidateJournalType),
input vcCrossCyJournalCode (icReportingJournalCode),
input 0 (iiBQCrossCyPostingID),
input true (ilCallFromDaemon),
output viNewPostingLineID (oiNewPostingLineID),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave PROCESSBLOCK.
/* ====================================================================================== */
/* Call submethod that will also set the CrossCompany info of the originator postingline */
/* ====================================================================================== */
<M-48 run ApiProcessQCrossCyPostingJE
(input tQCrossCyPosting.OriginatorCompany_ID (iiOriginatorCompanyID),
input tQCrossCyPosting.OriginatorPosting_ID (iiOriginatorPostingID),
input tQCrossCyPosting.OriginatorPostingLine_ID (iiOriginatorPostingLineID),
input tQCrossCyPosting.Company_ID (iiNewCompanyID),
input viNewPostingID (iiNewPostingID),
input viNewPostingLineID (iiNewPostingLineID),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
<M-79 run ValidateBCAndAdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper <> 0
then do:
if viFcReturnSuper < 0
then assign vcMsgCrossCy = trim(substitute(#T-93'An error (&1) has occurred while validating the journal entry of the cross-company posting.':255(56008583)T-93#, string(viFcReturnSuper))).
else assign vcMsgCrossCy = trim(substitute(#T-70'A warning (&1) has occurred while validating the journal entry of the cross-company posting.':255(150387165)T-70#, string(viFcReturnSuper))).
assign viLocalReturn = viFcReturnSuper.
<M-12 run SetMessage
(input vcMsgCrossCy (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input (if viLocalReturn < 0 then 'E':U else 'W':U) (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-278291':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
<M-94 run SetPublicData
(input 'vlPostingMustBebalanced':U (icDataList),
input 'False' (icValueList),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 then leave PROCESSBLOCK.
end. /* if viFcReturnSuper <> 0 */
/* ============================================ */
/* Datasave: real commit of the tranaction */
/* Make sure all external components are closed */
/* ============================================ */
<I-5 {bFcCloseInstance
&CLASS = "BJournalEntry"}>
end. /* PROCESSBLOCK */
if viLocalReturn <> 0
then assign oiReturnStatus = viLocalReturn.
if viLocalReturn < 0
then Return.
/* ================== */
/* Exception handling */
/* ================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.