Skip to Content
0
Jun 22, 2020 at 08:10 PM

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

103 Views

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.

Attachments

nodo-1.png (4.4 kB)