on 08-24-2015 7:18 AM
Hello Experts
can i add attachment to delivery note or sale order by DI api
i did code for that but it giving error for Delivery not object but it working fine for activity object
This is My code
///////////////////////
try
{
SAPbobsCOM.Attachments2 oATT = LoginForm.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2) as SAPbobsCOM.Attachments2;
string FileName = "C:\\Test\\MyTest.txt";
oATT.Lines.Add();
oATT.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(FileName);
oATT.Lines.FileExtension = System.IO.Path.GetExtension(FileName).Substring(1);
oATT.Lines.SourcePath = System.IO.Path.GetDirectoryName(FileName);
oATT.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES;
SAPbobsCOM.Contacts ACT;
SAPbobsCOM.Documents oSO;
SAPbobsCOM.Documents odelivery;
//// SAPbobsCOM.SalesOpportunities oactivity;
oSO = (SAPbobsCOM.Documents)LoginForm.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
odelivery = (SAPbobsCOM.Documents)LoginForm.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);
ACT = (SAPbobsCOM.Contacts)LoginForm.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oContacts);
int iAttEntry = -1;
if (oATT.Add() == 0)
{
iAttEntry = int.Parse(LoginForm.oCompany.GetNewObjectKey());
//Assign the attachment to the GR object (GR is my SAPbobsCOM.Documents object)
odelivery.AttachmentEntry = iAttEntry;
}
}
catch (Exception ex)
{
// c = false;
MessageBox.Show(ex.Message);
}
Hi Vilas,
Follow this:
How do I create or copy an attatchment to Sales... | SCN
Hope that helps.
Thanks & Regards
ANKIT CHAUHAN
SAP Business One Global Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Diego
I am using SAP 9.0 PL 12 and am also doing same as Ankit but it giving error on
Object.Attachmententry (Object does not support this method or method not implemented)on ( oDLN.AttachmentEntry = AttEntry;)
Is This problem Of version?
I Think It should Work On Each PL Of SAP (9.0)
THis Is My Code
/////////////////////////////////////////
try
{
SAPbobsCOM.Attachments2 oAtt = (SAPbobsCOM.Attachments2)LoginForm.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2);
string FileName = "C:\\Test\\MyTest.txt";
//oATT.Lines.Add();
//oATT.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(FileName);
//oATT.Lines.FileExtension = System.IO.Path.GetExtension(FileName).Substring(1);
//oATT.Lines.SourcePath = System.IO.Path.GetDirectoryName(FileName);
//oATT.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES;
if (System.IO.File.Exists("C:\\Test\\MyTest.txt"))
{
oAtt.Lines.SourcePath = System.IO.Path.GetDirectoryName(FileName);
oAtt.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(FileName);
oAtt.Lines.FileExtension = System.IO.Path.GetExtension(FileName).Substring(1);
oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES;
int iErr = oAtt.Add();
int AttEntry = 0;
if (iErr == 0)
{
AttEntry = int.Parse(LoginForm.oCompany.GetNewObjectKey());
SAPbobsCOM.Documents oDLN = (SAPbobsCOM.Documents)LoginForm.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);
oDLN.CardCode = "C00000852";
oDLN.AttachmentEntry = AttEntry;
oDLN.Lines.BaseEntry = 362;
oDLN.Lines.BaseType = 17;
oDLN.Lines.BaseLine = 0;
iErr = oDLN.Add();
if (iErr != 0) MessageBox.Show(LoginForm.oCompany.GetLastErrorDescription());
}
}
}
catch (Exception ex)
{
// c = false;
MessageBox.Show(ex.Message);
}
Hi vilas,
I think that I didn't understand the problem, if you saved your attachment, you just need associate the value of the key of Attachments2 object to the property AttachmentEntry in the Delivery object. But this property "AttachmentEntry " is only available in version 9.0 or latest from SAPBobsCom.
Your code that you past in the last answer works fine if you use a newly SAPBobsCom.
With your code, I get this result in my sap b1 client:
Regards,
Diego
Hi CAB,
I used the code provided in this thread How do I create or copy an attatchment to Sales... | SCN
and the code provided by Vilas Maskey in your first question.
Best regards,
Diego Lother
I'm trying to purchase invoice but I get error -5002 , the code is the same. You will have idea that it might be?
'Meter los archivos como adjunto al documento
Dim Adjuntos As SAPbobsCOM.Attachments2
Adjuntos = oCompany.GetBusinessObject(oAttachments2)
Adjuntos.Lines.SourcePath = "c\repsotiorio"
Adjuntos.Lines.FileName = "AVM950418QQ6_431309_FAA_8B2CE109-ECBC-45A7-BD93-89772A70CC84_"
Adjuntos.Lines.FileExtension = "xml"
Try
Dim iAttEntry As Integer = -1
Dim errorat As Integer = Adjuntos.Add() '******HERE GENERATES ERROR
If (errorat = 0) Then
iAttEntry = Int32.Parse(oCompany.GetNewObjectKey())
oDocumentoSAP.AttachmentEntry = iAttEntry
End If
Catch ex As Exception
End Try
The purchase invoice already exists , I'm just attaching a file xml.
User | Count |
---|---|
95 | |
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.