Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Null on Null Input | False |
| Schema Bound | False |
| Assembly |
Parameters
| Name | Data Type | Length | Description |
|---|---|---|---|
| @date_start | date | 3 | |
| @date_stop | date | 3 | |
| @jn_doc | varchar | 255 |
SQL Script
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE FUNCTION dbo.gab_rpt_outgoing_wh(
@date_start date,
@date_stop date,
@jn_doc varchar(255))
RETURNS TABLE
---XencX---with encryption
AS
RETURN (
SELECT
enum_data_out_to.doc_out_to_name as bc_type_name
, tbl_sa_hdr.BC25No as doc_no
, cast(tbl_sa_hdr.BC25Tg as date) as doc_date
, tbl_data_out_hdr.doc_out_no as surat_jalan_no
, cast(tbl_data_out_hdr.doc_out_date as date) as surat_jalan_date
, tbl_sa.NAMA_PEMBELI as supplier_receiver_name
, tbl_sa.ASSY_CODE as barang_code
, tbl_sa.ASSY_NO as barang_name
, tbl_sa.SATUAN as satuan_code
, tbl_sa.TOTAL_SET as doc_qty
, tbl_sa.AMOUNT as total
, '' valuta_code
FROM tbl_sa_hdr INNER JOIN
tbl_sa ON tbl_sa_hdr.id_sa_hdr = tbl_sa.id_sa_hdr INNER JOIN
tbl_data_out_hdr ON tbl_sa_hdr.id_sa_hdr = tbl_data_out_hdr.id_terkait INNER JOIN
enum_data_out_to ON tbl_data_out_hdr.doc_out_to_id = enum_data_out_to.doc_out_to_id
WHERE (tbl_data_out_hdr.doc_out_to_id = 3)
and cast(tbl_data_out_hdr.doc_out_date as date) between @date_start and @date_stop
and ((nullif(nullif(@jn_doc,''),'-')) is null or (upper(enum_data_out_to.doc_out_to_name)=@jn_doc and (nullif(nullif(@jn_doc,''),'-')) is not null))
and nullif(tbl_sa_hdr.BC25No ,'') is not null
union all
SELECT
enum_data_out_to.doc_out_to_name as bc_type_name
,tbl_bc_out_hdr.NODAFT as doc_no
, cast(tbl_bc_out_hdr.TGDAFT as date) as doc_date
, tbl_data_out_hdr.doc_out_no as surat_jalan_no
, cast(tbl_data_out_hdr.doc_out_date as date) as surat_jalan_date
, tbl_bc_out_hdr.NAMABELI as supplier_receiver_name
, tbl_bc_out_dtl.KDBRG as barang_code
, tbl_bc_out_dtl.URBRG1 as barang_name
, tbl_bc_out_dtl.JNSATUAN as satuan_code
, tbl_bc_out_dtl.JMSATUAN as doc_qty
, tbl_bc_out_dtl.DNilInv as total
, '' valuta_code
FROM tbl_bc_out_hdr INNER JOIN
tbl_bc_out_dtl ON tbl_bc_out_hdr.id_bc_out_hdr = tbl_bc_out_dtl.id_bc_out_hdr INNER JOIN
tbl_data_out_hdr ON tbl_bc_out_hdr.id_bc_out_hdr = tbl_data_out_hdr.id_terkait INNER JOIN
enum_data_out_to ON tbl_data_out_hdr.doc_out_to_id = enum_data_out_to.doc_out_to_id
WHERE
(tbl_data_out_hdr.doc_out_to_id = 2 or tbl_data_out_hdr.doc_out_to_id = 5 or tbl_data_out_hdr.doc_out_to_id = 6)
and cast(tbl_bc_out_hdr.TGDAFT as date) between @date_start and @date_stop
and ((nullif(nullif(@jn_doc,''),'-')) is null or (upper(enum_data_out_to.doc_out_to_name)=@jn_doc and (nullif(nullif(@jn_doc,''),'-')) is not null))
and nullif(tbl_bc_out_hdr.NODAFT ,'') is not null
---- NEW MESIN
union all
SELECT
bc_type_name
, doc_no
, doc_date
, surat_jalan_no
, surat_jalan_date
, supplier_receiver_name
, barang_code
, barang_name
, satuan_code
, doc_qty
, total
, valuta_code
FROM dbo.gab_rpt_outgoing_wh_mesin(@date_start,@date_stop,replace(@jn_doc,'BC','')) AS gab_rpt_outgoing_wh_mesin_1
)
--GO
-- select * from gab_rpt_outgoing_wh ('12/12/2015', '12/12/2016','BC27')
GO
GO
CREATE FUNCTION dbo.gab_rpt_outgoing_wh(
@date_start date,
@date_stop date,
@jn_doc varchar(255))
RETURNS TABLE
---XencX---with encryption
AS
RETURN (
SELECT
enum_data_out_to.doc_out_to_name as bc_type_name
, tbl_sa_hdr.BC25No as doc_no
, cast(tbl_sa_hdr.BC25Tg as date) as doc_date
, tbl_data_out_hdr.doc_out_no as surat_jalan_no
, cast(tbl_data_out_hdr.doc_out_date as date) as surat_jalan_date
, tbl_sa.NAMA_PEMBELI as supplier_receiver_name
, tbl_sa.ASSY_CODE as barang_code
, tbl_sa.ASSY_NO as barang_name
, tbl_sa.SATUAN as satuan_code
, tbl_sa.TOTAL_SET as doc_qty
, tbl_sa.AMOUNT as total
, '' valuta_code
FROM tbl_sa_hdr INNER JOIN
tbl_sa ON tbl_sa_hdr.id_sa_hdr = tbl_sa.id_sa_hdr INNER JOIN
tbl_data_out_hdr ON tbl_sa_hdr.id_sa_hdr = tbl_data_out_hdr.id_terkait INNER JOIN
enum_data_out_to ON tbl_data_out_hdr.doc_out_to_id = enum_data_out_to.doc_out_to_id
WHERE (tbl_data_out_hdr.doc_out_to_id = 3)
and cast(tbl_data_out_hdr.doc_out_date as date) between @date_start and @date_stop
and ((nullif(nullif(@jn_doc,''),'-')) is null or (upper(enum_data_out_to.doc_out_to_name)=@jn_doc and (nullif(nullif(@jn_doc,''),'-')) is not null))
and nullif(tbl_sa_hdr.BC25No ,'') is not null
union all
SELECT
enum_data_out_to.doc_out_to_name as bc_type_name
,tbl_bc_out_hdr.NODAFT as doc_no
, cast(tbl_bc_out_hdr.TGDAFT as date) as doc_date
, tbl_data_out_hdr.doc_out_no as surat_jalan_no
, cast(tbl_data_out_hdr.doc_out_date as date) as surat_jalan_date
, tbl_bc_out_hdr.NAMABELI as supplier_receiver_name
, tbl_bc_out_dtl.KDBRG as barang_code
, tbl_bc_out_dtl.URBRG1 as barang_name
, tbl_bc_out_dtl.JNSATUAN as satuan_code
, tbl_bc_out_dtl.JMSATUAN as doc_qty
, tbl_bc_out_dtl.DNilInv as total
, '' valuta_code
FROM tbl_bc_out_hdr INNER JOIN
tbl_bc_out_dtl ON tbl_bc_out_hdr.id_bc_out_hdr = tbl_bc_out_dtl.id_bc_out_hdr INNER JOIN
tbl_data_out_hdr ON tbl_bc_out_hdr.id_bc_out_hdr = tbl_data_out_hdr.id_terkait INNER JOIN
enum_data_out_to ON tbl_data_out_hdr.doc_out_to_id = enum_data_out_to.doc_out_to_id
WHERE
(tbl_data_out_hdr.doc_out_to_id = 2 or tbl_data_out_hdr.doc_out_to_id = 5 or tbl_data_out_hdr.doc_out_to_id = 6)
and cast(tbl_bc_out_hdr.TGDAFT as date) between @date_start and @date_stop
and ((nullif(nullif(@jn_doc,''),'-')) is null or (upper(enum_data_out_to.doc_out_to_name)=@jn_doc and (nullif(nullif(@jn_doc,''),'-')) is not null))
and nullif(tbl_bc_out_hdr.NODAFT ,'') is not null
---- NEW MESIN
union all
SELECT
bc_type_name
, doc_no
, doc_date
, surat_jalan_no
, surat_jalan_date
, supplier_receiver_name
, barang_code
, barang_name
, satuan_code
, doc_qty
, total
, valuta_code
FROM dbo.gab_rpt_outgoing_wh_mesin(@date_start,@date_stop,replace(@jn_doc,'BC','')) AS gab_rpt_outgoing_wh_mesin_1
)
--GO
-- select * from gab_rpt_outgoing_wh ('12/12/2015', '12/12/2016','BC27')
GO
Depends On
7Used By
No items found