on 09-16-2008 9:20 PM
If I add the Journal entry without the line
journalEntries.Lines.ContraAccount
B1 inserts automatically the first account found on the entry as ContraAccount. But for my purpose, it has to be empty.
But "journalEntries.Lines.ContraAccount = string.Empty" has no effect.
Has anybody a solution?
Hallo Owen
It worked like you proposed. Thanks for your professional help.
Josef
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hallo Owen
Thanks for the solution. The problem I have is to get the sbo TransID. Could you tell me, how to get the TransId?
I am writing the journal entry like
journalEntries.Add()
At this moment, I asume, that sbo is assigning the TransId.
Josef
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Josef,
The Company object in the DI API has a method called GetNewObjectCode which can be used to return the key value of the last object created in this instance of the DI API. In the case of a Journal Entry, the key value will be the TransId value. Therefore, your whole solution would go something like:
1) Create an instance of the JournalEntries object, set its properties and add it to SBO.
2) Call the GetNewObjectCode method to retrieve the new journal number
3) Call the GetByKey method of the JournalEntries object, passing the key you got in step 2
4) Set all the ContraAccount properties to empty (as per the code above)
5) Call update on the JournalEntries object
Kind Regards,
Owen
Hi Josef,
If you leave the ContraAccount field blank when you create the journal, the DI API will automatically populate this field and set it to the first account in the journal lines. This is by design and mimics the logic in the user interface.
The ContraAccount field is one of the few fields you can update after a journal has been added. Therefore, you should be able to retrieve the journal using the DI API, after it has been added, and then set all the ContraAccount values to blank.
SAPbobsCOM.JournalEntries sboJournal = (SAPbobsCOM.JournalEntries)_sboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries);
if (sboJournal.GetByKey(iJournalNum))
{
for (int i = 0; i < sboJournal.Lines.Count; i++)
{
sboJournal.Lines.SetCurrentLine(i);
sboJournal.Lines.ContraAccount = "";
}
if (sboJournal.Update() != 0)
{
_sboApp.SetStatusBarMessage("Error: " + _sboCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, true);
}
}
Kind Regards,
Owen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
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.