Public Sub CreateJournal() Try Dim AX As New Axapta Dim JnlLine As AxaptaObject Dim numberSeqFormHandlerLedgerJournal As AxaptaObject Dim LedgerJournalTable As AxaptaObject Dim LoopRow As Integer Dim CompanyName As String AX.Logon("", "", "", "") AX.TTSBegin() DataGridView1.ReadOnly = True LedgerJournalTable = AX.CreateAxaptaObject("AxLedgerJournalTable") numberSeqFormHandlerLedgerJournal = AX.CreateAxaptaObject("numberSeqFormHandlerLedgerJournal") LedgerJournalTable.Call("parmJournalName", Me.TxtJournalName.Text.ToString()) LedgerJournalTable.Call("parmJournalNum", Me.TxtJournalNumber.Text.ToString()) LedgerJournalTable.Call("parmVoucherSeries", Me.TxtVoucherSeries.Text.ToString()) LedgerJournalTable.Call("save") // till here it works fine, i.e. ....able to insert in LedgerJournalTable. // Just to test, inserting just one line and hard coded values JnlLine = AX.CreateAxaptaObject("AXLedgerJournalTrans") JnlLine.Call("parmJournalNum", "San1") JnlLine.Call("parmLineNum", 1) JnlLine.Call("parmAccountType", 1) JnlLine.Call("parmAccountNum", "605500") JnlLine.Call("parmAmountCurDebit", 800) JnlLine.Call("parmCurrencyCode", "USD") JnlLine.Call("parmVoucher", "V_0001") JnlLine.Call("parmAmountCurCredit", 0) JnlLine.Call("parmOffsetAccount", 131100) JnlLine.Call("parmOffsetAccountType", 1) JnlLine.Call("parmTransDate", Today()) JnlLine.Call("parmCompany", "dmo") JnlLine.Call("parmOffsetCompany", "dmo") JnlLine.Call("Save") DataGridView1.Rows.Clear() AX.TTSCommit() AX.Logoff() MessageBox.Show(" Uploaded....!! ") Catch ex As Exception MsgBox(ex.Message) // here I get the exception msg triggered after "JnlLine.Call("Save")" Error executing code : NumberSeqFormHandlerLedgerJournal Object not initialized End Try End Sub
Comments
Please refer to this article - http://msdn.microsoft.com/en-us/library/aa478710.aspx. Note this line -
numberSeq = NumberSeq::newGetVoucherFromCode(ledgerJournalName.VoucherSeries);
Hope this helps,
Long way to go before I sleep..