Hello experts
I face an error when I need to update TMP table
Cannot select a record in Trial balance (LedgerTrialBalanceListPageTmp). Cannot select a record for update when the transaction is not started on the user connection attached. You need to begin transaction on the user connection first.
My full code is
[SysEntryPointAttribute(false)] public void processReport() { CustInvoiceJour jour,custJour; CustInvoiceTrans trans; TransDate fromDate,toDate; ZMLTrialBalanceContract contract = new ZMLTrialBalanceContract(); LedgerTrialBalanceDP trialBalanceDP = new LedgerTrialBalanceDP(); LedgerTrialBalanceContract trialBalanceContract = new LedgerTrialBalanceContract(); //LedgerTrialBalanceTmp trialBalanceTmp; DimensionHierarchy dimHier; UserConnection userConn; contract = this.parmDataContract(); fromDate = contract.parmFromDate(); toDate = contract.parmToDate(); ttsBegin; dimHier = DimensionHierarchy::getMainAccountFocus(); //DimensionFocusUpdateBalance::updateBalance( //DimensionHierarchy::findByTypeAndName(DimensionHierarchyType::Focus, dimHier.Name),true); userConn = new UserConnection(); trialBalanceTmp.setConnection(userConn); _tmp.setConnection(userConn); trialBalanceContract.parmDetailSummary(DetailSummary::Summary); trialBalanceContract.parmFromDate(fromDate); trialBalanceContract.parmToDate(toDate); trialBalanceContract.parmIncludeOpening(False); trialBalanceContract.parmIncludeClosing(False); trialBalanceContract.parmOperationsTax(OperationsTax::Current); //trialBalanceContract.parmPrimaryDimensionFocus(dimHier.Name);//Arafa trialBalanceContract.parmPrimaryDimensionFocus("03"); trialBalanceDP.parmDataContract(trialBalanceContract); trialBalanceDP.parmUserConnection(userConn); trialBalanceDP.processReport(); _tmp.recordLevelSecurity(false); trialBalanceTmp = trialBalanceDP.getLedgerTrialBalanceTmp(); insert_recordset _tmp ( PrimaryFocus, LedgerDimension, OpeningBalance, AmountDebit, AmountCredit, ClosingBalance, EndingBalance, Description, DimensionValues) select PrimaryFocus, LedgerDimension, OpeningBalance, AmountDebit, AmountCredit, ClosingBalance, EndingBalance, PrimaryFocusDescription, DimensionValues from trialBalanceTmp; ttsCommit; ttsBegin; while select forUpdate _tmp { _tmp.MainAccountId = MainAccount::findByLedgerDimension(_tmp.LedgerDimension).MainAccountId; _tmp.update(); } ttsCommit; _tmp.recordLevelSecurity(true); }
[SRSReportDataSetAttribute(tableStr(LedgerTrialBalanceListPageTmp))] public LedgerTrialBalanceListPageTmp getTmpData() { select _Tmp; return _Tmp; }
The error happend when I add the while select forupdate , if I removed it the report view the data without any problem
Thanks all