I'm new to SAP B1 and SQL and trying to create a query for invoice summary in query manager. Just a few questions..
Can I generate a column total automatically without ctrl+clicking on the colulmn?
Instead of filtering by WhsCode eg ABC, BCA, in Criteria Selection when executing query, I want to be able to choose from the list of A/R Invoice SeriesNames instead such as IN-ABC, IN-BCA in which it will then show me all Invoices where DocNum column starts with the chosen SeriesName prefix.
If I use whscode filter, how can I add a wildcard option such that if user does not select a warehouse, it will just display all warehouses.
Currently date filter lets me select a range of posting dates. Can I have the criteria selection show me a calender range instead of a list of documents?
Thank you.
Declare @Date1 Datetime
Declare @Date2 Datetime
Set @Date1 = (select min(S0.DocDate) from OINV S0 Where S0.DocDate >= '[%0]')
Set @Date2 = (select max(S1.DocDate) from OINV S1 Where S1.DocDate <= '[%1]')
SELECT
DISTINCT CONCAT(T1.[SeriesName], T0.[DocNum]) AS DocNum,
T2.[WhsCode],
T0.[CardName] AS 'Customer Name',
T0.[DocDate],
T0.[DocCur],
T0.[PaidSum],
T0.[DocStatus]
FROM
OINV T0 INNER JOIN NNM1 T1 ON T0.Series = T1.Series INNER JOIN INV1 T2 ON T0.[DocEntry] = T2.[DocEntry]
WHERE
T0.[DocDate] BETWEEN @Date1 AND @Date2
AND
T0.[DocStatus] = 'C'
AND
T2.[WhsCode] = '[%]'
I have tried
WHERE T1.[SeriesName] = '[%]'
to filter by SeriesName, but it gives me the entire system list of document series names when I only want series under A/R Invoice.