Feature #3788 » PRPTINVDOCDETAILNGROUPING.sql
| 1 |
ALTER PROCEDURE [dbo].[PRPTINVDOCDETAILNGROUPING] |
|---|---|
| 2 |
(
|
| 3 |
@DocDateFrom VARCHAR(20) |
| 4 |
,@DocDateTo VARCHAR(20) |
| 5 |
,@DocStatus VARCHAR(20) |
| 6 |
,@DocNoFrom VARCHAR(20) |
| 7 |
,@DocType VARCHAR(20) |
| 8 |
)
|
| 9 |
AS
|
| 10 |
|
| 11 |
--DECLARE @DocDateFrom VARCHAR(20) = ''
|
| 12 |
--DECLARE @DocDateTo VARCHAR(20) = ''
|
| 13 |
--DECLARE @DocStatus VARCHAR(20) = ''
|
| 14 |
--DECLARE @DocNoFrom VARCHAR(20) = '00000800'
|
| 15 |
--DECLARE @DocType VARCHAR(20) = 'GICU'
|
| 16 |
|
| 17 |
IF (@DocDateFrom <> '') BEGIN SET @DocDateFrom = @DocDateFrom END ELSE BEGIN SET @DocDateFrom = '19000101' END |
| 18 |
IF (@DocDateTo <> '') BEGIN SET @DocDateTo = @DocDateTo END ELSE BEGIN SET @DocDateTo = '99991231' END |
| 19 |
|
| 20 |
SELECT DISTINCT head.DocNo |
| 21 |
FROM dbo.PTRMATERIALHEAD AS head |
| 22 |
WHERE (head.DocType = @DocType OR @DocType = '') |
| 23 |
AND (head.DocDate >= @DocDateFrom AND head.DocDate <= @DocDateTo) |
| 24 |
AND (head.DocStatus = @DocStatus OR @DocStatus = '') |
| 25 |
AND (head.DocNo = @DocNoFrom OR @DocNoFrom = '') |