on 04-06-2006 6:57 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
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
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
Hi,
Maybe we can help you better if you post your sourcecode?
Regards,
Jacco
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Hi,
Can you tell me the error you get with the account code?
-M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
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.