Venice
SInvce::InsertStkDetail
 
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
CreateSInvce
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;

pSInvce->PrepareDocument (paUpdate);

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

    if (pSInvce->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))
    {
        pSInvce->InsertStkDetail (0, -1, vQuantity.dblVal, "Location A", "");
        bWrite = true;
    }
}

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

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

oSInvce.PrepareDocument (ePrepareAction.paUpdate);

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

    if (oSInvce.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))
    {
        oSInvce.InsertStkDetail (0, -1, ((double)oQuantity), "Location A", "");
        bWrite = true;        
    }
}

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

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

Call oSInvce.PrepareDocument(paUpdate)

bWrite = False

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

    If oSInvce.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) Then
        Call oSInvce.InsertStkDetail(0, -1, oQuantity, "Location A", "")
        bWrite = True
    End If
End If

If bWrite Then
    Call oSInvce.WriteDocument(rmFullReport, False, False)
Else
    Call oSInvce.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

oSInvce.PrepareDocument(ePrepareAction.paUpdate)

bWrite = False

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

    If oSInvce.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) Then
        oSInvce.InsertStkDetail(0, -1, oQuantity, "Location A", "")
        bWrite = True
    End If
End If

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