| opPrimeKey | output | longchar | Primary Key field value of loaded record(s). Keys are chr(4) separated. Key fields are chr(2) separated. |
| oiReturnStatus | output | integer | Return status of the method. |
/* ================================================================================================================== */
/* Call method that extends the tApi-tables with some defaults to ease the integration */
/* Note that this method DataLoadByInput works withe the t_s-tables while the called method works on the tApi-tables */
/* As such we have to copy the t_s-tables to the tApi-tables before the call and the other ways around after the call */
/* ================================================================================================================== */
if vcActivityCode = "" or
vcActivityCode = ?
then assign vcActivityCode = "ExternalCreate".
temp-table tApiPosting:handle:copy-temp-table (temp-table t_sPosting:handle).
temp-table tApiPostingLine:handle:copy-temp-table (temp-table t_sPostingLine:handle).
temp-table tApiPostingSaf:handle:copy-temp-table (temp-table t_sPostingSaf:handle).
temp-table tApiPostingVat:handle:copy-temp-table (temp-table t_sPostingVat:handle).
temp-table tApiPostingVatDelay:handle:copy-temp-table (temp-table t_sPostingVatDelay:handle).
<M-95 run ApiStdMaintainTTInitialDefaulting (output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
temp-table t_sPosting:handle:copy-temp-table (temp-table tApiPosting:handle).
temp-table t_sPostingLine:handle:copy-temp-table (temp-table tApiPostingLine:handle).
temp-table t_sPostingSaf:handle:copy-temp-table (temp-table tApiPostingSaf:handle).
temp-table t_sPostingVat:handle:copy-temp-table (temp-table tApiPostingVat:handle).
temp-table t_sPostingVatDelay:handle:copy-temp-table (temp-table tApiPostingVatDelay:handle).
/* Exception Handling */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* Go through all postings in the input in order of their tc_rowid */
PROCESSBLOCKDATALOADBYINPUT:
for each t_sPosting :
/* Reset some data-item */
assign viDataLoadReturnStatus = 0.
/* When we are not in Create-mode then Load the posting based on its logical key */
if vcActivityCode <> "Create":U and
vcActivityCode <> "ExternalCreate":U
then do:
/* fill company_id when blank */
if t_sPosting.Company_ID = 0 or
t_sPosting.Company_ID = ?
then assign t_sPosting.Company_ID = viCompanyId.
/* Retrieve the Journal_ID to use in the freeform */
<Q-15 run JournalPrim (all) (Read) (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPosting.tcJournalCode, (JournalCode)
input ?, (JournalID)
output dataset tqJournalPrim) in BJournal >
find tqJournalPrim where
tqJournalPrim.tcJournalCode = t_sPosting.tcJournalCode
no-error.
if available tqJournalPrim
then t_sPosting.Journal_ID = tqJournalPrim.tiJournal_ID.
/* Try to Load the posting */
assign vcFreeform = "for each Posting where Posting.Company_ID = ":U + string(t_sPosting.Company_ID) +
" and Posting.PostingYear = ":U + string(t_sPosting.PostingYear) +
" and Posting.Journal_ID = ":U + string(t_sPosting.Journal_ID) +
" and Posting.PostingVoucher = ":U + string(t_sPosting.PostingVoucher).
<M-17 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input vcFreeform (icFreeform),
input true (ilKeepPrevious),
output viDataLoadReturnStatus (oiReturnStatus)) in BPosting>
/* ============================================================================================================================= */
/* if the DataLoad returned -4 and the activity is Delete, then just delete the t_sPosting and continue with the next t_sPosting */
/* if the DataLoad returned -4 and the activity is Modify, then raise an error */
/* else, if the DataLoad returned -4 then we do not log this error and we just act as if the acitivity was Create */
/* ============================================================================================================================= */
if viDataLoadReturnStatus = -4
then do :
if vcActivityCode = "Delete":U
then do :
delete t_sPosting.
next.
end. /* if vcActivityCode = "Delete":U */
else do :
if vcActivityCode = "Modify":U
then do:
assign vcMessage = trim(#T-38'Unable to find Posting.':255(71306)T-38#) + chr(10) +
trim(substitute(#T-39'Company-ID: &1':255(999890489)T-39#, trim(string(t_sPosting.Company_ID)) )) + chr(10) +
trim(substitute(#T-40'Accounting Year: &1':255(71307)T-40#, trim(string(t_sPosting.PostingYear)) )) + chr(10) +
trim(substitute(#T-41'Daybook code: &1':222(31365)T-41#, trim(t_sPosting.tcJournalCode) )) + chr(10) +
trim(substitute(#T-42'Voucher: &1':200(71308)T-42#, trim(string(t_sPosting.PostingVoucher)) )).
if viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
<M-37 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 't_sPosting.PostingVoucher':U (icFieldName),
input t_sPosting.PostingVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-9123':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
Leave PROCESSBLOCKDATALOADBYINPUT.
end. /* if vcActivityCode = Modify */
end. /* Not if vcActivityCode = "Delete":U */
end. /* if viDataLoadReturnStatus = -4 */
else do :
if viDataLoadReturnStatus <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viDataLoadReturnStatus.
if viDataLoadReturnStatus < 0
then Leave PROCESSBLOCKDATALOADBYINPUT.
end. /* Not if viDataLoadReturnStatus = -4 */
find first tPosting where
tPosting.Company_ID = t_sPosting.Company_ID and
tPosting.PostingYear = t_sPosting.PostingYear and
tPosting.Journal_ID = t_sPosting.Journal_ID and
tPosting.PostingVoucher = t_sPosting.PostingVoucher
no-error.
if not available tPosting and
(vcActivityCode = "Modify":U or
vcActivityCode = "Delete":U)
then do :
assign vcMessage = trim(#T-44'Unable to find Posting.':255(71306)T-44#) + chr(10) +
trim(substitute(#T-45'Company-ID: &1':255(999890489)T-45#, trim(string(t_sPosting.Company_ID)) )) + chr(10) +
trim(substitute(#T-46'Accounting Year: &1':255(71307)T-46#, trim(string(t_sPosting.PostingYear)) )) + chr(10) +
trim(substitute(#T-47'Daybook code: &1':222(31365)T-47#, trim(t_sPosting.tcJournalCode) )) + chr(10) +
trim(substitute(#T-48'Voucher: &1':200(71308)T-48#, trim(string(t_sPosting.PostingVoucher)) )).
if viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
<M-43 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 't_sPosting.PostingVoucher':U (icFieldName),
input t_sPosting.PostingVoucher (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-9124':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave PROCESSBLOCKDATALOADBYINPUT.
end. /* if not available tPosting */
end. /* if vcActivityCode <> "Create":U and */
/* ==================================================================================== */
/* When in delete mode: */
/* - If dataload returned -4 then just delete the t_sPosting record (handled before) */
/* - If dataload returned no error then just mark it as deleted */
/* In all cases of delete: go the next t_sPosting after this block */
/* ==================================================================================== */
if vcActivityCode = "Delete":U
then do:
<M-50 run SetRowidConvert
(input t_sPosting.tc_Rowid (icOldRowid),
input tPosting.tc_Rowid (icNewRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPosting.tc_Rowid = tPosting.tc_Rowid
t_sPosting.tc_ParentRowid = "":U
t_sPosting.tc_Status = "D":U
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tPosting.Posting_ID).
next.
end. /* if vcActivityCode = Delete */
/* ============================================================================== */
/* Block for the create-activity and for case of modify where the DataLoad could */
/* not read the posting from the db (we will act like create create in that case) */
/* ============================================================================== */
if vcActivityCode = "ExternalCreate":U or
vcActivityCode = "Create":U or
viDataLoadReturnStatus = -4
then do:
/* When object not found or in create mode, create it. */
<M-5 run AddDetailLine
(input 'Posting':U (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
/* Update input to allow correct matching */
assign t_sPosting.tc_Status = "N":U.
end. /* if vcActivityCode = Create */
else assign t_sPosting.tc_Status = "C":U.
/* ================================================================================================================================= */
/* Assign the ID in the input record with the ID of the loaded-created record */
/* Note: In case of Excel-integration activities we here accept the Posting_ID of the input and use that in the real New Postings */
/* The functional reason for this is that once the ExcelSheet has been uploaded in the UI, the UI calls a business-method */
/* on this class that returns a list of Posting_IDs and then the UI replaces the Posting_IDs in the grid with the Posting_IDs */
/* that were returned by the business-method. */
/* The reason for this construction is that once the ExcelSheet has been loaded into the grid users can add attachments and */
/* the link between the Posting in the grid and these attachements is the Posting_ID. As such, at that moment it is needed */
/* that the UI alsready has got the final Posting_ID that will also go into the database */
/* ================================================================================================================================= */
if t_sPosting.tc_Status = "N":U and
t_sPosting.Posting_ID <> 0 and
t_sPosting.Posting_ID <> ? and
(vcActivityCode = "JournalEntryExcelIntegrationRepair":U or vcActivityCode = "ExcelIntegration ":U)
then assign tPosting.Posting_ID = t_sPosting.Posting_ID.
else assign t_sPosting.Posting_ID = tPosting.Posting_ID.
/* Code for PostingLines */
for each tPostingLine where
tPostingLine.tc_ParentRowid = tPosting.tc_Rowid:
assign tPostingLine.tc_Status = "D":U.
end. /* for each tPostingLine where */
for each t_sPostingLine where
t_sPostingLine.tc_ParentRowid = t_sPosting.tc_Rowid and
t_sPostingLine.tc_Status <> "D":U:
assign t_sPostingLine.Posting_ID = t_sPosting.Posting_ID.
find first tPostingLine where
tPostingLine.tc_ParentRowid = tPosting.tc_Rowid and
tPostingLine.PostingLineSequence = t_sPostingLine.PostingLineSequence
no-error.
if available tPostingLine
then do :
if tPostingLine.tc_Status = "D":U
then assign t_sPostingLine.tc_Status = "C":U
tPostingLine.tc_Status = "C":U.
else do:
assign vcMsgExplanation = <M-70 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(#T-29'Duplicate posting line sequence in input.':255(999890336)T-29#).
if viLocalReturnStatus >= 0
then assign viLocalReturnStatus = -3.
<M-28 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.PostingLineSequence' (icFieldName),
input string(t_sPostingLine.PostingLineSequence) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-9038':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave PROCESSBLOCKDATALOADBYINPUT.
end. /* Not if tPostingLine.tc_Status = "D":U */
end. /* if avail tPostingLine */
else do:
<M-7 run AddDetailLine
(input 'PostingLine':U (icTable),
input tPosting.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPostingLine.tc_Status = "N":U
tPostingLine.PostingLineSequence = t_sPostingLine.PostingLineSequence.
end. /* Not if avail tPostingLine */
assign t_sPostingLine.PostingLine_ID = tPostingLine.PostingLine_ID
t_sPostingLine.tlLinkedCrCyDaemonReqExists = false.
/* Code for PostingSaf */
for each tPostingSaf where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid:
assign tPostingSaf.tc_Status = "D":U.
end. /* for each tPostingSaf where */
if not can-find (first t_sPostingSaf where
t_sPostingSaf.tc_ParentRowid = t_sPostingLine.tc_Rowid)
then do :
/* Call method that will create the default safs */
<M-30 run DataLoadByInputSafDefaulting
(input-output vlQStartedGetSafConceptsForStr (blQStartedGetSafConceptsForStr),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
end. /* if not can-find (first t_sPostingSaf where */
else do :
for each t_sPostingSaf where
t_sPostingSaf.tc_ParentRowid = t_sPostingLine.tc_Rowid and
t_sPostingSaf.tc_Status <> "D":U:
find first tPostingSaf where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid and
tPostingSaf.PostingSafParentType = t_sPostingSaf.PostingSafParentType and
tPostingSaf.PostingSafInputSequence = t_sPostingSaf.PostingSafInputSequence
no-error.
if available tPostingSaf
then assign t_sPostingSaf.tc_Status = "C":U.
else do:
<M-23 run AddDetailLine
(input 'PostingSaf':U (icTable),
input tPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPostingSaf.tc_Status = "N":U.
end. /* else do: */
<M-51 run SetRowidConvert
(input t_sPostingSaf.tc_Rowid (icOldRowid),
input tPostingSaf.tc_Rowid (icNewRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPostingSaf.PostingSaf_ID = tPostingSaf.PostingSaf_ID
t_sPostingSaf.Posting_ID = tPostingSaf.Posting_ID
t_sPostingSaf.tc_Rowid = tPostingSaf.tc_Rowid
t_sPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid.
end. /* for each t_sPostingSaf */
end. /* Not if not can-find (first t_sPostingSaf where */
/* Code for PostingVat */
for each tPostingVat where
tPostingVat.tc_ParentRowid = tPosting.tc_Rowid:
assign tPostingVat.tc_Status = "D":U.
end. /* for each tPostingVat where */
for each t_sPostingVat where
t_sPostingVat.tc_ParentRowid = t_sPostingLine.tc_Rowid and
t_sPostingVat.tc_Status <> "D":U:
find first tPostingVat where
tPostingVat.tc_ParentRowid = tPostingLine.tc_Rowid
no-error.
if available tPostingVat
then assign t_sPostingVat.tc_Status = "C":U.
else do:
<M-26 run AddDetailLine
(input 'PostingVat':U (icTable),
input tPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
<M-77 run DataLoadByInputVatRule
(input-output vlQStartedVatRuleByVatIDCode (blQStartedVatRuleByVatIDCode),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPostingVat.tc_Status = "N":U.
end. /* else do: */
<M-52 run SetRowidConvert
(input t_sPostingVat.tc_Rowid (icOldRowid),
input tPostingVat.tc_Rowid (icNewRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPostingVat.PostingVat_ID = tPostingVat.PostingVat_ID
t_sPostingVat.Posting_ID = tPostingVat.Posting_ID
t_sPostingVat.tc_Rowid = tPostingVat.tc_Rowid
t_sPostingVat.tc_ParentRowid = tPostingLine.tc_Rowid.
end. /* for each t_sPostingVat */
/* Code for PostingVatDelay */
for each tPostingVatDelay where
tPostingVatDelay.tc_ParentRowid = tPostingLine.tc_Rowid:
assign tPostingVatDelay.tc_Status = "D":U.
end. /* for each tPostingVatDelay where */
for each t_sPostingVatDelay where
t_sPostingVatDelay.tc_ParentRowid = t_sPostingLine.tc_Rowid and
t_sPostingVatDelay.tc_Status <> "D":U:
find first tPostingVatDelay where
tPostingVatDelay.tc_ParentRowid = tPostingLine.tc_Rowid
no-error.
if available tPostingVatDelay
then assign t_sPostingVatDelay.tc_Status = "C":U.
else do:
<M-27 run AddDetailLine
(input 'PostingVatDelay':U (icTable),
input tPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPostingVatDelay.tc_Status = "N":U.
end. /* else do: */
<M-53 run SetRowidConvert
(input t_sPostingVatDelay.tc_Rowid (icOldRowid),
input tPostingVatDelay.tc_Rowid (icNewRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPostingVatDelay.PostingVatDelay_ID = tPostingVatDelay.PostingVatDelay_ID
t_sPostingVatDelay.Posting_ID = tPostingVatDelay.Posting_ID
t_sPostingVatDelay.tc_Rowid = tPostingVatDelay.tc_Rowid
t_sPostingVatDelay.tc_ParentRowid = tPostingLine.tc_Rowid.
end. /* for each t_sPostingVatDelay */
/* Override value for identity fields in input (PostingLine) */
/* Update input to allow correct matching */
<M-54 run SetRowidConvert
(input t_sPostingLine.tc_Rowid (icOldRowid),
input tPostingLine.tc_Rowid (icNewRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPostingLine.PostingLine_ID = tPostingLine.PostingLine_ID
t_sPostingLine.Posting_ID = tPostingLine.Posting_ID
t_sPostingLine.tc_Rowid = tPostingLine.tc_Rowid
t_sPostingLine.tc_ParentRowid = tPosting.tc_Rowid.
end. /* for each t_sPostingLine */
/* Get a new Voucher if empty */
if t_sPosting.PostingVoucher = 0 or
t_sPosting.PostingVoucher = ?
then do:
<M-13 run GetPostingNumber
(input tPosting.tc_Rowid (ictcRowid),
input t_sPosting.PostingYear (iiYear),
input t_sPosting.tcJournalCode (icJournalCode),
output t_sPosting.PostingVoucher (oiVoucher),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
end. /* if tPosting.PostingVoucher = 0 */
/* Override value for identity fields in input (Posting) */
<M-55 run SetRowidConvert
(input t_sPosting.tc_Rowid (icOldRowid),
input tPosting.tc_Rowid (icNewRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave PROCESSBLOCKDATALOADBYINPUT.
assign t_sPosting.Posting_ID = tPosting.Posting_ID
t_sPosting.Company_ID = tPosting.Company_ID
t_sPosting.PostingVerifyStatus = 'INITIAL':U
t_sPosting.PostingApproveStatus = 'INITIAL':U
t_sPosting.CreatorUsr_ID = viUsrId
t_sPosting.tcUsrLogin = vcUserLogin
t_sPosting.tc_Rowid = tPosting.tc_Rowid
t_sPosting.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = ""
then ""
else opPrimeKey + chr(4)) +
string(tPosting.Posting_ID).
/* we overwrite any given value by today's date */
if tPosting.tc_Status = 'N'
then assign t_sPosting.PostingSystemDate = today.
END. /* PROCESSBLOCKDATALOADBYINPUT */
/* Exception hanlding */
assign oiReturnStatus = viLocalReturnStatus.