Description
This medhod executes transfer of posting(s) from one journal to second one.
Parameters
icActivityCode | input | character | Acitivty-code: in case the current-activity is not yet known on business-side and this parameter is filled, then the current activity-code on business-side will be filled with the value of this parameter. |
tMassLayerTransferJournalE | input-output | temp-table | Dataset containing list of journal entries to be processed. |
ilSkipWarnings | input | logical | SkipWarnings is used when a warning is produced (for example, open pending vouchers) to firstly display the warning with the dialog box, then if the user has selected "yes" on the UI then the warnings will be skipped because they want to proceed. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bmasslayertransfer.p)
/* =========================================================================== */
/* ApiExecuteLayerTransfer */
/* This method executes transfer of postings from one layer to seconde one */
/* (technically by change of journal of posting */
/* =========================================================================== */
/* Parameters: sJournalEntries - dataset containing list of journal entries */
/* which has to be transferred to another layer */
/* =========================================================================== */
/* ============================================= */
/* Exception handling and Main block start */
/* Start queries used repetitively in the block */
/* ============================================= */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
MAINTRANSFERBLOCK: DO :
/* =================================================================================================== */
/* Set curent activity when not yet known on business-side and when the associated parameter is filled */
/* =================================================================================================== */
if icActivityCode <> "":U and
icActivityCode <> ? and
(vcActivityCode = "":U or
vcActivityCode = ?)
then assign vcActivityCode = icActivityCode.
/* =================================================================================================== */
/* Get the Mfg Pro Version */
/* =================================================================================================== */
<M-72 run StartCacher
(output vhFcComponent (ohCacher),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
if viFcReturnSuper <> 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave MAINTRANSFERBLOCK.
<M-56 run GetIntegerValueFromSession
(input viSessionID (iiSessionId),
input 'MfgProMajorVersion' (icDataItemName),
output viMfgProMajorVersion (oiValue),
output viFcReturnSuper (oiReturnStatus)) in Cacher>
if viFcReturnSuper <> 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave MAINTRANSFERBLOCK.
<M-85 run GetIntegerValueFromSession
(input viSessionID (iiSessionId),
input 'MfgProMinorVersion' (icDataItemName),
output viMfgProMinorVersion (oiValue),
output viFcReturnSuper (oiReturnStatus)) in Cacher>
if viFcReturnSuper <> 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave MAINTRANSFERBLOCK.
/* ====================================================================== */
/* Check if any postings have cross-company postings in a transient layer */
/* Only do this if the current activity is PC-transfer */
/* ====================================================================== */
if vcActivityCode = "PC-Transfer":U and ilSkipWarnings = false
then do:
assign vcTransientLayerType = {&LAYERTYPECODE-TRANSIENT}.
CROSSCYBLOCK:
for each tMassLayerTransferJournalE where
tMassLayerTransferJournalE.tiPosting_ID <> 0 and
tMassLayerTransferJournalE.tiPosting_ID <> ?:
<Q-33 assign vlFcQueryRecordsAvailable = PostingByCrossCyLayerType (NoCache)
(input ?, (CompanyId)
input tMassLayerTransferJournalE.tiPosting_ID, (PostingId)
input vcTransientLayerType, (CrossCyLayerTypeCode)) in BPosting>
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMessage = #T-67'A cross-company posting line links to a transient posting. Make sure to transfer that posting to a management or official layer as well.':255(444049900)T-67#
viLocalReturnStatus = (if viLocalReturnStatus >= 0 then 1 else viLocalReturnStatus).
<M-87 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'tMassLayerTransferJournalE.tiPosting_ID' (icFieldName),
input string(tMassLayerTransferJournalE.tiPosting_ID) (icFieldValue),
input 'W' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'qadfin-386107':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
leave CROSSCYBLOCK.
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* for each tMassLayerTransferJournalE where */
end. /* if vcActivityCode = "PC-Transfer":U and ilSkipWarnings = false */
/* =================================================================================================== */
/* Check if any open pending vouchers exist at the end of the GL Period. */
/* Only do this if the current activity is PC-Transfer. */
/* =================================================================================================== */
if (vcActivityCode = "PC-Transfer":U and ilSkipWarnings = false) and
(viMfgProMajorVersion > 3 /* Meaning eB3 */ or
(viMfgProMajorVersion = 3 /* Meaning eB3 */ and
viMfgProMinorVersion >= 10 /* Meaning SP10 */))
then do:
/* create a list of pending vouchers to check */
empty temp-table tOpenPvoMstrGLPeriodPCTransfer.
for each tMassLayerTransferJournalE:
<Q-44 run PeriodByYearPeriod (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tMassLayerTransferJournalE.tiPostingYear, (PeriodYear)
input tMassLayerTransferJournalE.tiPostingPeriod, (PeriodPeriod)
input ?, (PeriodId)
output dataset tqPeriodByYearPeriod) in BPeriod>
find first tqPeriodByYearPeriod where tqPeriodByYearPeriod.tiCompany_ID = viCompanyId
and tqPeriodByYearPeriod.tiPeriodYear = tMassLayerTransferJournalE.tiPostingYear
and tqPeriodByYearPeriod.tiPeriodPeriod = tMassLayerTransferJournalE.tiPostingPeriod
no-lock no-error.
if not available tqPeriodByYearPeriod
then do:
assign vcMessage = trim(substitute(#T-7'Period &1 is not defined for Year &2':255(999890450)T-7#,tMassLayerTransferJournalE.tiPostingPeriod,tMassLayerTransferJournalE.tiPostingYear))
viLocalReturnStatus = 1.
<M-28 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-574476':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
end. /* if not available tqPeriodByYearPeriod */
create tOpenPvoMstrGLPeriodPCTransfer.
assign tOpenPvoMstrGLPeriodPCTransfer.tcPvoDomain = vcDomainCode
tOpenPvoMstrGLPeriodPCTransfer.ttGLPeriodEndDate = tqPeriodByYearPeriod.ttPeriodEndDate
tOpenPvoMstrGLPeriodPCTransfer.tiOpenStatus = 0.
end. /* for each ... */
/* call the API method */
<I-32 {bFcStartAndOpenInstance
&CLASS = "PMFGPendingVoucher"}>
<M-2 run CheckOpenGLPeriod
(input tOpenPvoMstrGLPeriodPCTransfer (tOpenPvoMstrGLPeriod),
output viFcReturnSuper (oiReturnStatus)) in PMFGPendingVoucher>
<I-8 {bFcCloseInstance
&CLASS = "PMFGPendingVoucher"}>
/* Display a warning if there are open pending vouchers for the existing GL Period */
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
assign vcMessage = trim(#T-54'There are existing open pending vouchers at the end of the GL period.':255(776105890)T-54#)
viLocalReturnStatus = 1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-513613':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
end. /* if viFcReturnSuper < 0 */
end.
if viLocalReturnStatus <> 0
then leave MAINTRANSFERBLOCK.
/* ================================================================================================================ */
/* Check if PC is enabled for the current domain in case the activity is 'PC-Transfer' */
/* If so and the Final-daybook in the control-file is filled then the target journal should match the Final-daybook */
/* ================================================================================================================ */
if vcActivityCode = "PC-Transfer":U
then do :
if vlPeriodicCostingModuleIsActive = ? or
vcPeriodicCostingFinalJournal = ?
then do :
<M-80 run PeriodicCostingModuleIsActive
(input vcDomainCode (icDomainCode),
output vlPeriodicCostingModuleIsActive (olPeriodicCostingModuleIsActive),
output vcPeriodicCostingFinalJournal (ocPeriodicCostingFinalJournal),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAINTRANSFERBLOCK.
end. /* if vlPeriodicCostingModuleIsActive = ? */
if vlPeriodicCostingModuleIsActive <> true
then do :
assign vcMessage = trim(substitute(#T-38'You cannot use activty &1 as the current domain (&2) is not enabled for Periodic-Costing.':255(402147668)T-38#, vcActivityCode, vcDomainCode))
viLocalReturnStatus = -1.
<M-22 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-649988':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
Leave MAINTRANSFERBLOCK.
end. /* if vlPeriodicCostingModuleIsActive = false */
if vcPeriodicCostingFinalJournal <> "":U and
vcPeriodicCostingFinalJournal <> ?
then do :
Find first tMassLayerTransferJournalE where
tMassLayerTransferJournalE.tcTargetJournalCode <> vcPeriodicCostingFinalJournal
no-lock no-error.
if available tMassLayerTransferJournalE
then do :
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-14'The target daybook (&1) in all detail-lines of the Mass-Layer-Transfer should match the final-daybook (&2) as specified in the periodic-costing control-file.':255(139014026)T-14#,tMassLayerTransferJournalE.tcTargetJournalCode,vcPeriodicCostingFinalJournal)).
<M-95 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-560941':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
Leave MAINTRANSFERBLOCK.
end. /* if available tMassLayerTransferJournalE */
end. /* if vcPeriodicCostingFinalJournal <> "":U and */
end. /* if vcActivityCode = "PC-Transfer":U */
/* ================================================================================================ */
/* Validations: Is the journal-type and the target-journal-type correct comparing to the activity ? */
/* Check this for every JournalCode and TargetJournalCode involved */
/* ================================================================================================ */
for each tMassLayerTransferJournalE
break by tMassLayerTransferJournalE.tcJournalCode :
if first-of (tMassLayerTransferJournalE.tcJournalCode)
then do :
/* Read the journal to find out the type */
<Q-21 run JournalByJournalLayerType (all) (Read) (NoCache)
(input ?, (JournalId)
input tMassLayerTransferJournalE.tcJournalCode, (JournalCode)
input viCompanyId, (CompanyId)
input ?, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal >
Find first tqJournalByJournalLayerType no-error.
if not available tqJournalByJournalLayerType
then do :
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-77'Invalid daybook: &1.':255(915894465)T-77#,tMassLayerTransferJournalE.tcJournalCode)).
<M-66 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-778171':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
Leave MAINTRANSFERBLOCK.
end. /* if not available tqJournalByJournalLayerType */
/* Compare the journal-type against the activity */
assign vcMessage = "":U.
if vcActivityCode <> "PC-Transfer":U and
tqJournalByJournalLayerType.tcJournalTypeCode = {&JOURNALTYPE-PERIODICCOSTING}
then assign vcMessage = trim(substitute(#T-42'The daybook-code (&1) cannot have daybook-type &2 as you started activity &3.':255(52815618)T-42#,tMassLayerTransferJournalE.tcJournalCode,{&JOURNALTYPE-PERIODICCOSTING-TR},vcActivityCode)).
else if vcActivityCode = "PC-Transfer":U and
tqJournalByJournalLayerType.tcJournalTypeCode <> {&JOURNALTYPE-PERIODICCOSTING}
then assign vcMessage = trim(substitute(#T-55'The daybook-code (&1) should have daybook-type &2 as you started activity &3.':255(606045963)T-55#,tMassLayerTransferJournalE.tcJournalCode,{&JOURNALTYPE-PERIODICCOSTING-TR},vcActivityCode)).
if vcMessage <> "":U
then do :
<M-92 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-620714':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
assign viLocalReturnStatus = -1.
Leave MAINTRANSFERBLOCK.
end. /* if vcMessage <> "":U */
/* Check Journal Access */
if can-do({&SECUREJOURNALTYPES}, tqJournalByJournalLayerType.tcJournalTypeCode)
then do:
<M-81 run ValidateComponentPostJournalRole
(input tMassLayerTransferJournalE.tcJournalCode (icJournalCode),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAINTRANSFERBLOCK.
end.
end. /* if first-of (tMassLayerTransferJournalE.tcJournalCode) */
end. /* for each tMassLayerTransferJournalE break by tMassLayerTransferJournalE.tcJournalCode */
for each tMassLayerTransferJournalE
break by tMassLayerTransferJournalE.tcTargetJournalCode :
if first-of (tMassLayerTransferJournalE.tcTargetJournalCode)
then do :
/* Read the journal to find out the type */
<Q-93 run JournalByJournalLayerType (all) (Read) (NoCache)
(input ?, (JournalId)
input tMassLayerTransferJournalE.tcTargetJournalCode, (JournalCode)
input viCompanyId, (CompanyId)
input ?, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal >
Find first tqJournalByJournalLayerType no-error.
if not available tqJournalByJournalLayerType
then do :
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-4'Invalid daybook: &1.':255(915894465)T-4#,tMassLayerTransferJournalE.tcTargetJournalCode)).
<M-9 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-195828':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
Leave MAINTRANSFERBLOCK.
end. /* if not available tqJournalByJournalLayerType */
/* Compare the journal-type against the activity */
assign vcMessage = "":U.
if vcActivityCode <> "PC-Transfer":U and
tqJournalByJournalLayerType.tcJournalTypeCode = {&JOURNALTYPE-PERIODICCOSTING}
then assign vcMessage = trim(substitute(#T-12'The daybook-code (&1) cannot have daybook-type &2 as you started activity &3.':255(52815618)T-12#,tMassLayerTransferJournalE.tcTargetJournalCode,{&JOURNALTYPE-PERIODICCOSTING-TR},vcActivityCode)).
else if vcActivityCode = "PC-Transfer":U and
tqJournalByJournalLayerType.tcJournalTypeCode <> {&JOURNALTYPE-PERIODICCOSTING}
then assign vcMessage = trim(substitute(#T-10'The daybook-code (&1) should have daybook-type &2 as you started activity &3.':255(606045963)T-10#,tMassLayerTransferJournalE.tcTargetJournalCode,{&JOURNALTYPE-PERIODICCOSTING-TR},vcActivityCode)).
if vcMessage <> "":U
then do :
<M-5 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-821968':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
assign viLocalReturnStatus = -1.
Leave MAINTRANSFERBLOCK.
end. /* if vcMessage <> "":U */
/* Check Journal Access */
if can-do({&SECUREJOURNALTYPES}, tqJournalByJournalLayerType.tcJournalTypeCode)
then do:
<M-68 run ValidateComponentPostJournalRole
(input tMassLayerTransferJournalE.tcTargetJournalCode (icJournalCode),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAINTRANSFERBLOCK.
end.
end. /* if first-of (tMassLayerTransferJournalE.tcTargetJournalCode) */
end. /* for each tMassLayerTransferJournalE break by tMassLayerTransferJournalE.tcTargetJournalCode */
/* ==================================================================================================================== */
/* Call the API to calculate periodic costing cost adjustment */
/* ==================================================================================================================== */
if vcActivityCode = "PC-Transfer":U and
(viMfgProMajorVersion > 3 /* Meaning eB3 */ or
(viMfgProMajorVersion = 3 /* Meaning eB3 */ and
viMfgProMinorVersion >= 10 /* Meaning SP10 */))
then do:
/* check that the cost method for the domain is First-In First-Out (FIFO) */
<Q-75 run PeriodicCostingControlByDomain (all) (Read) (NoCache)
(input vcDomainCode, (DomainCode)
output dataset tqPeriodicCostingControlByDomain) in BMfgPeriodicCostingCtrl>
find first tqPeriodicCostingControlByDomain where
tqPeriodicCostingControlByDomain.tcpcsc_domain = vcDomainCode.
if available tqPeriodicCostingControlByDomain and
tqPeriodicCostingControlByDomain.tcpcsc_cs_mthd = {&PC-COSTMETHOD-FIFO}
then do:
/* create a temp-table for the API */
empty temp-table tPCCostAdjustmentPCTransfer.
for each tMassLayerTransferJournalE:
<Q-39 run PeriodByYearPeriod (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tMassLayerTransferJournalE.tiPostingYear, (PeriodYear)
input tMassLayerTransferJournalE.tiPostingPeriod, (PeriodPeriod)
input ?, (PeriodId)
output dataset tqPeriodByYearPeriod) in BPeriod>
find first tqPeriodByYearPeriod where tqPeriodByYearPeriod.tiCompany_ID = viCompanyId
and tqPeriodByYearPeriod.tiPeriodYear = tMassLayerTransferJournalE.tiPostingYear
and tqPeriodByYearPeriod.tiPeriodPeriod = tMassLayerTransferJournalE.tiPostingPeriod
no-lock no-error.
if not available tqPeriodByYearPeriod
then do:
assign vcMessage = trim(substitute(#T-79'Period &1 is not defined for Year &2':255(999890450)T-79#,tMassLayerTransferJournalE.tiPostingPeriod,tMassLayerTransferJournalE.tiPostingYear))
viLocalReturnStatus = 1.
<M-15 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-434262':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMassLayerTransfer>
leave MAINTRANSFERBLOCK.
end. /* if not available tqPeriodByYearPeriod */
create tPCCostAdjustmentPCTransfer.
assign tPCCostAdjustmentPCTransfer.tcDomain = vcDomainCode
tPCCostAdjustmentPCTransfer.tcDaybookCode = tMassLayerTransferJournalE.tcJournalCode
tPCCostAdjustmentPCTransfer.tcTargetDaybookCode = tMassLayerTransferJournalE.tcTargetJournalCode
tPCCostAdjustmentPCTransfer.ttGLCalendarStartDate = tqPeriodByYearPeriod.ttPeriodStartDate
tPCCostAdjustmentPCTransfer.ttGLCalendarEndDate = tqPeriodByYearPeriod.ttPeriodEndDate
tPCCostAdjustmentPCTransfer.tiERSStatus = 0.
end. /* for each tMassLayerTransferJournalE: */
/* call the API */
<I-88 {bFcStartAndOpenInstance
&CLASS = "PMFGPeriodicCosting"}>
<M-57 run TransferPCCostAdjustment
(input tPCCostAdjustmentPCTransfer (tPCCostAdjustment),
output viFcReturnSuper (oiReturnStatus)) in PMFGPeriodicCosting>
<I-59 {bFcCloseInstance
&CLASS = "PMFGPeriodicCosting"}>
/* error handling */
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
/* an error occurred during the API call */
/* the API raises the errors, we just need to stop processing */
viLocalReturnStatus = -1.
leave MAINTRANSFERBLOCK.
end.
end. /* if available tqPeriodicCostingControlByDomain and */
end. /* if vcActivityCode = "PC-Transfer":U */
/* ======================================== */
/* Create and open instance of JE-component */
/* Start a block for the JE-instance-action */
/* ======================================== */
<I-73 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BJournalEntry"}>
MAINJEBLOCK: DO :
/* ======================================================= */
/* Call a method in JE for every posting in our temp-table */
/* ======================================================= */
assign viExternalReturnStatus = 0.
for each tMassLayerTransferJournalE:
<M-36 run ApiUpdateJournal
(input tMassLayerTransferJournalE.tiPosting_ID (iiPostingId),
input tMassLayerTransferJournalE.tcTargetJournalCode (icNewJournalCode),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper <> 0 then assign viExternalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then Leave MAINJEBLOCK.
assign tMassLayerTransferJournalE.tlIsProcessed = true
tMassLayerTransferJournalE.tlIsSelect = false.
end. /* for each */
END. /* MAINJEBLOCK */
/* ================= */
/* Close JE-instance */
/* ================= */
<I-48 {bFcCloseAndStopInstance
&CLASS = "BJournalEntry"}>
/* warnings are ignored here because if any warnings are raised during the ApiUpdateJournal then the records will have already been saved. */
if viExternalReturnStatus < 0 then assign viLocalReturnStatus = viExternalReturnStatus.
if viExternalReturnStatus < 0 then Leave MAINTRANSFERBLOCK.
/* ==================================================================================================================== */
/* In case only a single Period is involved and only a single TargetJournal is involved and the TargetJournal blongs to */
/* a non-transient layer and the current activity is PC-MassLayerTransfer then close the Period for Periodic-Costing */
/* ==================================================================================================================== */
if vcActivityCode = "PC-Transfer":U
then do:
Find first tMassLayerTransferJournalE no-lock no-error.
if available tMassLayerTransferJournalE
then do :
assign viFirstPostingYear = tMassLayerTransferJournalE.tiPostingYear
viFirstPostingPeriod = tMassLayerTransferJournalE.tiPostingPeriod
vcFirstTargetJournalCode = tMassLayerTransferJournalE.tcTargetJournalCode.
Find first tMassLayerTransferJournalE where
tMassLayerTransferJournalE.tiPostingYear <> viFirstPostingYear or
tMassLayerTransferJournalE.tiPostingPeriod <> viFirstPostingPeriod
no-lock no-error.
If not available tMassLayerTransferJournalE
then do :
Find first tMassLayerTransferJournalE where
tMassLayerTransferJournalE.tcTargetJournalCode <> vcFirstTargetJournalCode
no-lock no-error.
If not available tMassLayerTransferJournalE
then do :
/* Read the journal to find out the layer type */
<Q-382 run JournalByJournalLayerType (all) (Read) (NoCache)
(input ?, (JournalId)
input vcFirstTargetJournalCode, (JournalCode)
input viCompanyId, (CompanyId)
input ?, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal>
Find first tqJournalByJournalLayerType where
tqJournalByJournalLayerType.tcJournalCode = vcFirstTargetJournalCode and
tqJournalByJournalLayerType.tcLayerTypeCode <> {&LAYERTYPECODE-TRANSIENT}
no-error.
if available tqJournalByJournalLayerType
then do :
<Q-89 run PeriodForSubLedgers (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input viFirstPostingYear, (PeriodYear)
input viFirstPostingPeriod, (PeriodPeriod)
input ?, (PeriodID)
output dataset tqPeriodForSubLedgers) in BPeriod >
Find tqPeriodForSubLedgers where
tqPeriodForSubLedgers.tiCompany_ID = viCompanyId and
tqPeriodForSubLedgers.tiPeriodYear = viFirstPostingYear and
tqPeriodForSubLedgers.tiPeriodPeriod = viFirstPostingPeriod and
tqPeriodForSubLedgers.tlPeriodIsPostingPCAllowed = true
no-lock no-error.
if available tqPeriodForSubLedgers
then do :
/* ============================================================= */
/* Create and open instance of Period-component in different Trx */
/* Run the method to close the period for PC and Close BPeriod */
/* ============================================================= */
<I-30 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BPeriod"}>
<M-71 run ApiDeactivatePeriodForPeriodicCosting
(input vcDomainCode (icDomainCode),
input vcCompanyCode (icCompanyCode),
input viFirstPostingYear (iiPeriodYear),
input viFirstPostingPeriod (iiPeriodPeriod),
output viExternalReturnStatus (oiReturnStatus)) in BPeriod>
<I-18 {bFcCloseAndStopInstance
&CLASS = "BPeriod"}>
if viExternalReturnStatus <> 0 then assign viLocalReturnStatus = viExternalReturnStatus.
if viExternalReturnStatus < 0 then Leave MAINTRANSFERBLOCK.
end. /* if available tqPeriodForSubLedgers */
end. /* if available tqJournalByJournalLayerType */
end. /* If not available tMassLayerTransferJournalE */
end. /* If not available tMassLayerTransferJournalE */
end. /* if available tMassLayerTransferJournalE */
end. /* if vcActivityCode = "PC-Transfer":U */
END. /* MAINTRANSFERBLOCK */
/* ============================================ */
/* Exception handling */
/* ============================================ */
assign oiReturnStatus = viLocalReturnStatus.