cancel
Showing results for 
Search instead for 
Did you mean: 

Try to update ShippingMethod via DI-Api to -1 in order line

Swen_Koegler
Discoverer
0 Kudos
129

Version: SAP Business One 10.0 SP 2411 for HANA

I am trying to set the ShippingMethod in order lines to the default value -1 with an update via DI-API. Unfortunately without success so far. The value -1 is not recognized. Instead, the value 15 is entered, which is contained in the OSHP table.

The update process does not produce an error. Since I also adjust the delivery date in the same step, which works, the question has arisen for me whether the value -1 cannot be set or whether it is a problem in the DI-API.

The same behavior exists via the service layer. However, I can update a NULL via the service layer, which is not possible via the DI-API.

Who has ideas or solutions?

Code:
I run a query to determine all order lines that should be updated
--------------
while (!oRecordset.EoF)
{
SAPbobsCOM.Documents oOrders = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
int documentEntry = (int)oRecordset.Fields.Item("DocEntry").Value;
int documentLine = (int)oRecordset.Fields.Item("VisOrder").Value;

oOrders.Lines.SetCurrentLine(documentLine);
oOrders.Lines.ShipDate = DateTime.Now.AddDays(addDaysToCurrentDateForNewShipDate).Date;
oOrders.Lines.ShippingMethod = -1;

oOrders.Update()
}
--------------

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

Hi Swen_Koegler,

According to SAP Note 2623612

If you use ShippingMethod = -1 in the DI program, it will take the Shipping Type from Item Master Data of the line. This is by-design behavior.

If you want to set Shipping Type as empty, you should use the following:

oSO.Lines.ShippingMethod = -2;

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Swen_Koegler
Discoverer

Hi ANKIT_CHAUHAN,

unbelievable, but it works. It's a good thing that SAP doesn't write it in the DI-API documentation. Otherwise there would be no need for this forum. 🙂
Thanks a lot. Problem solved.

Answers (0)