on 09-12-2016 9:08 PM
Muy buenas tardes apreciados Ingenieros
Estoy utilizando el SDK de sap Business one , con el lenguaje programación .NET
tengo un portal web donde los usuarios ingresan y registran sus solicitudes de compra
ahora me surge la necesidad de adjuntar archivos, pero no se cual es el objeto utilizado para hacer la carga del archivo
'DM.Lines.LineVendor = Service.Cardname
DM.Lines.RequiredDate = DateTime.Parse(tbFecha.Text)
DM.Lines.CostingCode2 = Service.ProjectLine
'DM.Lines.UserFields.Fields.Item("U_caracteristicas").Value = Service.ItemSpecs
DM.Lines.UserFields.Fields.Item("U_descripcion2").Value = Service.ItemSpecs.Substring(0, IIf(Service.ItemSpecs.Length < 100, Service.ItemSpecs.Length, 100))
DM.Lines.ProjectCode = Service.ProjectCode
DM.Lines.UserFields.Fields.Item("U_activos_proyecto").Value = Service.U_Differ
DM.Lines.UserFields.Fields.Item("U_presupuestado").Value = Service.U_Vaulted
DM.Lines.Add()
De antemano quedo muy agradecido por su amable colaboración
Hola muy buenas tardes
Agradezco la Inmensa colaboración y ayuda de CAB CANUL JULIAN de Mexico
y del DIEGO LOTHER de Brasil
ya lo logre hacer Comparto el código y si alguien tiene este problema con la DI-API Estoy atento para apoyarlos
'Creamos la variable y el objeto que necesitamos de tipo oAttachments2
'esto fuera de las lineas
Dim oAtt As SAPbobsCOM.Attachments2
oAtt = Con.GetBusinessObject(BoObjectTypes.oAttachments2)
oAtt.Lines.Add()
If FileCargarArchivosc.HasFile Then ' Si el Fileupload o el nombre que le puse a mi FileUpload no esta vacio entonces ejecute true y entre
Dim fileOK As Boolean = False 'Creo una variable de tipo boolean
Dim path As String = Server.MapPath("~/Anexos") 'Debes crear una carpeta vacia "Anexos" con un archivo en la solucion de tu proyecto .Net
FileCargarArchivosc.PostedFile.SaveAs(path & "/" & FileCargarArchivosc.FileName)'Instrucción para Guardar el archivo Adjuntado en el Fileupload en la carpeta que creaste en la solucion
oAtt.Lines.SourcePath = Server.MapPath("~/") + "Anexos\" 'Aqui le doy la ruta de origen, que exige el objeto de la DI-API Para poder hacer el Attachment
'Vuelvo a preguntar si el FileUpload no esta vacio entonces ejecute verdadero y entre
If FileCargarArchivosc.HasFile Then
Dim fileExtension As String 'Creo la Variable FileExtencion
fileExtension = System.IO.Path.GetExtension(FileCargarArchivosc.FileName).ToLower() 'Obtengo la extencion de mi archivo y la convierto a Minuscula
Dim allowedExtensions As String() = {".jpg", ".jpeg", ".png", ".gif", ".pdf"} 'Extenciones validas
'Recorro las extenciones y las comparo con las de mi archivo
For i As Integer = 0 To allowedExtensions.Length - 1
If fileExtension = allowedExtensions(i) Then
fileOK = True
End If
Next
'si fue correcta la extencion entonces poga la variable FileOk en verdadero
If fileOK Then
Try
oAtt.Lines.FileName = FileCargarArchivosc.FileName 'Entreguele al objeto de la Di-api el Nombre del Archivo
oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES 'Sobre escriba el metodo
lblErrorDeffer.Text = "Archivo Cargado Correctamente" 'Mensaje de advertencia
Catch ex As Exception
lblErrorDeffer.Text = "El Archivo no pudo ser cargado." + ex.ToString
End Try
Else
lblErrorDeffer.Text = "El Sistema no acepta este tipo de archivos"
End If
End If
Dim iAttEntry As Integer = -1
Dim ErrAtt As Integer = oAtt.Add
Dim ErrCode As String = Con.GetLastErrorCode
Dim ErrDescrip As String = Con.GetLastErrorDescription
If (oAtt.Add() = 0) Then
'So, you need get the id of the attachment that was created
iAttEntry = Int32.Parse(Con.GetNewObjectKey())
DM.AttachmentEntry = iAttEntry
Else
MsgBox("A ocurrido un error: " & ErrCode & ":" & ErrDescrip)
End If
End If
end if
'' Ahora solo falta eliminar el archivo para que el servidor WEB Donde esta la solucion o el proyecto no se llene de archivos innecesarios
Desde Bogota Colombia un Abrazo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola muy buenas noches , con la ayuda de Julian de Mexico, y Diego de brasil he logrado hacer
que me adjunte archivos pero aun no lo consigo como debería ser
Dim oAtt As SAPbobsCOM.Attachments2
oAtt = Con.GetBusinessObject(BoObjectTypes.oAttachments2)
oAtt.Lines.Add()
oAtt.Lines.SourcePath = "C:\Users\yohari\Desktop\"
Dim fileOK As Boolean = False
If FileCargarArchivosc.HasFile Then
Dim fileExtension As String
fileExtension = System.IO.Path.GetExtension(FileCargarArchivosc.FileName).ToLower()
Dim allowedExtensions As String() ={".jpg", ".jpeg", ".png", ".gif", ".pdf"}
For i As Integer = 0 To allowedExtensions.Length - 1
If fileExtension = allowedExtensions(i) Then
fileOK = True
End If
Next
If fileOK Then
Try
oAtt.Lines.FileName = FileCargarArchivosc.FileName
oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES
lblErrorDeffer.Text = "Archivo Cargado Correctamente"
Catch ex As Exception
lblErrorDeffer.Text = "El Archivo no pudo ser cargado." + ex.ToString
End Try
Else
lblErrorDeffer.Text = "El Sistema no acepta este tipo de archivos"
End If
End If
Dim iAttEntry As Integer = -1
Dim ErrAtt As Integer = oAtt.Add
Dim ErrCode As String = Con.GetLastErrorCode
Dim ErrDescrip As String = Con.GetLastErrorDescription
If (oAtt.Add() = 0) Then
'So, you need get the id of the attachment that was created
iAttEntry = Int32.Parse(Con.GetNewObjectKey())
DM.AttachmentEntry = iAttEntry
Else
MsgBox("A ocurrido un error: " & ErrCode & ":" & ErrDescrip)
End If
el problema radica en que sap pide una ruta de Origen
oAtt.Lines.Add()
oAtt.Lines.SourcePath = "C:\Users\yohary.garnica\Desktop\" 'AQUI
oAtt.Lines.FileName = "32"
oAtt.Lines.FileExtension = "pdf"
oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES
En este momento se la Queme como se dice en Desarrollo y funciona me adjunta el archivo
y lo puedo consultar desde Sap Business one
Pero cuando un usuario esta en la aplicacion web me es muy complicado decirle la ruta completa de origen del archivo, ya que ni con ASP, Ni con JavaScript lo puedo hacer por las politicas de seguridad de los navegadores
La verdad no se que hacer
quedo atento a sus amables comentarios
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dim oAtt As SAPbobsCOM.Attachments2
oAtt = Con.GetBusinessObject(BoObjectTypes.oAttachments2)
Dim iAttEntry As Integer = -1
oAtt.Lines.SourcePath = "C:\"
oAtt.Lines.FileName = FileUpload1.FileName 'Nombre de mi campo en la Vista FileUpload
oAtt.Lines.FileExtension = "pdf"
If (oAtt.Add() = 0) Then
'So, you need get the id of the attachment that was created
iAttEntry = Int32.Parse(Con.GetNewObjectKey())
End If
DM.AttachmentEntry = iAttEntry
DM.Lines.Add()
Pero ahora cuando intento ingresar una nueva Solicitud me sale este Mensaje
Ocurrio algo imprevisto
No_ existen registros coincidentes (OBDC-2028)
quedo atento a tus amables comentarios gracias
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Muy buenas noches amigos
Nada que lo logro conseguir
Dim oAtt As SAPbobsCOM.Attachments2
'oAtt = Con.GetBusinessObject(oAttachments2) If I do so I generated error here (oAttachments2) !!!!!!
oAtt = Con.GetBusinessObject(BoObjectTypes.oAttachments2)
Dim iAttEntry As Integer = -1
oAtt.Lines.SourcePath = "C:\"
oAtt.Lines.FileName = FileUpload1.FileName
oAtt.Lines.FileExtension = "PDF"
If (oAtt.Add() = 0) Then
'Por lo tanto, es necesario obtener el id de la unión que se creó
iAttEntry = Int32.Parse(Con.GetNewObjectKey())
End If
DM.AttachmentEntry = iAttEntry
DM.Lines.Add()
Pero ya de esta forma no me guarda nada que estaré haciendo mal
Agradezco sus amables comentarios
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Else
MyServices = Session("Services")
For Each Service As Services In MyServices
DM.Lines.ItemDescription = Service.ItemDescription.Substring(0, IIf(Service.ItemDescription.Length < 100, Service.ItemDescription.Length, 100))
DM.Lines.LineVendor = Service.Cardname
DM.Lines.RequiredDate = DateTime.Parse(tbFecha.Text)
DM.Lines.CostingCode2 = Service.ProjectLine
'DM.Lines.UserFields.Fields.Item("U_caracteristicas").Value = Service.ItemSpecs
DM.Lines.UserFields.Fields.Item("U_descripcion2").Value = Service.ItemSpecs.Substring(0, IIf(Service.ItemSpecs.Length < 100, Service.ItemSpecs.Length, 100))
DM.Lines.ProjectCode = Service.ProjectCode
''AQUI ESTOY INTENTANDO ADJUNTAR EL ARCHIVO Pero no me funciona
Dim oAtt As SAPbobsCOM.Attachments2
oAtt = Con.GetBusinessObject(BoObjectTypes.oPurchaseRequest)
oAtt.Lines.SourcePath = "C:\"
oAtt.Lines.FileName = FileUpload1.FileName
oAtt.Lines.FileExtension = "PDF"
oAtt.Add()
DM.Lines.UserFields.Fields.Item("U_activos_proyecto").Value = Service.U_Differ
DM.Lines.UserFields.Fields.Item("U_presupuestado").Value = Service.U_Vaulted
DM.Lines.Add()
Next
End If
Please si alguien tiene una idea la acepto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
-Este Codigo me funciona muy bien en .net
-Pero como es de su conocimiento yo no puedo adjuntar nada que no sea Utilizando el SDK
Dim path As String = Server.MapPath("~/ArchivosFacturas")
Dim fileOK As Boolean = False
If FileCargarArchivo.HasFile Then
Dim fileExtension As String
fileExtension = System.IO.Path.
GetExtension(FileCargarArchivo.FileName).ToLower()
Dim allowedExtensions As String() =
{".jpg", ".jpeg", ".png", ".gif", ".pdf"}
For i As Integer = 0 To allowedExtensions.Length - 1
If fileExtension = allowedExtensions(i) Then
fileOK = True
End If
Next
If fileOK Then
Try
FileCargarArchivo.PostedFile.SaveAs(path & "/" &
FileCargarArchivo.FileName)
Label1.Text = "Archivo Cargado Correctamente"
Catch ex As Exception
Label1.Text = "El Archivo no pudo ser cargado." + ex.ToString
End Try
Else
Label1.Text = "El Sistema no acepta este tipo de archivos"
End If
End If
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Checate esta liga te puede servir de mucho.
User | Count |
---|---|
89 | |
7 | |
7 | |
4 | |
4 | |
3 | |
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.