on 03-28-2017 4:27 PM
Hello Experts,
i am trying to update the lines in a journal entry but i update only the first line. The code i am using is the following :
Dim oJournalEntry As SAPbobsCOM.JournalEntries
oJournalEntry = oCompany.GetBusinessObject(BoObjectTypes.oJournalEntries)
Dim rsGetJournal As SAPbobsCOM.Recordset
rsGetJournal = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
rsGetJournal.DoQuery("SELECT TransID FROM OJDT WHERE TransID='" & TransId & "' ")
rsGetJournal.MoveFirst()
While rsGetJournal.EoF = False
oJournalEntry.GetByKey(rsGetJournal.Fields.Item("TransID").Value.ToString)
oJournalEntry.UserFields.Fields.Item("U_Fldnl").Value = "Y"
Dim rsGetJournalLines As SAPbobsCOM.Recordset 'base table query
rsGetJournalLines = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
rsGetJournalLines.DoQuery("SELECT * FROM JDT1 WHERE TransID='" & TransId & "' ")
rsGetJournalLines.MoveFirst()
While rsGetJournalLines.EoF = False
oJournalEntry.Lines.UserFields.Fields.Item("U_Kca").Value = "BP"
rsGetJournalLines.MoveNext()
End While
lretcode = oJournalEntry.Update
Hi,
It is happening because you are not providing which line you would like to update. Here is a sample which can help you to understand it correctly:
SAPbobsCOM.JournalEntries oJE = (SAPbobsCOM.JournalEntries)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries);
oJE.Lines.SetCurrentLine(0);
oJE.Lines.UserFields.Fields.Item("U_TEST").Value = "TEST";
int Update = oJE.Update();
Kind regards,
ANKIT CHAUHAN
SAP SME Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
97 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.