Skip to Content

Attaching images via code with a Web service (SAP ByD)

Hello experts,

I am using a custom object and one of the nodes has a DocumentList, this makes reference to another Custom BO and we create the new data via Web Service.

In the Root- Before save script I make a query to the other BO to re attach some images because we need to have them in both BO, the problem is that the Before save does not creates the new attachments in the BO when we use the Web service, it only creates them when we save the information in the UI.

This is the web service configuration:

nodo-1.png

And this is the before save script:

import ABSL;
import AP.Common.GDT as apCommonGDT;
import BASIS.Global as basis;

if (this.Depositos.Count() > 0)
{
foreach (var dep in this.Depositos)
{
if (dep.zIDeposito.IsInitial())
{
dep.Delete();
}
else
{
var querydep = BOCashTransf.QueryByElements;
var paramsdep = querydep.CreateSelectionParams();
paramsdep.Add(querydep.zIDCashTransfer, "I", "EQ", dep.zIDeposito.RemoveLeadingZeros());
var resultdep = querydep.Execute(paramsdep);
if (resultdep.Count() > 0)
{
var depencontrado = resultdep.GetFirst();
if (depencontrado.adjuntos.AttachmentExistsIndicator)
{

var docDescription : Description;
var MyAtt = depencontrado.adjuntos.DocumentList;
var FileCont = MyAtt.GetFirst();
var attach = dep.Depositos;
docDescription.content = FileCont.Name;

attach.CreateFile(FileCont.TypeCode, FileCont.Name, FileCont.Name, docDescription, FileCont.FileContent.BinaryObject);

}
}
}
}
}

As I mentioned, the creation of the attachment works fine in the UI but it does not work from the Web service, the instance is created without a problem, just no attachments.

nodo-1.png (4.4 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jul 17, 2020 at 01:25 PM

    Hi Fernando,

    Did you make any progress on your requirement?

    Kind regards,

    Adrian

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.