Description
This method will load the postings that need to be dumped and dump them in a XML file.
Parameters
icDumpFile | input | character | |
icConsolCompany | input | character | |
idCCExchangeRate | input | decimal | |
idCCExchangeRateScale | input | decimal | |
icCCCurrencyCode | input | character | |
bcGLIDList | input-output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bjournalentry.p)
If oiReturnStatus = 0
Then Assign oiReturnStatus = -98.
Assign bcGLIDList = Replace(bcGLIDList,Chr(4),',':U).
Assign viDecimals = integer(entry(lookup(icCCCurrencyCode,
vcCurrencyDecimalsList) + 1,
vcCurrencyDecimalsList)) No-error.
/*Start queries*/
<Q-11 run GLByGLType (Start) in BGL >
For Each tPosting:
Assign
tPosting.PeriodMark_ID = 0
tPosting.Company_ID = 0.
Assign
vdPostingLineDebitLC = 0
vdPostingLineCreditLC = 0
vdPostingLineDebitTC = 0
vdPostingLineCreditTC = 0.
For Each tPostingLine Where
tPostingLine.tc_ParentRowid = tPosting.tc_Rowid:
Assign
tPostingLine.PostingLineDebitLC = <M-31 RoundAmount
(input tPostingLine.PostingLineDebitLC * idCCExchangeRate * idCCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>
tPostingLine.PostingLineCreditLC = <M-32 RoundAmount
(input tPostingLine.PostingLineCreditLC * idCCExchangeRate * idCCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>
tPostingLine.PostingLineRateScale = 1
tPostingLine.PostingLineMaster_ID = 0
tPostingLine.Company_ID = 0
tPostingLine.CrossCompany_ID = 0
tPostingLine.CrossCompanyPosting_ID = 0
tPostingLine.CrossCompanyPostingLine_ID = 0
tPostingLine.tlLinkedCrCyDaemonReqExists = false.
.
Assign vdExchangeRate = 1.
If tPostingLine.PostingLineDebitTC <> 0
Then Assign vdExchangeRate = tPostingLine.PostingLineDebitLC / tPostingLine.PostingLineDebitTC.
Else If tPostingLine.PostingLineCreditTC <> 0
Then Assign vdExchangeRate = tPostingLine.PostingLineCreditLC / tPostingLine.PostingLineCreditTC.
If vdExchangeRate = 0
Then Assign vdExchangeRate = 1.
Assign tPostingLine.PostingLineExchangeRate = vdExchangeRate.
<Q-12 run GLByGLType (all) (Read) (NoCache)
(input tPosting.Company_ID, (CompanyId)
input tPostingLine.GL_ID, (GLId)
input ?, (GLCode)
input ?, (GLTypeCode)
input ?, (GLIsDivisionAccount)
output dataset tqGLByGLType) in BGL >
Find First tqGLByGLType No-error.
If Not Available tqGLByGLType Then Next.
Case tqGLByGLType.tcGLTypeCode:
When {&GLTYPECODE-CRED}
Then Do:
<Q-13 run CInvoiceByPostingID (all) (Read) (NoCache)
(input tPosting.Posting_ID, (PostingID)
input tPosting.Company_ID, (CompanyId)
output dataset tqCInvoiceByPostingID) in BCInvoice >
Find First tqCInvoiceByPostingID No-lock No-error.
If Available tqCInvoiceByPostingID
Then Assign tPostingLine.PostingLineText = tqCInvoiceByPostingID.tcCInvoiceType + '/':U +
tqCInvoiceByPostingID.tcCreditorCode + '/':U +
tqCInvoiceByPostingID.tcCurrencyCode + '/':U +
tqCInvoiceByPostingID.tcBusinessRelationCode + '/':U +
tqCInvoiceByPostingID.tcVatNumberIdentity + '/':U +
String(tqCInvoiceByPostingID.tiPeriodYearPeriod) + '/':U +
tqCInvoiceByPostingID.tcJournalCode + '/':U +
String(tqCInvoiceByPostingID.tiCInvoiceVoucher) + '/':U +
tqCInvoiceByPostingID.tcCInvoiceReference.
End.
When {&GLTYPECODE-DEBT}
Then Do:
<Q-14 run DInvoiceByPostingID (all) (Read) (NoCache)
(input tPosting.Posting_ID, (PostingID)
input tPosting.Company_ID, (CompanyId)
output dataset tqDInvoiceByPostingID) in BDInvoice >
Find First tqDInvoiceByPostingID No-lock No-error.
If Available tqDInvoiceByPostingID
Then Assign tPostingLine.PostingLineText = tqDInvoiceByPostingID.tcDInvoiceType + '/':U +
tqDInvoiceByPostingID.tcDebtorCode + '/':U +
tqDInvoiceByPostingID.tcCurrencyCode + '/':U +
tqDInvoiceByPostingID.tcBusinessRelationCode + '/':U +
tqDInvoiceByPostingID.tcVatNumberIdentity + '/':U +
String(tqDInvoiceByPostingID.tiDInvoicePostingYearPeriod) + '/':U +
tqDInvoiceByPostingID.tcJournalCode + '/':U +
String(tqDInvoiceByPostingID.tiDInvoiceVoucher) + '/':U +
tqDInvoiceByPostingID.tcDInvoiceDescription.
End.
When {&GLTYPECODE-BANK}
Then Do:
<Q-15 run BankNumberByParentNumberExt (all) (Read) (NoCache)
(input tPostingLine.GL_ID, (ParentObjectID)
input ?, (BankNumber)
input ?, (BankNumberExtension)
output dataset tqBankNumberByParentNumberExt) in BBankNumber >
Find First tqBankNumberByParentNumberExt No-lock No-error.
If Available tqBankNumberByParentNumberExt
Then Assign tPostingLine.PostingLineText = tqBankNumberByParentNumberExt.tcBankNumber + '/':U +
tqBankNumberByParentNumberExt.tcBankNumberExtension + '/':U +
tqBankNumberByParentNumberExt.tcBankNumberValidation.
End.
When {&GLTYPECODE-VAT}
Then Do:
Find First tPostingVat Where
tPostingVat.tc_ParentRowid = tPostingLine.tc_Rowid No-lock No-error.
If Available tPostingVat
Then Do:
<Q-16 run VatByAllFields (all) (Read) (NoCache)
(input tPostingVat.Vat_ID, (VatId)
input ?, (VatCode)
input ?, (VatDeliveryType)
input ?, (VatPercentageLevel)
input ?, (VatInOut)
input ?, (TransactionType)
input ?, (VatAVRCode)
input ?, (VatIsActive)
output dataset tqVatByAllFields) in BVAT >
Find First tqVatByAllFields No-lock No-error.
If Available tqVatByAllFields
Then Assign tPostingLine.PostingLineText = 'VAT/':U +
tqVatByAllFields.tcVatCode + '/':U +
tqVatByAllFields.tcVatPercentageLevel + '/':U +
String(tPostingVat.PostingVatBaseDebitTC - tPostingVat.PostingVatBaseCreditTC) + '/':U +
String(tPostingVat.tdTotalVatDebitTC - tPostingVat.tdTotalVatCreditTC).
End.
End.
When {&GLTYPECODE-DDOC}
Then Do:
<Q-17 run DDocumentByPostingLineID (all) (Read) (NoCache)
(input tPostingLine.PostingLine_ID, (PostingLineID)
input tPosting.Company_ID, (CompanyId)
output dataset tqDDocumentByPostingLineID) in BDDocument >
Find First tqDDocumentByPostingLineID No-lock No-error.
If Available tqDDocumentByPostingLineID
Then Assign tPostingLine.PostingLineText = tqDDocumentByPostingLineID.tcDDocumentType + '/':U +
tqDDocumentByPostingLineID.tcDebtorCode + '/':U +
tqDDocumentByPostingLineID.tcCurrencyCode + '/':U +
tqDDocumentByPostingLineID.tcBusinessRelationCode + '/':U +
String(tqDDocumentByPostingLineID.tiDDocumentYear) + '/':U +
String(tqDDocumentByPostingLineID.tiDDocumentNumber) + '/':U +
tqDDocumentByPostingLineID.tcDDocumentReference + '/':U +
tqDDocumentByPostingLineID.tcDDocumentStatus.
End.
When {&GLTYPECODE-CDOC}
Then Do:
<Q-18 run CDocumentByPostingLineID (all) (Read) (NoCache)
(input tPostingLine.PostingLine_ID, (PostingLineID)
input tPosting.Company_ID, (CompanyId)
output dataset tqCDocumentByPostingLineID) in BCDocument >
Find First tqCDocumentByPostingLineID No-lock No-error.
If Available tqCDocumentByPostingLineID
Then Assign tPostingLine.PostingLineText = tqCDocumentByPostingLineID.tcCDocumentType + '/':U +
tqCDocumentByPostingLineID.tcCreditorCode + '/':U +
tqCDocumentByPostingLineID.tcCurrencyCode + '/':U +
tqCDocumentByPostingLineID.tcBusinessRelationCode + '/':U +
String(tqCDocumentByPostingLineID.tiCDocumentYear) + '/':U +
String(tqCDocumentByPostingLineID.tiCDocumentNumber) + '/':U +
tqCDocumentByPostingLineID.tcCDocumentReference + '/':U +
tqCDocumentByPostingLineID.tcCDocumentStatus.
End.
When {&GLTYPECODE-CROSS}
Then Do:
<Q-19 run PostingPrim (all) (Read) (NoCache)
(input ?, (CompanyId)
input ?, (JournalCode)
input ?, (PeriodYear)
input ?, (PostingVoucher)
input tPostingLine.CrossCompanyPosting_ID, (PostingID)
output dataset tqPostingPrim) in BPosting >
Find First tqPostingPrim No-lock No-error.
If Available tqPostingPrim
Then Assign tPostingLine.PostingLineText = 'CrossCY/':U +
tPostingLine.tcCrossCompanyIntercoCode + '/':U +
tPostingLine.tcCrossCompanyCode + '/':U +
tPostingLine.tcIntercoBusinessRelationCode + '/':U +
String(tqPostingPrim.tiPostingAccYear) + '/':U +
String(tqPostingPrim.tiPostingPeriod) + '/':U +
tqPostingPrim.tcPostingJournalCode + '/':U +
String(tqPostingPrim.tiPostingVoucher).
End.
When {&GLTYPECODE-OPEN}
Then Do:
<Q-20 run GLOpenItemMovementByGLPosting (all) (Read) (NoCache)
(input ?, (GL_ID)
input tPostingLine.PostingLine_ID, (PostingLine_ID)
input tPosting.Company_ID, (CompanyId)
output dataset tqGLOpenItemMovementByGLPosting) in BGLOpenItem >
Find First tqGLOpenItemMovementByGLPosting No-lock No-error.
If Available tqGLOpenItemMovementByGLPosting
Then Assign tPostingLine.PostingLineText = 'GL O/I/':U +
tqGLOpenItemMovementByGLPosting.tcGLOpenItemKey + '/':U +
String(tqGLOpenItemMovementByGLPosting.tiPeriodYear) + '/':U +
String(tqGLOpenItemMovementByGLPosting.tiPeriodPeriod) + '/':U +
tqGLOpenItemMovementByGLPosting.tcJournalCode + '/':U +
String(tqGLOpenItemMovementByGLPosting.tiPostingVoucher).
Else Assign tPostingLine.PostingLineText = 'GL O/I/':U +
tPostingLine.tcAllocationKey + '/':U +
String(tPosting.PostingYear) + '/':U +
String(tPosting.PostingPeriod) + '/':U +
tPosting.tcJournalCode + '/':U +
String(tPosting.PostingVoucher).
End.
When {&GLTYPECODE-FASS}
Then Do:
<Q-21 run FACapitalByPostingLineID (all) (Read) (NoCache)
(input tPosting.Company_ID, (CompanyId)
input tPostingLine.PostingLine_ID, (PostingLineID)
output dataset tqFACapitalByPostingLineID) in BFixedAssetCapital >
Find First tqFACapitalByPostingLineID No-lock No-error.
If Available tqFACapitalByPostingLineID
Then Assign tPostingLine.PostingLineText = 'FACAP/':U +
tqFACapitalByPostingLineID.tcFAAssetCode + '/':U +
tqFACapitalByPostingLineID.tcFAAssetTypeCode + '/':U +
tqFACapitalByPostingLineID.tcFAAssetDescription + '/':U +
tqFACapitalByPostingLineID.tcFAAssetCatalogueValue2 + '/':U +
tqFACapitalByPostingLineID.tcFAAssetCatalogueValue3 + '/':U +
tqFACapitalByPostingLineID.tcFAAssetCatalogueValue4 + '/':U +
tqFACapitalByPostingLineID.tcFAAssetCatalogueValue5 + '/':U +
tqFACapitalByPostingLineID.tcFAAssetCatalogueValue6.
Else Do:
<Q-22 run FADepreciationByPostingID (all) (Read) (NoCache)
(input tPosting.Posting_ID, (PostingID)
input tPosting.Company_ID, (CompanyId)
output dataset tqFADepreciationByPostingID) in BFixedAssetDepreciation >
Find First tqFADepreciationByPostingID No-lock No-error.
If Available tqFADepreciationByPostingID
Then Assign tPostingLine.PostingLineText = 'FADEP':U +
tqFADepreciationByPostingID.tcFAAssetCode + '/':U +
tqFADepreciationByPostingID.tcFAAssetTypeCode + '/':U +
tqFADepreciationByPostingID.tcFAAssetDescription + '/':U +
tqFADepreciationByPostingID.tcFAAssetBookDeprType + '/':U +
tqFADepreciationByPostingID.tcFAAssetCatalogueValue2 + '/':U +
tqFADepreciationByPostingID.tcFAAssetCatalogueValue3 + '/':U +
tqFADepreciationByPostingID.tcFAAssetCatalogueValue4 + '/':U +
tqFADepreciationByPostingID.tcFAAssetCatalogueValue5 + '/':U +
tqFADepreciationByPostingID.tcFAAssetCatalogueValue6.
Else Do:
<Q-23 run FADisposalByPostingID (all) (Read) (NoCache)
(input tPosting.Posting_ID, (PostingID)
input tPosting.Company_ID, (CompanyId)
output dataset tqFADisposalByPostingID) in BFixedAssetDisposal >
Find First tqFADisposalByPostingID No-lock No-error.
If Available tqFADisposalByPostingID
Then Assign tPostingLine.PostingLineText = 'FADIS':U +
tqFADisposalByPostingID.tcFAAssetCode + '/':U +
tqFADisposalByPostingID.tcFAAssetTypeCode + '/':U +
tqFADisposalByPostingID.tcFAAssetDescription + '/':U +
tqFADisposalByPostingID.tcFAAssetBookDeprType + '/':U +
tqFADisposalByPostingID.tcFAAssetCatalogueValue2 + '/':U +
tqFADisposalByPostingID.tcFAAssetCatalogueValue3 + '/':U +
tqFADisposalByPostingID.tcFAAssetCatalogueValue4 + '/':U +
tqFADisposalByPostingID.tcFAAssetCatalogueValue5 + '/':U +
tqFADisposalByPostingID.tcFAAssetCatalogueValue6.
Else Do:
<Q-24 run FARevalPostingByPostingID (all) (Read) (NoCache)
(input tPosting.Posting_ID, (PostingID)
input tPosting.Company_ID, (CompanyId)
output dataset tqFARevalPostingByPostingID) in BFixedAssetRevaluation >
Find First tqFARevalPostingByPostingID No-lock No-error.
If Available tqFARevalPostingByPostingID
Then Assign tPostingLine.PostingLineText = 'FAREV':U +
tqFARevalPostingByPostingID.tcFAAssetCode + '/':U +
tqFARevalPostingByPostingID.tcFAAssetTypeCode + '/':U +
tqFARevalPostingByPostingID.tcFAAssetDescription + '/':U +
tqFARevalPostingByPostingID.tcFAAssetBookDeprType + '/':U +
tqFARevalPostingByPostingID.tcFAAssetCatalogueValue2 + '/':U +
tqFARevalPostingByPostingID.tcFAAssetCatalogueValue3 + '/':U +
tqFARevalPostingByPostingID.tcFAAssetCatalogueValue4 + '/':U +
tqFARevalPostingByPostingID.tcFAAssetCatalogueValue5 + '/':U +
tqFARevalPostingByPostingID.tcFAAssetCatalogueValue6.
End.
End.
End.
End.
End. /* Case tqGLByGLType.tcGLTypeCode: */
For Each tPostingVat Where
tPostingVat.tc_ParentRowid = tPostingLine.tc_Rowid:
Delete tPostingVat.
End.
For Each tPostingVatDelay Where
tPostingVatDelay.tc_ParentRowid = tPostingLine.tc_Rowid:
Delete tPostingVatDelay.
End.
Assign vdPostingLineDebitLC = vdPostingLineDebitLC + tPostingLine.PostingLineDebitLC.
Assign vdPostingLineCreditLC = vdPostingLineCreditLC + tPostingLine.PostingLineCreditLC.
Assign vdPostingLineDebitTC = vdPostingLineDebitTC + tPostingLine.PostingLineDebitTC.
Assign vdPostingLineCreditTC = vdPostingLineCreditTC + tPostingLine.PostingLineCreditTC.
If Not Can-do(bcGLIDList + ",0":U, String(tPostingLine.GL_ID))
Then Assign bcGLIDList = bcGLIDList + ',':U + String(tPostingLine.GL_ID).
Assign
tPostingLine.tcCrossCompanyCode = '':U
tPostingLine.tcCrossCompanyCurrencyCode = '':U
tPostingLine.tcCrossCompanyGLCode = '':U
tPostingLine.tcCrossCompanyIntercoCode = '':U
tPostingLine.PostingLineCreditCC = 0
tPostingLine.PostingLineDebitCC = 0.
End. /* For Each tPostingLine Of tPosting: */
If vdPostingLineDebitLC <> vdPostingLineCreditLC Or
vdPostingLineDebitTC <> vdPostingLineCreditTC
Then Do:
<M-26 run AddDetailLine (input 'PostingLine':U (icTable),
input tPosting.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
Assign
tPostingLine.PostingLineMaster_ID = 0
tPostingLine.Company_ID = 0
tPostingLine.CrossCompany_ID = 0
tPostingLine.CrossCompanyPosting_ID = 0
tPostingLine.CrossCompanyPostingLine_ID = 0
tPostingLine.tlLinkedCrCyDaemonReqExists = false.
<Q-27 run GLByGLSystemType (all) (Read) (NoCache)
(input tPosting.Company_ID, (CompanyId)
input {&GLSYSTEMTYPE-ROUND}, (GLSystemTypeCode)
input ?, (GlTypeCode)
input ?, (GlIsDivisionAccount)
output dataset tqGLByGLSystemType) in BGL >
Find First tqGLByGLSystemType No-lock No-error.
If Available tqGLByGLSystemType
Then do:
Assign
tPostingLine.GL_ID = tqGLByGLSystemType.tiGL_ID
tPostingLine.tcGLCode = tqGLByGLSystemType.tcGLCode
tPostingLine.tcGLTypeCode = tqGLByGLSystemType.tcGLTypeCode.
If vdPostingLineDebitLC - vdPostingLineCreditLC >= 0
Then Assign
tPostingLine.PostingLineDebitLC = 0
tPostingLine.PostingLineCreditLC = vdPostingLineDebitLC - vdPostingLineCreditLC.
Else Assign
tPostingLine.PostingLineCreditLC = 0
tPostingLine.PostingLineDebitLC = vdPostingLineCreditLC - vdPostingLineDebitLC.
If vdPostingLineDebitTC - vdPostingLineCreditTC >= 0
Then Assign
tPostingLine.PostingLineDebitTC = 0
tPostingLine.PostingLineCreditTC = vdPostingLineDebitTC - vdPostingLineCreditTC.
Else Assign
tPostingLine.PostingLineCreditTC = 0
tPostingLine.PostingLineDebitTC = vdPostingLineCreditTC - vdPostingLineDebitTC.
Assign
tPostingLine.PostingLineExchangeRate = 1
tPostingLine.PostingLineRateScale = 1
tPostingLine.tcCurrencyCode = icCCCurrencyCode.
End.
If Not Can-do(bcGLIDList + ",0":U, String(tPostingLine.GL_ID))
Then Assign bcGLIDList = bcGLIDList + ',':U + String(tPostingLine.GL_ID).
End.
Assign
tPosting.Posting_ID = 0.
End. /* For Each tPosting: */
Assign bcGLIDList = Replace(Trim(bcGLIDList,',':U),',':U,Chr(4)).
/*Stop queries*/
<Q-28 run GLByGLType (Stop) in BGL >
<M-29 run DumpXmlRepresentation
(input icDumpFile (icFile),
input no (ilHeaderOnly),
input no (ilSuppressEmptyFields),
input 0 (iiPriority),
input no (ilWriteXMLSchema),
input ? (icObjectRowId),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
create X-DOCUMENT vhDoc in widget-pool "non-persistent".
create X-NODEREF vhRoot in widget-pool "non-persistent".
create X-NODEREF vhNode in widget-pool "non-persistent".
create X-NODEREF vhNode2 in widget-pool "non-persistent".
create X-NODEREF vhValue in widget-pool "non-persistent".
vhDoc:load ("FILE":U, icDumpFile, no) no-error.
do viCnt = 1 to vhDoc:num-children:
vhDoc:get-child(vhRoot,viCnt).
if vhRoot:local-name = "object":U
Then Leave.
end.
do viCnt = 1 to vhRoot:num-children:
vhRoot:get-child(vhNode,viCnt).
if vhNode:local-name = "CompanyCode":U and
vhNode:num-children = 1
then do:
vhNode:get-child(vhValue,1).
if vhValue:name = "#text":U
then do:
vhValue:node-value = icConsolCompany.
End.
end.
if vhNode:local-name = "classRepresentation":U
Then Do:
vhDoc:create-node-namespace (vhNode2, "com.softcell.componentbuilder.class":U, "priority":U, "element":U).
vhNode2:namespace-prefix = "cb":U.
vhRoot:insert-before (vhNode2, vhNode).
vhDoc:CREATE-NODE (vhValue, "", "TEXT":U).
vhValue:NODE-VALUE = "220":U.
vhNode2:APPEND-CHILD (vhValue).
/*this is a must otherwise crash*/
Assign viCnt = viCnt + 1.
End.
end.
vhDoc:save ("file":U, icDumpFile) no-error.
delete object vhValue.
delete object vhNode2.
delete object vhNode.
delete object vhRoot.
delete object vhDoc.
<M-30 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
If oiReturnStatus = -98
Then Assign oiReturnStatus = 0.