Description
PostingLineUpdateCrossCy: method that should be called from the UI when tPostingLine.tcPostingLineCrossCompanyCode (only in case the GL on that posting-line is of type 'Cross-Company account') is filled and the user wants to switch to the corresponding posting in the other (tagrget) company
Parameters
iiPostingCompanyID | input | integer | PostingCompanyID of the posting that holds the originating posting-line |
icPostingTcRowid | input | character | PostingTcRowid: field tc_rowid of the Postign that holds the originating posting-line |
icPostingLineTcRowid | input | character | PostingLineTcRowid; field tc_rowid of the originating posting-line |
icPostingLineCrossCompanyGLCode | input | character | PostingLineCrossCompanyGLCode: the GLcode that is on the originating posting-line |
icPostingLineCrossCompanyCode | input | character | PostingLineCrossCompanyCode: the company-code that is on the originating posting-line |
oiPostingLineCrossCompanyID | output | integer | PostingLineCrossCompanyID: the company-id that corresponds with the company-code entered on the originating posting-line |
ocCrossCompanyGLCode | output | character | CrossCompanyGLCode: GLCode that is to be used on the compensating posting-line in the target-company) |
ocCrossCompanyCurrencyCode | output | character | CrossCompanyCurrencyCode: CurrencyCode that is to be used on the compensating posting-line in the target-company) |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program6/bjournalentry.p)
/* ============================================================================================== */
/* This method that should be called from the UI when tPostingLine.tcPostingLineCrossCompanyCode */
/* (only in case the GL on that posting-line is of type 'Cross-Company account') is filled and */
/* the user wants to switch to the corresponding posting in the other (tagrget) company */
/* ============================================================================================== */
/* But: this method is also called for a cross-company posting-line wherefor the corresponding */
/* cross-company posting-line in the other company has not yet been created. This can be the case */
/* for a non-new posting, icPostingLineCrossCompanyCode empty and there is still a record in */
/* table QCrossCyPosting waiting to be processed. If this is the case then we will give another */
/* message then in case some elemantary input was missing */
/* ============================================================================================== */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98.
/* ============================================================================================== */
/* This method is also called for a cross-company posting-line wherefor the corresponding */
/* cross-company posting-line in the other company has not yet been created. This can be the case */
/* for a non-new posting, icPostingLineCrossCompanyCode empty and there is still a record in */
/* table QCrossCyPosting waiting to be processed. If this is the case then we will give another */
/* message then in case some elemantary input was missing */
/* ============================================================================================== */
if can-find (tPosting where
tPosting.tc_Rowid = icPostingTcRowid and
tPosting.tc_Status <> "N":U) and
(icPostingLineCrossCompanyCode = "":U or
icPostingLineCrossCompanyCode = ?)
then do :
<Q-147 assign vlFcQueryRecordsAvailable = QCrossCyPostingByCompany (NoCache) (input ?, (CompanyId)) in BQCrossCyPosting >
if vlFcQueryRecordsAvailable <> false
then do :
assign oiReturnStatus = -1
vcMessage = trim(#T-148'The corresponding posting in the other company has not yet been created. You must wait for this posting to be processed.':255(65671)T-148#) + chr(10) +
trim(#T-149'The corresponding posting has not yet been created, possibly because the cross-company daemon may be inactive. There are still unprocessed requests for this daemon.':255(65670)T-149#) + chr(10) +
trim(#T-150'Verify the Cross-Company daemon status using Cross Company Daemon Monitor.':255(65669)T-150#).
<M-151 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingLineTcRowid (icRowid),
input 'QadFin-7244':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* if can-find */
/* ====================================== */
/* Validate input parameters on emptyness */
/* ====================================== */
assign vcMessage = "":U.
if iiPostingCompanyID = 0 or
iiPostingCompanyID = ?
then assign vcMessage = trim(substitute(#T-95'Internal error: this parameter (&1) is mandatory for this method (&2).':255(60924)T-95#,"PostingCompanyID":U,"PostingLineUpdateCrossCy":U)).
if vcMessage = "":U and
(icPostingTcRowid = "":U or
icPostingTcRowid = ?)
then assign vcMessage = trim(substitute(#T-96'Internal error: this parameter (&1) is mandatory for this method (&2).':255(60924)T-96#,"PostingTcRowid":U,"PostingLineUpdateCrossCy":U)).
if vcMessage = "":U and
(icPostingLineTcRowid = "":U or
icPostingLineTcRowid = ?)
then assign vcMessage = trim(substitute(#T-97'Internal error: this parameter (&1) is mandatory for this method (&2).':255(60924)T-97#,"PostingLineTcRowid":U,"PostingLineUpdateCrossCy":U)).
if vcMessage = "":U and
(icPostingLineCrossCompanyGLCode = "":U or
icPostingLineCrossCompanyGLCode = ?)
then assign vcMessage = trim(substitute(#T-98'Internal error: this parameter (&1) is mandatory for this method (&2).':255(60924)T-98#,"PostingLineCrossCompanyGLCode":U,"PostingLineUpdateCrossCy":U)).
if vcMessage <> "":U
then do :
assign oiReturnStatus = -1.
<M-100 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingLineTcRowid (icRowid),
input 'QadFin-6210':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if vcMessage <> "":U */
if icPostingLineCrossCompanyCode = "":U or
icPostingLineCrossCompanyCode = ?
then do:
assign vcMessage = #T-152'You must define the cross-company code before you create a cross-company posting.':255(69453)T-152#.
<M-153 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'PostingLine.tcCrossCompanyCode':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingLineTcRowid (icRowid),
input 'QadFin-8097':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
assign oiReturnStatus = -1.
return.
end.
/* ======================================== */
/* Validate input parameters on correctness */
/* ======================================== */
find tPosting where
tPosting.tc_Rowid = icPostingTcRowid
no-lock no-error.
if not available tPosting
then do :
assign vcMessage = trim(substitute(#T-103'Internal error: cannot find the posting based on its rowid &1. Method: &2.':255(60925)T-103#,icPostingTcRowid,"PostingLineUpdateCrossCy":U))
oiReturnStatus = -1.
<M-107 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6212':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if not available tPosting */
find tPostingLine where
tPostingLine.tc_Rowid = icPostingLineTcRowid
no-lock no-error.
if not available tPostingLine
then do :
assign vcMessage = trim(substitute(#T-110'Internal error: cannot find the posting-line based on its rowid &1. Method: &2.':255(60926)T-110#,icPostingLineTcRowid,"PostingLineUpdateCrossCy":U))
oiReturnStatus = -1.
<M-109 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingLineTcRowid (icRowid),
input 'QadFin-6213':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if not available tPostingLine */
if tPosting.Company_ID <> iiPostingCompanyID
then do :
assign vcMessage = trim(substitute(#T-112'The company ID &1 of the posting differs from the company ID &2 received as input for the method &3.':255(60929)T-112#,trim(string(tPosting.Company_ID)),icPostingTcRowid,"PostingLineUpdateCrossCy":U))
oiReturnStatus = -1.
<M-111 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6214':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if tPosting.Company_ID <> iiPostingCompanyID */
<Q-113 run GLByGLType (all) (Read) (NoCache)
(input iiPostingCompanyID, (CompanyId)
input ?, (GLId)
input icPostingLineCrossCompanyGLCode, (GLCode)
input ?, (GLTypeCode)
input ?, (GLIsDivisionAccount)
output dataset tqGLByGLType) in BGL >
find tqGLByGLType
no-lock no-error.
if not available tqGLByGLType
then do :
assign vcMessage = trim(substitute(#T-115'The account &1 specified in the original cross-company posting line cannot be found.':255(60930)T-115#,icPostingLineCrossCompanyGLCode)) + chr(10) +
trim(substitute(#T-116'Company ID: &1.':255(413923384)T-116#,trim(string(tPosting.Company_ID))))
oiReturnStatus = -1.
<M-114 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6217':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if not available tqGLByGLType */
if tqGLByGLType.tcGLTypeCode <> {&GLTYPECODE-CROSS}
then do :
assign vcMessage = trim(substitute(#T-118'The account &1 specified in the original cross-company posting line is not of the correct type. This account type should be &2.':255(60932)T-118#,icPostingLineCrossCompanyGLCode,{&GLTYPECODE-CROSS-TR})) + chr(10) +
trim(substitute(#T-119'Company ID: &1.':255(591246328)T-119#,trim(string(tPosting.Company_ID))))
oiReturnStatus = -1.
<M-117 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6218':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if tqGLByGLType.tcGLTypeCode <> {&GLTYPECODE-CROSS} */
<Q-146 run CompanyByCodeCurrActiveID (all) (Read) (NoCache)
(input ?, (CompanyId)
input icPostingLineCrossCompanyCode, (CompanyCode)
input ?, (CompanyIsActive)
input ?, (CurrencyID)
output dataset tqCompanyByCodeCurrActiveID) in BCompany >
find tqCompanyByCodeCurrActiveID
no-lock no-error.
if not available tqCompanyByCodeCurrActiveID
then do :
assign vcMessage = trim(substitute(#T-122'Cannot find the company code &1 specified in the original cross-company posting line.':255(60933)T-122#,icPostingLineCrossCompanyCode))
oiReturnStatus = -1.
<M-121 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6219':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if not available tqCompanyByCodeCurrActiveID */
if tqCompanyByCodeCurrActiveID.tlDomainIsActive <> true
then do :
assign vcMessage = trim(substitute(#T-130'The company code &1 specified in the original cross-company posting line is not active.':255(60934)T-130#,icPostingLineCrossCompanyCode))
oiReturnStatus = -1.
<M-129 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6222':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if tqCompanyByCodeCurrActiveID.tlDomainIsActive <> true */
/* =========================================================================== */
/* Assign the output paramater oiPostingLineCrossCompanyID: */
/* company-id of the target-posting to store in the originating posting-line */
/* =========================================================================== */
assign oiPostingLineCrossCompanyID = tqCompanyByCodeCurrActiveID.tiCompany_ID.
/* ======================================================================================= */
/* Assign the output paramater ocCrossCompanyCurrencyCode: */
/* CurrencyCode that is to be used on the compensating posting-line in the target-company */
/* ======================================================================================= */
assign ocCrossCompanyCurrencyCode = tqCompanyByCodeCurrActiveID.tcCurrencyCode.
/* ================================================================================= */
/* Assign the output paramater ocCrossCompanyGLCode: */
/* GLCode that is to be used on the compensating posting-line in the target-company */
/* ================================================================================= */
/* Get cross company G/L accounts for domain of posting company */
<Q-125 run DomainForInterCompany (all) (Read) (NoCache)
(input tqCompanyByCodeCurrActiveID.tiDomain_ID, (DomainID)
input ?, (DomainCode)
input ?, (CompanyID)
output dataset tqDomainForInterCompany) in BDomain >
find first tqDomainForInterCompany
no-lock no-error.
if not available tqDomainForInterCompany
then do :
assign vcMessage = trim(substitute(#T-132'Internal error: cannot find the domain based on the domain ID &2 specified in the setup of the company &1.':255(60937)T-132#,icPostingLineCrossCompanyCode,string(tqCompanyByCodeCurrActiveID.tiDomain_ID)))
oiReturnStatus = -1.
<M-131 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6223':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if not available tqDomainForInterCompany */
if tqDomainForInterCompany.tcIntercoJEGLCode = "":U or
tqDomainForInterCompany.tcIntercoJEGLCode = ?
then do:
assign vcMessage = trim(substitute(#T-128'Cannot create cross-company posting lines in the journal entry because the cross-company accounts have not been defined for the domain &1.':255(63255)T-128#,tqDomainForInterCompany.tcDomainCode))
oiReturnStatus = -1.
<M-133 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6224':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* f tqDomainForInterCompany.tcIntercoJEGLCode = "":U or */
/* Check the type of th g/l account in the target company */
<Q-134 run GLByGLType (all) (Read) (NoCache)
(input tqCompanyByCodeCurrActiveID.tiCompany_ID, (CompanyId)
input ?, (GLId)
input tqDomainForInterCompany.tcIntercoJEGLCode, (GLCode)
input ?, (GLTypeCode)
input ?, (GLIsDivisionAccount)
output dataset tqGLByGLType) in BGL >
find tqGLByGLType
no-lock no-error.
if not available tqGLByGLType
then do :
assign vcMessage = trim(substitute(#T-137'Cannot find the account &1 specified as the manual journal entry account in the cross-company setup for the domain &2.':255(60939)T-137#,tqDomainForInterCompany.tcIntercoJEGLCode,tqDomainForInterCompany.tcDomainCode)) + chr(10) +
trim(substitute(#T-138'Current Company ID: &1.':255(60940)T-138#,trim(string(tPosting.Company_ID))))
oiReturnStatus = -1.
/* Create a corruption */
assign vhFcComponent = ?.
<M-142 run CreateCorruption
(input 'DomainProperty':U (icTableName),
input trim(substitute('Domain: &1.':U,tqDomainForInterCompany.tcDomainCode)) (icKey),
input vcMessage (icDescription),
input false (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
<M-135 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6225':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if not available tqGLByGLType */
if tqGLByGLType.tcGLTypeCode <> {&GLTYPECODE-CROSS}
then do :
assign vcMessage = trim(substitute(#T-144'The account &1 is defined as the manual journal entry account in the cross-company setup of the domain &2. Account &1 is not a cross-company account.':255(60941)T-144#,tqDomainForInterCompany.tcIntercoJEGLCode,tqDomainForInterCompany.tcDomainCode)) + chr(10) +
trim(substitute(#T-145'Current Company ID: &1.':255(60940)T-145#,trim(string(tPosting.Company_ID))))
oiReturnStatus = -1.
/* Create a corruption */
assign vhFcComponent = ?.
<M-143 run CreateCorruption
(input 'DomainProperty':U (icTableName),
input trim(substitute('Domain: &1.':U,tqDomainForInterCompany.tcDomainCode)) (icKey),
input vcMessage (icDescription),
input false (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
<M-136 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icPostingTcRowid (icRowid),
input 'QadFin-6226':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
Return.
end. /* if tqGLByGLType.tcGLTypeCode <> {&GLTYPECODE-CROSS} */
assign ocCrossCompanyGLCode = tqDomainForInterCompany.tcIntercoJEGLCode.
/* =============================== */
/* Turn-off the exception handling */
/* =============================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.