SOrder::UpdateStkDetail (Interface: SOrder)
 
Updates a distribution for a detail.
 
void UpdateStkDetail (
    SHORT sDetIndex,
    SHORT sStkIndex,
    DOUBLE dQuantity,
    BSTR bsLocation,
    BSTR bsSerialNumber
)
 
Parameters
sDetIndex
[in] The index of the detail where the distribution belongs to, starting from 0.
sStkIndex
[in] The index of the distribution, starting from 0.
dQuantity
[in] The quantity that is distributed (in stock units).
bsLocation
[in] The location of the article.
bsSerialNumber
[in] The serial number of the article.
 
Remarks
If the parameter sIndex is an invalid index (refers to a not existing distribution) an exception is thrown. You can use GetStkDetail to check whether an index is valid, in which case it returns true.
 
See Also
CreateSOrder
Handling invoicing documents using the SDK
PrepareDocument
GetNumDetails
GetNumStkDetails
GetStkDetail
WriteDocument
CancelDocument
 
Samples
 
C++
 
// Update the location code of all distributions of all details of the current document from 'LOC_A' to 'LOC_B'
VARIANT vQuantity, vLocation, vSerialNumber;
short sNumDetails;
bool bWrite = false;

pSOrder->PrepareDocument (paUpdate);

sNumDetails = pSOrder->GetNumDetails ();

for (short sDetail = 0; sDetail < sNumDetails; sDetail++)
{
    short sNumStkDets = pSOrder->GetNumStkDetails (sDetail);
    
    for (short sStkDet = 0; sStkDet < sNumStkDets; sStkDet++)
    {
        if (pSOrder->GetStkDetail (sDetail, sStkDet, &vQuantity, &vLocation, &vSerialNumber) && CString (vLocation.bstrVal) == "LOC_A")
        {
            pSOrder->UpdateStkDetail (sDetail, sStkDet, vQuantity.dblVal, "LOC_B", vSerialNumber.bstrVal);
            bWrite = true;
        }
    }
}

if (bWrite)
    pSOrder->WriteDocument (rmFullReport, VARIANT_FALSE, VARIANT_FALSE);
else
    pSOrder->CancelDocument ();

C#
 
// Update the location code of all distributions of all details of the current document from 'LOC_A' to 'LOC_B'
object oQuantity, oLocation, oSerialNumber;
short sNumDetails;
bool bWrite = false;

oSOrder.PrepareDocument (ePrepareAction.paUpdate);

sNumDetails = oSOrder.GetNumDetails ();

for (short sDetail = 0; sDetail < sNumDetails; sDetail++)
{
    short sNumStkDets = oSOrder.GetNumStkDetails (sDetail);
    
    for (short sStkDet = 0; sStkDet < sNumStkDets; sStkDet++)
    {
        if (oSOrder.GetStkDetail (sDetail, sStkDet, out oQuantity, out oLocation, out oSerialNumber) && oLocation.ToString () == "LOC_A")
        {
            oSOrder.UpdateStkDetail (sDetail, sStkDet, (double)oQuantity, "LOC_B", oSerialNumber.ToString ());
            bWrite = true;
        }
    }
}

if (bWrite)
    oSOrder.WriteDocument (eReportMode.rmFullReport, false, false);
else
    oSOrder.CancelDocument ();

VBS
 
' Update the location code of all distributions of all details of the current document from 'LOC_A' to 'LOC_B'
Dim oQuantity, oLocation, oSerialNumber
Dim sNumDetails, sDetail
Dim bWrite

Call oSOrder.PrepareDocument(paUpdate)

sNumDetails = oSOrder.GetNumDetails()
bWrite = False

For sDetail = 0 To sNumDetails - 1
    Dim sNumStkDets, sStkDet
    
    sNumStkDets = oSOrder.GetNumStkDetails(sDetail)
    
    For sStkDet = 0 To sNumStkDets - 1
        If oSOrder.GetStkDetail(sDetail, sStkDet, oQuantity, oLocation, oSerialNumber) And oLocation = "LOC_A" Then
            Call oSOrder.UpdateStkDetail(sDetail, sStkDet, oQuantity, "LOC_B", oSerialNumber)
            bWrite = True
        End If
    Next
Next

If bWrite Then
    Call oSOrder.WriteDocument(rmFullReport, False, False)
Else
    Call oSOrder.CancelDocument()
End If

VB.NET
 
' Update the location code of all distributions of all details of the current document from 'LOC_A' to 'LOC_B'
Dim oQuantity, oLocation, oSerialNumber As Object
Dim sNumDetails As Short
Dim bWrite As Boolean

oSOrder.PrepareDocument(ePrepareAction.paUpdate)

sNumDetails = oSOrder.GetNumDetails()
bWrite = False

For sDetail As Short = 0 To sNumDetails - 1
    Dim sNumStkDets As Short
    
    sNumStkDets = oSOrder.GetNumStkDetails(sDetail)
    
    For sStkDet As Short = 0 To sNumStkDets - 1
        If oSOrder.GetStkDetail(sDetail, sStkDet, oQuantity, oLocation, oSerialNumber) And oLocation = "LOC_A" Then
            oSOrder.UpdateStkDetail(sDetail, sStkDet, oQuantity, "LOC_B", oSerialNumber)
            bWrite = True
        End If
    Next
Next

If bWrite Then
    oSOrder.WriteDocument(eReportMode.rmFullReport, False, False)
Else
    oSOrder.CancelDocument()
End If