on 09-19-2016 11:24 PM
Buenas Tardes a la comunidad,
Quisiera ver si alguien me puede ayudar o me podría orientar con un desarrollo que quiero hacer el cual consiste en lo siguiente.
Tengo que hacer un webservice que a travez de el, yo le pase ciertos parametros de un cliente y este webservice me lo pueda crear en la tabla OCRD del SAP. Yo me hice un procedimiento almacenado mediante el cual yo inserto los registros directamente desde el procedimiento almacenado a la tabla de SAP y lo hace bien.
El problema es que me dicen que no puedo hacer esa operacion de insertar datos directamente a la base de datos de sap, sino que tengo que usar el SDK de SAP para realizar esta operacion.
Ahora aqui viene mi duda, si alguien tiene algun ejemplo pequeño o cuales son los pasos para que yo pueda insertar registros en la tabla OCRD usando el SDK.
Gracias.
Debes usar la DI API para poder hacer una conexion a SAP y poder llamar al objeto "Socio de Negocios"
La insercion se debe hacer de la siguiente manera (Codigo de Ejemplo del SDK)
Dim nErr As Long
Dim errMsg As String
'Create the BusinessPartners object
Dim vBP As SAPbobsCOM.BusinessPartners
Set vBP = vCompany.GetBusinessObject(oBusinessPartners)'Calls BusinessPartners object
'Set values of the BusinessPartners object's mandatory and optional properties
vBP.CardCode = "HU1003" 'Mandatory property in the BusinessPartners object
vBP.CardName = "ABCD"
vBP.CardType = cCustomer
vBP.CommissionGroupCode = 0
vBP.CommissionPercent = 15
vBP.Company_Private = cPrivate
vBP.ContactPerson = "C1"
vBP.Currency = "$"
vBP.DiscountPercent = 15
vBP.VatLiable = vLiable
vBP.ShippingType = 3
Call vBP.ContactEmployees.Add
Call vBP.ContactEmployees.SetCurentLine(0)
vBP.ContactEmployees.Name = "C1"
vBP.ContactEmployees.Address = "LN"
vBP.ContactEmployees.E_Mail = "ABCD@MAIL.COM"
vBP.ContactEmployees.Fax = "8433777778"
vBP.ContactEmployees.MobilePhone = "8388888"
vBP.ContactEmployees.Phone1 = "88880000"
Call vBP.ContactEmployees.SetCurentLine(1)
vBP.ContactEmployees.Name = "C2"
vBP.ContactEmployees.Address = "BJ"
vBP.ContactEmployees.E_Mail = "abcde2@MAIL.COM"
vBP.ContactEmployees.Fax = "84338"
vBP.ContactEmployees.MobilePhone = "877388888"
vBP.ContactEmployees.Phone1 = "8888300"
If (0 <> vBP.Add()) Then
MsgBox ("Failed to add an business partner")
Else
Dim objCode As String
MsgBox ("Succeeded add a business partner
, new objcode=" + vBP.CardCode)
vBP.SaveXml ("c:\temp\BP" + vBP.CardCode + ".xml")
End If
'Check Error
Call vCompany.GetLastError(nErr, errMsg)
If (0 <> nErr) Then
MsgBox ("Found error:" + Str(nErr) + "," + errMsg)
End If
Saludos.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Exacto, debes realizar la conexion pero mediante la DI API, para eso deberas usar el siguiente codigo:
Dim oCompany As SAPbobsCOM.Company = New SAPbobsCOM.Company
oCompany.Server = "ServerAddress"
oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English
oCompany.UseTrusted = False
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005
oCompany.DbUserName = "dbusername"
oCompany.DbPassword = "dbpassword"
oCompany.UserName = "appUserName"
oCompany.Password = "appPassword"
oCompany.CompanyDB = "companydb"
oCompany.LicenseServer = "localhost:30000"
Gracias por el código Gabriel, te cuento que he intentado de todo, pero no me puedo conectar porque me sale este error.
He revisado por todos lados y no veo porque no me deja conectarme, pareciera como sino conectara con el servidor de licencia. Alguien tendra conocimiento sobre este problema.
He buscado en los foros pero las soluciones que brindan no me han funcionado :c
Hola Jose!
Trata de probar con este codigo, en los codigos anteriores falta la intruccion ".connect()", aqui tambien te muestro como hacer un sql con un recordset y como instanciar un objeto de negocios del SAP con la DI, luego de hacer el connect, ya puedes ejecutar el codigo para registrar el la OCRD:
private void Conexion_Prueba() | |
{ | |
try | |
{ | |
SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company(); |
oCompany.Server = "FSSAPBO"; | |
//oCompany.language = SAPbobsCOM.BoSuppLangs.ln_Spanish_La; | |
oCompany.UseTrusted = false; | |
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; | |
oCompany.DbUserName = "sa"; | |
oCompany.DbPassword = "Sqladmin281"; | |
oCompany.UserName = "manager"; | |
oCompany.Password = "rgnm"; | |
oCompany.CompanyDB = "SBO_COMERCIAL"; | |
oCompany.LicenseServer = "FSSAPBO:30000"; |
oCompany.Connect(); |
SAPbobsCOM.Recordset businessObject = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); | |
int nDocOrd = 0; |
string sql = "select DocEntry from OPRQ"; | |
businessObject.DoQuery(sql); | |
if (businessObject.RecordCount > 0) | |
{ | |
nDocOrd = Convert.ToInt32(businessObject.Fields.Item(0).Value); | |
} |
SAPbobsCOM.Documents oPurchaseRequest = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseRequest); |
if (oPurchaseRequest.GetByKey(nDocOrd)) | |
{ | |
for (int i = 0; i < oPurchaseRequest.Lines.Count; i++) | |
{ | |
oPurchaseRequest.Lines.SetCurrentLine(i); | |
string itemCode = oPurchaseRequest.Lines.ItemCode; | |
} | |
} |
} | |
catch (Exception) | |
{ | |
} |
} |
Espero te funcione.
Saludos y si te sirve, recuerda marcar la solucion.
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.