Description
Synchronization between UI and Business Component.
On the UI, the component's CashReportGLLine-records are presented as columns of CashReportGL.
This method creates, updates and deletes CashReportGLLines based on a temp-table that is created on the UI, representing the UI-columns.
Parameters
Internal usage
unused
program code (program4/bcashreport.p)
oiReturnStatus = -98.
for each tCashReport where
tCashReport.tc_Status <> 'D':U:
<M-3 run GenerateIntervalDates (input tCashReport.tiPeriodYear (iiPeriodYear),
input tCashReport.tiPeriodPeriod (iiPeriodPeriod),
input tCashReport.CashReportDaysInterval (iiDaysInterval),
input tCashReport.CashReportNumberOfPeriods (iiNumberOfPeriods),
output vcIntervalDates (ocIntervalDates),
output vtPeriodEndDate (otPeriodEndDate),
output viFcReturnSuper (oiReturnStatus)) in BCashReport>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
then do:
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
for each tCashReportGL where
tCashReportGL.tc_Status <> 'D':U and
tCashReportGL.tc_ParentRowid = tCashReport.tc_Rowid:
/*tCashReportGL.CashReportGLCurrencyView = tCashReport.CashReportCurrencyView and
tCashReportGL.Currency_ID = tCashReport.Currency_ID:*/
/* Delete CashReportGLLine records when no corresponding UI-record exists. */
/* Newly added records are effectively deleted while existing records get tc_Status 'D' */
for each tCashReportGLLine where
tCashReportGLLine.tc_Status <> 'D':U and
tCashReportGLLine.tc_ParentRowid = tCashReportGL.tc_Rowid and
tCashReportGLLine.CashReportGLLineCurrView = tCashReportGL.CashReportGLCurrencyView and
tCashReportGLLine.Currency_ID = tCashReportGL.Currency_ID:
find tUICashReportGLPerc where
tUICashReportGLPerc.tcUICashReportPerc_ParentRowid = tCashReportGLLine.tc_ParentRowid and
tUICashReportGLPerc.tiUICashReportPerc_Seq = tCashReportGLLine.CashReportGLLineSeq
no-lock no-error.
if not available(tUICashReportGLPerc)
then do:
if tCashReportGLLine.tc_Status = 'N':U
then delete tCashReportGLLine.
else assign tCashReportGLLine.tc_Status = 'D':U.
end.
end. /* for each tCashReportGLLine */
/* If no corresponding CashReportGLLine record exists for a UI-record, create it. */
/* If it does exist, update it. */
for each tUICashReportGLPerc where
tUICashReportGLPerc.tcUICashReportPerc_ParentRowid = tCashReportGL.tc_Rowid:
find tCashReportGLLine where
tCashReportGLLine.tc_ParentRowid = tUICashReportGLPerc.tcUICashReportPerc_ParentRowid and
tCashReportGLLine.CashReportGLLineSeq = tUICashReportGLPerc.tiUICashReportPerc_Seq and
tCashReportGLLine.CashReportGLLineCurrView = tCashReportGL.CashReportGLCurrencyView and
tCashReportGLLine.Currency_ID = tCashReportGL.Currency_ID
no-lock no-error.
if available(tCashReportGLLine)
then do:
/* This method is called with every Save action. */
/* --> Optimize database-updates : set tc_Status to 'C' for actual changes only. */
if (tCashReportGLLine.tc_Status <> 'N':U)
then do:
if (tCashReportGLLine.CashReportGLLinePerc <> tUICashReportGLPerc.tdUICashReportPerc_Perc or
tCashReportGLLine.CashReportGLLineDate <> Date(entry(tUICashReportGLPerc.tiUICashReportPerc_Seq, vcIntervalDates, chr(2))) )
then assign tCashReportGLLine.tc_Status = 'C':U.
end.
end.
else do:
<M-2 run AddDetailLine (input 'CashReportGLLine':U (icTable),
input tCashReportGL.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCashReport>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
then do:
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
assign tCashReportGLLine.CashReportGL_ID = tCashReportGL.CashReportGL_ID
tCashReportGLLine.CashReportGLLineSeq = tUICashReportGLPerc.tiUICashReportPerc_Seq.
end.
assign tCashReportGLLine.CashReportGLLinePerc = tUICashReportGLPerc.tdUICashReportPerc_Perc
tCashReportGLLine.CashReportGLLineDate = Date(entry(tUICashReportGLPerc.tiUICashReportPerc_Seq, vcIntervalDates, chr(2)))
tCashReportGLLine.CashReportGLLineCurrView = tCashReportGL.CashReportGLCurrencyView
tCashReportGLLine.Currency_ID = tCashReportGL.Currency_ID.
end. /* for each tUICashReportGLPerc */
end. /* for each tCashReportGL */
end. /* for each tCashReport */
if oiReturnStatus = -98
then oiReturnStatus = 0.