2016-10-26 7 views
1

У меня возникли проблемы с классом AX2012 (класс AX2012 по умолчанию и код, никаких изменений не было сделано на нем): CustVendTransDetails в методе calcCashDiscountsЗамена EXISTS РЕГИСТРИРУЙТЕСЬ с РЕГИСТРИРУЙТЕСЬ

Следующий запрос дает мне ошибку The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns. :

if (TaxParameters::canApplyCashDiscOnInvoice_ES()) 
{ 
    insert_recordset tmpValue 
     (CustVendTransRefRecId, AmountMST) 
     select CustVendTransRefRecId 
     from _custVendAccountStatementIntTmpProcessing 

     exists join custVendTransLoc 
     where 
      custVendTransLoc.RecId == _custVendAccountStatementIntTmpProcessing.CustVendTransRefRecId 

     exists join firstOnly subledgerVoucherGeneralJournalEntry 
     where 
      subledgerVoucherGeneralJournalEntry.Voucher == custVendTransLoc.Voucher && 
      subledgerVoucherGeneralJournalEntry.AccountingDate == custVendTransLoc.TransDate 

     exists join generalJournalEntry 
     where 
      generalJournalEntry.RecId == subledgerVoucherGeneralJournalEntry.GeneralJournalEntry && 
      generalJournalEntry.Ledger == Ledger::current() 

     join AccountingCurrencyAmount from generalJournalAccountEntry 
     where 
      generalJournalAccountEntry.GeneralJournalEntry == generalJournalEntry.RecId && 
      (generalJournalAccountEntry.PostingType == LedgerPostingType::CustCashDisc || 
      generalJournalAccountEntry.PostingType == LedgerPostingType::VendCashDisc); 

    update_recordSet _custVendAccountStatementIntTmpProcessing setting 
     UtilizedCashDisc = tmpValue.AmountMST, 
     PossibleCashDisc = tmpValue.AmountMST 
     join tmpValue 
     where 
      tmpValue.CustVendTransRefRecId == _custVendAccountStatementIntTmpProcessing.CustVendTransRefRecId; 
} 

Я понимаю, почему, но я не уверен, как решить эту проблему. Будет ли проблема заменить exist join на нормальный join?

Замена exist join на join, действительно решает мою проблему, но я не уверен, какая разница в данных? Потому что это только выбор 1 поля?

ответ

2

Вы можете попытаться изменить порядок объединений:

insert_recordset tmpValue (CustVendTransRefRecId, AmountMST) 
    select CustVendTransRefRecId 
    from _custVendAccountStatementIntTmpProcessing 

    join AccountingCurrencyAmount from generalJournalAccountEntry // Moved up 
    where generalJournalAccountEntry.PostingType == LedgerPostingType::CustCashDisc || 
      generalJournalAccountEntry.PostingType == LedgerPostingType::VendCashDisc 

    exists join custVendTransLoc 
    where 
     custVendTransLoc.RecId == _custVendAccountStatementIntTmpProcessing.CustVendTransRefRecId 

    exists join firstOnly subledgerVoucherGeneralJournalEntry 
    where 
     subledgerVoucherGeneralJournalEntry.Voucher == custVendTransLoc.Voucher && 
     subledgerVoucherGeneralJournalEntry.AccountingDate == custVendTransLoc.TransDate 

    exists join generalJournalEntry 
    where 
     generalJournalEntry.RecId == subledgerVoucherGeneralJournalEntry.GeneralJournalEntry && && 
     generalJournalEntry.RecId == generalJournalAccountEntry.GeneralJournalEntry && // Moved from join 
     generalJournalEntry.Ledger == Ledger::current(); 
+0

Спасибо, это решить мою проблему. –

1

Замена существующего соединения с соединением не решит вашу проблему. Exist - это способ присоединиться к по существу внутреннему соединению к таблице, не возвращая никаких полей.

Запрос должен возвращать CustVendTransRefRecId из _custVendAccountStatementIntTmpProcessing и AccountingCurrencyAmount из generalJournalAccountEntry, который является именно тем, что ожидает вставка.

Я ожидаю, что запрос на самом деле ничего не возвращает. Проверьте критерии, которые он использует, и проверьте данные.