on 09-11-2008 12:15 AM
Hola a todos los miembros de esta comunidad, ando por aqui solicitando de su ayuda que de antemano les agradesco; pues vayamos al punto; mi problema es que estoy generando un addon para creacion de facturas, ya busque en la ayuda y hay un ejemplo pero pero ese ejemplo graba sobre la tabla ODRF, y me puse a hacer unas facturas con SAP y este graba las facturas en la tabla OINV y ademas graba cada una de las lineas de las facturas en la tabla INV1, el codigo de ejemplo que yo estoy ocupando es el siguiente:
Sub AddInvoice_Click()
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
'Create the Documents object
Dim vDrafts As SAPbobsCOM.Documents
Set vDrafts = vCmp.GetBusinessObject(oDrafts)
'Set values to the fields
vDrafts.DocObjectCode = oInvoices
vDrafts.CardCode = "BP234"
vDrafts.HandWritten = tNO
vDrafts.DocDate = "21/8/2003"
vDrafts.DocTotal = 264.6
'Invoice Lines - Set values to the first line
vDrafts.Lines.ItemCode = "A00023"
vDrafts.Lines.ItemDescription = "Banana"
vDrafts.Lines.Quantity = 50
'Invoice Lines - Set values to the second line
vDrafts.Lines.Add
vDrafts.Lines.ItemCode = " A00033"
vDrafts.Lines.ItemDescription = "Orange"
vDrafts.Lines.Quantity = 1
'Add the Invoice
RetVal = vDrafts.Add
End Sub
Este codigo es el qu eme est agrabando sobre la tabal ORDF, mi pregunta es si alguno de ustedes expertos en sap saben por qeue graba sobre la tabla ORDF y no sobre INV1y OINV?
Espero me puedan ayudar seguiremos en contacto.
Edited by: Rui Pereira on Nov 7, 2008 9:41 AM
Okmuchas gracias jorge ya me di cuenta que si manejo cuentas segmentadas; y eh colocado el codigo que mencionaste anteriormente, pero sigo con problemas ahora el mensaje que me manda es el siguinte:
"Either BOF or EOF have Been Reached"
Eh estado intentando solucionarlo y nadamas no encuentro como conseguirlo,
Este es el codigo que actualmente tengo para la creacion de mi factura.. espero puedas encontrar algo con lo cuel pueda dar respuesta a mi problema de antemanos muchas gracias por la ayuda...
Private Sub CreaFactura()
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim sStr As String
Dim vRs As SAPbobsCOM.Recordset
Dim vBOB As SAPbobsCOM.SBObob
Dim vCH As SAPbobsCOM.ChartOfAccounts
vCH = Co_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oChartOfAccounts)
vBOB = Co_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)
vRs = Co_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
' When working with segmentation use this function
' to find the account key in the ChartOfAccount object
vRs = vBOB.GetObjectKeyBySingleValue(SAPbobsCOM.BoObjectTypes.oChartOfAccounts, "FormatCode", "125100000100101", SAPbobsCOM.BoQueryConditions.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)
Try
''Create the Documents object
Dim vDrafts As SAPbobsCOM.Documents
vDrafts = Co_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
Co_Factura = Co_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)
If Co_Factura.GetByKey(cardcode) <> 0 Then
''Set values to the fields
vDrafts.DocObjectCode = SAPbobsCOM.BoObjectTypes.oInvoices
vDrafts.CardCode = Co_Factura.CardCode
vDrafts.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
vDrafts.DocDate = Now.Date
vDrafts.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service
vDrafts.DocNum = Li_DocNum
''Invoice Lines - Set values to the first line
vDrafts.Lines.ItemCode = "1"
vDrafts.Lines.ItemDescription = "Platano"
vDrafts.Lines.Quantity = 1
vDrafts.Lines.Price = 10
vDrafts.Lines.LineTotal = 10
vDrafts.Lines.RowTotalFC = 11.5
vDrafts.Lines.AccountCode = "P001"
''Add the Invoice
RetVal = vDrafts.Add
'' ''Check the result
If RetVal <> 0 Then
Co_Company.GetLastError(ErrCode, ErrMsg)
MsgBox(ErrCode & " " & ErrMsg)
End If
End If
Catch ex As Exception
ManejaExcepcion(ex)
Finally
Mo_Forma.Freeze(False)
End Try
End Sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pues ya pude quitar ese error pero ahora me sale el siguiente mensaje .....
-2028 ( INV1.AcctCode ) (line:1),'No existen registros coincidentes(ODBC-2028)'
alguien sabe como puedo solucionarlo ...?¡
Edited by: Jorge Luis Madrigal Hernandez on Sep 11, 2008 11:16 AM
Edited by: Jorge Luis Madrigal Hernandez on Sep 11, 2008 11:17 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ocupas cuentas segmentadas????
si es afirmativa tu respuesta debes hacer un paso previa a pasar el codigo de la cuenta.
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)
' 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)
suerte
hola a todos y muchas gracias Jorge Benitez si tenias razon ese era el problema, ya me di cuenta que con eso podre grabar en la tabla qe deseo solo que ahora me manda un problema que dice que no genera la factura por que algunos datos no estan completos; primero me salia un mensaje que faltaba el monto de la factura, cosa que ya le coloque pero ahora me pide la cuenta de mayor, no se si alguien del foro me podria decir cuales son los datos especificos que nesesito para generar mi dactura de manera correcta muchas gracias por su ayuda...
Y pues seguiremos en contacto
________________________________________________________________________________________
La fortuna juega en favor de una mente preparada.
-
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola Jorge,
en el Help del SDK estan definidos los campos Mandatory para cada tipo de objetos de negocio de SAP
oDocuments
Documents_Lines
AccountCode:
Sets or returns the G/L account code of the business partner as defined in Chart of Accounts.
(field name: AcctCode).
Mandatory property.
Length: 15 characters.
-
-
ItemCode:
Sets or returns the item code in the inventory. The item code must be unique.
(field name: ItemCode).
Mandatory property.
Length: 20 characters.
This is a foreign key to the Items object.
-
-
lo otro es que generes el documento mediante el formulario de SAP y apuntes los datos minimos para la creacion del documento
suerte.
si esta solucionada tu consulta, por favor dar como respondido el post y ve el tema de los puntos, si tú lo estimas.
Hola Jorge,
esto es por que estas creando un Objeto del tipo oDraft y no un oInvoices
Create the Documents object
Dim vDrafts As SAPbobsCOM.Documents
Set vDrafts = vCmp.GetBusinessObject(oDrafts)
'Set values to the fields
vDrafts.DocObjectCode = oInvoices
cambiar por
Create the Documents object
Dim vInvoices As SAPbobsCOM.Documents
Set vInvoices = vCmp.GetBusinessObject(oInvoices)
esta linea ya no iria en tu codigo
'Set values to the fields
vDrafts.DocObjectCode = oInvoices
suerte.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
6 | |
6 | |
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.