cancel
Showing results for 
Search instead for 
Did you mean: 

DI Question (invoice)

former_member687054
Participant
0 Kudos

Hi,

How can we assign the property oInvoice.Lines.AccountCode ?

I try with the account code but I've got an error...

I also try with the _sysxxx number but it seems to be linked with the wrong gl account

Thank you for your help

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Looking at your code I think you are using segmentation in your chart of accounts. Is this is the case to set the account code you need to use the FormatCode to find the key:

1. Get the key using the GetObjectKeyBySingleValue method.

2. Use the returned recordset to retrieve the value of the key.

3. Use the value as the AccountCode.

Hope it helps

-M

former_member687054
Participant
0 Kudos

Hi,

I try it but I've got the same error as when I assign the _sysxxx number directly...

Here's the error,

Error -5002 OACT Account currency 1100-00-0-00 does not match the document currency

but the returned account (1100-00-0-00) is not the good one... it seems that the link between the account and the _sysxxx number is not good...

Former Member
0 Kudos

Hi Joderick,

Con you please copy the GetObjectKeyBySingleValue part of the code to have a look at it?

thanks

-M

former_member687054
Participant
0 Kudos

Hi Marco,

Here's the code, I've got it directly in the help file and changed the value for the account number...

Dim sStr As String

Dim vRs As SAPbobsCOM.Recordset

Dim vBOB As SAPbobsCOM.SBObob

vBOB = oUSCompany.GetBusinessObjec(BoObjectTypes.BoBridge)

vRs = vBOB.GetObjectKeyBySingleValue(BoObjectTypes.oChartOfAccounts, "FormatCode", "4110001000", BoQueryConditions.bqc_Equal)

If Not (vRs.BoF And vRs.EoF) Then

'The Recordset retrieves the value of the key (for example, sStr = _SYS00000000010).

sStr = vRs.Fields.Item(0).Value

oInvoice.Lines.AccountCode = vRs.Fields.Item(0).Value

End If

Is there something wrong ?

Thank You

Former Member
0 Kudos

Hi Joderick,

I found the following code in the help file that is a little different from yours:

Dim sStr As String

Dim vRs As SAPbobsCOM.Recordset

Dim vBOB As SAPbobsCOM.SBObob

Dim vCH As SAPbobsCOM.ChartOfAccounts

Set vCH = Vcmp.GetBusinessObject(oChartOfAccounts)

Set vBOB = Vcmp.GetBusinessObject(BoBridge)

Set vRs = Vcmp.GetBusinessObject(BoRecordset)

Set vRs = vBOB.GetObjectKeyBySingleValue(oBusinessPartners, "CardName", "aaa", bqc_Equal)

' When working with segmentation use this function

' to find the account key in the ChartOfAccount object

Set vRs = vBOB.GetObjectKeyBySingleValue(oChartOfAccounts, "FormatCode", "125100000100101", bqc_Equal)

'The Recordset retrieves the value of the key (for example, sStr = _SYS00000000010).

sStr = vRs.Fields.Item(0).Value

'Call the method GetByKey with this value (for example, sStr =_SYS00000000010) to 'retrieve the account

vCH.GetByKey (sStr)

As you can see at the end you get a chart of account object from where you can get the code.

Hope it helps,

-M

former_member687054
Participant
0 Kudos

Hi,

thank you for your help

time was running out and we had to use a work around to get what we wanted...

Message was edited by: Joderick Picard

Answers (2)

Answers (2)

jaccomoolenaar
Participant
0 Kudos

Hi,

Maybe we can help you better if you post your sourcecode?

Regards,

Jacco

former_member687054
Participant
0 Kudos

Hi,

here's my VB.net code used to add my invoice:

Dim oInvoice As SAPbobsCOM.Documents

Dim intError As Integer

Dim intI As Integer

oInvoice = oUSCompany.GetBusinessObject(BoObjectTypes.oInvoices)

' facture de service

oInvoice.DocType = BoDocumentTypes.dDocument_Service

oInvoice.CardCode = oEditText.Value

oEditText = oForm.Items.Item("54").Specific

oInvoice.CardName = oEditText.Value

' * * * * * * * * * *

' lignes de commande

Dim oMatrix As SAPbouiCOM.Matrix

oMatrix = oForm.Items.Item("38").Specific

For intI = 1 To (oMatrix.RowCount - 1)

If intI <> 1 Then

oInvoice.Lines.Add()

End If 'If intI <> 1 Then

oEditText = oMatrix.Columns.Item("1").Cells.Item(intI).Specific

oInvoice.Lines.UserFields.Fields.Item("U_SvcItem").Value = oEditText.Value

oEditText = oMatrix.Columns.Item("3").Cells.Item(intI).Specific

oInvoice.Lines.UserFields.Fields.Item("U_SvcDesc").Value = oEditText.Value

oEditText = oMatrix.Columns.Item("11").Cells.Item(intI).Specific

oInvoice.Lines.UserFields.Fields.Item("U_SvcQty").Value = oEditText.Value

Try

oEditText = oMatrix.Columns.Item("17").Cells.Item(intI).Specific

'MsgBox(ReturnNum(oEditText.Value))

'oInvoice.Lines.UserFields.Fields.Item("U_SvcUnitPrice").Value = oEditText.Value

oInvoice.Lines.UserFields.Fields.Item("U_SvcUnitPrice").Value = CDbl(ReturnNum(oEditText.Value))

Catch ex As Exception

MsgBox(ex.Message)

End Try

oComboBox = oMatrix.Columns.Item("27").Cells.Item(intI).Specific

oInvoice.Lines.SalesPersonCode = oComboBox.Selected.Value

oEditText = oMatrix.Columns.Item("21").Cells.Item(intI).Specific

oInvoice.Lines.LineTotal = oEditText.Value

oInvoice.Lines.AccountCode = "41100-01-0-00"

Next intI

intError = oInvoice.Add

If intError <> 0 Then

oApplication.MessageBox("Error " & intError & Chr(13) & oUSCompany.GetLastErrorDescription())

Else 'If intError <> 0 Then

oApplication.MessageBox("Transfert facture terminé.")

End If 'Else 'If intError <> 0 Then

Former Member
0 Kudos

Hi,

Can you tell me the error you get with the account code?

-M

former_member687054
Participant
0 Kudos

Hi,

I assign a specific account to oInvoice.Lines.AccountCode property and I see it in the OACT table...

here is the error :

Error -2028 INV1.AcctCode No matching records found (ODBC -2028)

Jodérick

Former Member
0 Kudos

Hi,

just an idea: isn't it that you are adding an

empty line to your invoice?!?

'cause once I got a similar error from DI

but the real problem was that I was calling

oInvoice.Lines.Add also for the first line of

my invoice ...

HTH,

francesca

former_member687054
Participant
0 Kudos

Hi,

no, I already check if I should do oinvoice.lines.add or not when I add my lines...