SOrder::InsertStkDetail (Interface: SOrder)
 
Inserts a new distribution for a detail.
 
void InsertStkDetail (
    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
The parameter sStkIndex can have the value -1 (sDetIndex must be a valid index!). In this case the new distribution is inserted after the existing ones.
If sStkIndex refers to an existing index, the new distribution is inserted at this index and all following distributions are moved to the next index.
 
See Also
CreateSOrder
Handling invoicing documents using the SDK
PrepareDocument
NeedStkDistrib
GetDetail
WriteDocument
CancelDocument
 
Samples
 
C++
 
// Insert a new distribution (after the other distributions) for the first detail of the current document
bool bWrite = false;

pSOrder->PrepareDocument (paUpdate);

if (pSOrder->NeedStkDistrib (0))
{
    VARIANT vQuantity;

    if (pSOrder->GetDetail (0, &vQuantity, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
    {
        pSOrder->InsertStkDetail (0, -1, vQuantity.dblVal, "Location A", "");
        bWrite = true;
    }
}

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

C#
 
// Insert a new distribution (after the other distributions) for the first detail of the current document
bool bWrite = false;

oSOrder.PrepareDocument (ePrepareAction.paUpdate);

if (oSOrder.NeedStkDistrib (0))
{
    object oQuantity, oDummy;

    if (oSOrder.GetDetail (0, out oQuantity, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy))
    {
        oSOrder.InsertStkDetail (0, -1, ((double)oQuantity), "Location A", "");
        bWrite = true;        
    }
}

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

VBS
 
' Insert a new distribution (after the other distributions) for the first detail of the current document
Dim bWrite

Call oSOrder.PrepareDocument(paUpdate)

bWrite = False

If oSOrder.NeedStkDistrib(0) Then
    Dim oQuantity, oDummy

    If oSOrder.GetDetail(0, oQuantity, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy) Then
        Call oSOrder.InsertStkDetail(0, -1, oQuantity, "Location A", "")
        bWrite = True
    End If
End If

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

VB.NET
 
' Insert a new distribution (after the other distributions) for the first detail of the current document
Dim bWrite As Boolean

oSOrder.PrepareDocument(ePrepareAction.paUpdate)

bWrite = False

If oSOrder.NeedStkDistrib(0) Then
    Dim oQuantity, oDummy As Object

    If oSOrder.GetDetail(0, oQuantity, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy, oDummy) Then
        oSOrder.InsertStkDetail(0, -1, oQuantity, "Location A", "")
        bWrite = True
    End If
End If

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