Skip to Content
0

Di Add-on update only first line

Mar 28, 2017 at 03:27 PM

56

avatar image
Former Member

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
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
ANKIT CHAUHAN
Mar 28, 2017 at 04:32 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded