23 lines
1009 B
Plaintext
23 lines
1009 B
Plaintext
' Version Date: 13.10.2020
|
|
Function GetWinLineStockedAmount(ProductNumber, IncludeSalesDocuments)
|
|
' Lagerstand des Artikels prüfen
|
|
SQL = ""
|
|
SQL = SQL & "SELECT "
|
|
SQL = SQL & "(SELECT C008 AS [MengeZugang] from [v021] (NOLOCK) where (c002 = '__ARTICLENUMBER__') "& SQLQuery_BasicWhere &") - "
|
|
SQL = SQL & "(SELECT C009 AS [MengeAbgang] from [v021] (NOLOCK) where (c002 = '__ARTICLENUMBER__') "& SQLQuery_BasicWhere &") - "
|
|
|
|
If IncludeSalesDocuments = True Or IncludeSalesDocuments = "True" Or IncludeSalesDocuments = 1 Then
|
|
' Include Products from sales documents
|
|
SQL = SQL & "ISNULL((SELECT SUM(C035) AS [MengeVerkauf] FROM [t014] (NOLOCK) where c000 = '__ARTICLENUMBER__' "& SQLQuery_BasicWhere &"), 0) "
|
|
Else
|
|
' Skip Products from sales documents
|
|
SQL = SQL & "(SELECT 0) "
|
|
End If
|
|
|
|
SQL = SQL & "AS c000"
|
|
|
|
SQL = Replace(SQL, "__ARTICLENUMBER__", ProductNumber)
|
|
Set Result = CWLStart.CurrentCompany.Connection.Select(SQL)
|
|
|
|
GetWinLineStockedAmount = Result.Value("c000")
|
|
End Function |