Parameters
icDomainCode | input | character | |
icCompanyCode | input | character | |
icStatus | input | character | |
icGLCodes | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bcompanyproperty.p)
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
<Q-11 run DomainForInterCompany (all) (Read) (NoCache)
(input ?, (DomainID)
input icDomainCode, (DomainCode)
input ?, (CompanyID)
output dataset tqDomainForInterCompany) in BDomain >
find first tqDomainForInterCompany where
tqDomainForInterCompany.tcDomainCode = icDomainCode
no-error.
if not available tqDomainForInterCompany or
(available tqDomainForInterCompany and
tqDomainForInterCompany.tcIntercoAPGLCode = '' and
tqDomainForInterCompany.tcIntercoARGLCode = '' and
tqDomainForInterCompany.tcIntercoFAGLCode = '' and
tqDomainForInterCompany.tcIntercoICGLCode = '' and
tqDomainForInterCompany.tcIntercoJEGLCode = '')
then do :
assign oiReturnStatus = viLocalReturnStatus.
return.
end.
assign vcModules = "AP,AR,FA,IC":U
vcDivisionCodes = "":U
vcDRCR = "DR,CR":U.
/*******************************************************************/
/* Retrieve the division codes */
<Q-22 run GLByIDCode
(Start) in BGL >
do viModule = 1 to 4:
<Q-20 run GLByIDCode (all) (Read) (NoCache)
(input ?, (CompanyId)
input ?, (GLID)
input entry(viModule,icGLCodes), (GLCode)
output dataset tqGLByIDCode) in BGL >
find first tqGLByIDCode no-error.
if not available tqGLByIDCode then next.
assign vcDivisionCodes = vcDivisionCodes
+ (if viModule > 1 then ",":U else "":U)
+ tqGLByIDCode.tcDivisionCode.
end.
<Q-23 run GLByIDCode
(Stop) in BGL >
/*******************************************************************/
do viModule = 1 to 4: /* vcModules = "AP,AR,FA,IC":U */
do viDRCR = 1 to 2: /* vcDRCR = "DR,CR":U */
create tAccountDefaultMasterInterCo.
assign
tAccountDefaultMasterInterCo.tcDomain = icDomainCode
tAccountDefaultMasterInterCo.tcModule = entry(viModule, vcModules)
tAccountDefaultMasterInterCo.tcType = 'ICO_ACCT':U
tAccountDefaultMasterInterCo.tcKey1 = icCompanyCode
tAccountDefaultMasterInterCo.tcKey2 = entry(viDRCR, vcDRCR)
tAccountDefaultMasterInterCo.tcKey3 = '':U
tAccountDefaultMasterInterCo.tcKey4 = '':U
tAccountDefaultMasterInterCo.tcKey5 = '':U
tAccountDefaultMasterInterCo.tcKey6 = '':U
tAccountDefaultMasterInterCo.tcAcct = entry(viModule, icGLCodes)
tAccountDefaultMasterInterCo.tcSub = entry(viModule, vcDivisionCodes)
tAccountDefaultMasterInterCo.tcCc = '':U no-error.
if error-status:error
then do:
assign oiReturnStatus = -3
vcMessage = trim(#T-29'An internal error occurred while creating the intercompany accounts.':100(63188)T-29#).
if ERROR-STATUS:NUM-MESSAGES > 0
then assign vcMessage = vcMessage + chr(10) +
trim(substitute(#T-28'Detailed info: &1 (&2)':255(45616)T-28#,ERROR-STATUS:GET-MESSAGE(1),string(ERROR-STATUS:GET-NUMBER(1)))).
<M-30 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6412':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
return.
end. /* if error-status:error */
if icStatus <> "":U then
assign tAccountDefaultMasterInterCo.tc_Status = icStatus.
else do:
if not vlAccountDefaultMasterPrimStart
then do:
<Q-31 run AccountDefaultMasterByPrimKey
(Start) in BMfgAccountDefaultMaster >
assign vlAccountDefaultMasterPrimStart = yes.
end.
/* Search for the mfgpro record - acdf_mstr */
<Q-32 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
(input tAccountDefaultMasterInterCo.tcDomain, (DomainCode)
input tAccountDefaultMasterInterCo.tcModule, (Module)
input tAccountDefaultMasterInterCo.tcType, (Type)
input tAccountDefaultMasterInterCo.tcKey1, (Key1)
input tAccountDefaultMasterInterCo.tcKey2, (Key2)
input tAccountDefaultMasterInterCo.tcKey3, (Key3)
input tAccountDefaultMasterInterCo.tcKey4, (Key4)
input tAccountDefaultMasterInterCo.tcKey5, (Key5)
input tAccountDefaultMasterInterCo.tcKey6, (Key6)
output dataset tqAccountDefaultMasterByPrimKey) in BMfgAccountDefaultMaster >
find first tqAccountDefaultMasterByPrimKey no-lock no-error.
if available tqAccountDefaultMasterByPrimKey then do:
/* If the mfgpro record exists, and the codes were removed - then we should delete the record */
if tAccountDefaultMasterInterCo.tcAcct = "":U or tAccountDefaultMasterInterCo.tcAcct = ? then
assign tAccountDefaultMasterInterCo.tc_Status = "D":U.
/* If the codes were changed then update */
else if tAccountDefaultMasterInterCo.tcAcct <> tqAccountDefaultMasterByPrimKey.tcacdf_acct then
assign tAccountDefaultMasterInterCo.tc_Status = "C":U.
/* Otherwise - do nothing */
else
delete tAccountDefaultMasterInterCo.
end.
/* If no mfgpro record exists, and the codes are not blank, then create the record */
else if tAccountDefaultMasterInterCo.tcAcct <> "":U and tAccountDefaultMasterInterCo.tcAcct <> ? then
assign tAccountDefaultMasterInterCo.tc_Status = "N":U.
/* Otherwise - do nothing */
else
delete tAccountDefaultMasterInterCo.
end.
end.
end.
find first tAccountDefaultMasterInterCo no-error.
if available tAccountDefaultMasterInterCo
then do:
/* ======================= */
/* Updates towards MfgPro */
/* ======================= */
if viBMfgAccountDefaultMaster1ID = 0 or
viBMfgAccountDefaultMaster1ID = ?
then do:
<I-34 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "TRUE"
&CLASS = "BMfgAccountDefaultMaster"}>
end. /* if viBMfgCostCenterFromFinID = 0 or viBMfgCostCenterFromFinID = ? */
else do:
<I-35 {bFcOpenInstance
&CLASS = "BMfgAccountDefaultMaster"}>
end. /* Not if viBMfgCostCenterFromFinID = 0 or viBMfgCostCenterFromFinID = ? */
<M-37 run MaintainData
(input tAccountDefaultMasterInterCo (tAccountDefaultMaster),
output viLocalReturnStatus (oiReturnStatus)) in BMfgAccountDefaultMaster>
<I-36 {bFcCloseInstance
&CLASS = "BMfgAccountDefaultMaster"}>
if viLocalReturnStatus <> 0 then assign oiReturnStatus = viLocalReturnStatus.
if viLocalReturnStatus < 0
then do :
<M-38 run StopExternalInstances
(output oiReturnStatus (oiReturnStatus)) in BCompanyProperty>
Return.
end. /* if viLocalReturnStatus < 0 */
end. /* available tAccountDefaultMasterInterCo */
if vlAccountDefaultMasterPrimStart
then do:
<Q-33 run AccountDefaultMasterByPrimKey
(Stop) in BMfgAccountDefaultMaster >
assign vlAccountDefaultMasterPrimStart = no.
end.
assign oiReturnStatus = viLocalReturnStatus.