| tPostingForXLS | input-output | temp-table | Temp-table used for the Excel-integration so that at the moment an xls-sheet is loaded onto the grid, the Posting_ID gets set for the postings in the xls-sheet that do not yet exist in the FInancials-db or that already exist. The temp-table returns a value in field NewPostingID for every record in the temp-table based on the logical key of a posting. |
| oiReturnStatus | output | integer | Return status of the method. |
/* ================================================================================================================================= */
/* In case of Excel-integration activities we here retrun a list of Posting_IDs that will be used for the real Postings when saved */
/* The functional reason for this is that once the ExcelSheet has been uploaded in the UI, the UI calls this business-method that */
/* returns a list of Posting_IDs and then the UI replaces the Posting_IDs in the grid with the Posting_IDs that are returned by this */
/* 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 */
/* already has got the final Posting_ID that will also go into the database */
/* Also for existing postings that are modified via the ExcelIntegration function, we will return the existing Posting_ID for them */
/* ================================================================================================================================= */
/* Return in case nothing is needed */
if not can-find (first tPostingForXLS)
then return.
/* Start persistence and keep the handle */
<M-8 run StartPersistence
(output vhPersistenceHandle (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper < 0 or
(viFcReturnSuper <> 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
if not valid-handle (vhPersistenceHandle)
then do :
assign vcMessage = trim(substitute(#T-59'Internal error: Unable to access the persistence-layer from &1.':255(523751093)T-59#, "BPosting:GetRangeOfNewPostingIDs":U ))
oiReturnStatus = -3.
<M-51 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-890317':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
return.
end. /* if not valid-handle (vhPersistenceHandle) */
/* Loop through the input-output temp-table */
for each tPostingForXLS
on error undo, throw:
/* Set the Company_ID and Journal_ID when empty */
if tPostingForXLS.tiCompany_ID = 0 or
tPostingForXLS.tiCompany_ID = ?
then assign tPostingForXLS.tiCompany_ID = viCompanyID.
if tPostingForXLS.tcJournalCode <> "":U and
tPostingForXLS.tcJournalCode <> ? and
(tPostingForXLS.tiJournal_ID = 0 or
tPostingForXLS.tiJournal_ID = ?)
then do :
<Q-20 run JournalPrim (all) (Read) (Cache)
(input tPostingForXLS.tiCompany_ID, (CompanyId)
input tPostingForXLS.tcJournalCode, (JournalCode)
input ?, (JournalID)
output dataset tqJournalPrim) in BJournal>
Find tqJournalPrim where
tqJournalPrim.tcJournalCode = tPostingForXLS.tcJournalCode
no-lock no-error.
if available tqJournalPrim
then assign tPostingForXLS.tiJournal_ID = tqJournalPrim.tiJournal_ID.
end. /* if tPostingForXLS.tcJournalCode <> "":U and */
/* Try to read the posting from the db based on the logical key */
if tPostingForXLS.tiPostingYear <> 0 and
tPostingForXLS.tiPostingYear <> ? and
tPostingForXLS.tiJournal_ID <> 0 and
tPostingForXLS.tiJournal_ID <> ? and
tPostingForXLS.tiPostingVoucher <> 0 and
tPostingForXLS.tiPostingVoucher <> ?
then do :
<Q-94 run PostingByUniqueKey (all) (Read) (NoCache)
(input tPostingForXLS.tiCompany_ID, (CompanyId)
input tPostingForXLS.tiPostingYear, (PostingYear)
input tPostingForXLS.tiJournal_ID, (JournalID)
input tPostingForXLS.tiPostingVoucher, (PostingVoucher)
output dataset tqPostingByUniqueKey) in BPosting>
Find tqPostingByUniqueKey where
tqPostingByUniqueKey.tiCompany_ID = tPostingForXLS.tiCompany_ID and
tqPostingByUniqueKey.tiPostingYear = tPostingForXLS.tiPostingYear and
tqPostingByUniqueKey.tiJournal_ID = tPostingForXLS.tiJournal_ID and
tqPostingByUniqueKey.tiPostingVoucher = tPostingForXLS.tiPostingVoucher
no-lock no-error.
/* Actions are only required for Postings that do not yet exist */
if available tqPostingByUniqueKey
then do :
assign tPostingForXLS.tiNewPostingID = tqPostingByUniqueKey.tiPosting_ID.
next.
end. /* if available tqPostingByUniqueKey */
end. /* if tPostingForXLS.tiPostingYear <> 0 and */
/* Get a new IDs and store it in the input-output temp-table */
assign vhFcComponent = vhPersistenceHandle /* as GetNextValue is always executed in vhFcComponent */
tPostingForXLS.tiNewPostingID = <M-91 GetNextValue (input 'ObjectNumber':U (icSequence)) in persistence>.
end. /* for each tPostingForXLS : */