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_incoming_aw(
@date_start date,
@date_stop date,
@jn_doc varchar(255))
RETURNS TABLE
---XencX---with encryption
AS
RETURN (
select
ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) as id_data_in_hdr
,bc_type_name
,doc_no
,doc_date
,recieve_number
,recieve_date
,supplier_receiver_name
,barang_code
,barang_name
,doc_satuan_code
,isnull(doc_qty,0) as doc_qty
,isnull(total_cif,0) as total_cif
,invoice_no
,invoice_date
,valuta_code
from (
select isnull(upper(type_bc),'-') as bc_type_name
,isnull(no_daftar,'-') as doc_no
,tgl_nodaf as doc_date
,isnull(no_receive,'-') as recieve_number
,tgl_receive as recieve_date
,isnull(pemasok,'-') as supplier_receiver_name
,isnull(kode_brg,'-') as barang_code
,isnull(nama_brg,'-') as barang_name
,isnull(satuan,'-') as doc_satuan_code
,isnull(cast(jumlah as decimal(24,4)),0) as doc_qty
,isnull(cast(nilai_barang as decimal(24,4)),0) as total_cif
,null as invoice_no
,null as invoice_date
,'' as valuta_code
from AW.DB_PASI_20201106.dbo.tbl_pemasukan_barang
where tgl_receive between @date_start and @date_stop
and (not( pemasok= 'PT EDS MANUFACTURING INDONESIA'))
and ((nullif(nullif(@jn_doc,''),'-')) is null or (upper(type_bc)=@jn_doc and (nullif(nullif(@jn_doc,''),'-')) is not null))
union all
select isnull(upper(KODE_DOKUMEN),'-') as bc_type_name
,isnull(NOMOR_DAFTAR,'-') as doc_no
,TANGGAL_DAFTAR as doc_date
,isnull(receive_no,'-') as recieve_number
,receive_date as recieve_date
,isnull(NAMA_SUPPLIER,'-') as supplier_receiver_name
,isnull(KODE_BARANG,'-') as barang_codes
,isnull(NAMA_BARANG,'-') as barang_name
,isnull(SATUAN_BARANG,'-') as doc_satuan_code
,isnull(cast(JUMLAH_SATUAN as decimal(24,4)),0) as doc_qty
,isnull(cast(AMOUNT as decimal(24,4)),0) as total_cif
,null as invoice_no
,null as invoice_date
,kode_valuta as valuta_code
from AW.DB_PASI_20201106.dbo.dv_data_pemasukan_ceisa
where receive_date between @date_start and @date_stop
and ((nullif(nullif(@jn_doc,''),'-')) is null or (upper(KODE_DOKUMEN)=@jn_doc and (nullif(nullif(@jn_doc,''),'-')) is not null))
)xdata
)
--GO
-- select * from gab_rpt_incoming ('12/12/2015', '12/12/2016','BC27')
GO
GO
CREATE FUNCTION dbo.gab_rpt_incoming_aw(
@date_start date,
@date_stop date,
@jn_doc varchar(255))
RETURNS TABLE
---XencX---with encryption
AS
RETURN (
select
ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) as id_data_in_hdr
,bc_type_name
,doc_no
,doc_date
,recieve_number
,recieve_date
,supplier_receiver_name
,barang_code
,barang_name
,doc_satuan_code
,isnull(doc_qty,0) as doc_qty
,isnull(total_cif,0) as total_cif
,invoice_no
,invoice_date
,valuta_code
from (
select isnull(upper(type_bc),'-') as bc_type_name
,isnull(no_daftar,'-') as doc_no
,tgl_nodaf as doc_date
,isnull(no_receive,'-') as recieve_number
,tgl_receive as recieve_date
,isnull(pemasok,'-') as supplier_receiver_name
,isnull(kode_brg,'-') as barang_code
,isnull(nama_brg,'-') as barang_name
,isnull(satuan,'-') as doc_satuan_code
,isnull(cast(jumlah as decimal(24,4)),0) as doc_qty
,isnull(cast(nilai_barang as decimal(24,4)),0) as total_cif
,null as invoice_no
,null as invoice_date
,'' as valuta_code
from AW.DB_PASI_20201106.dbo.tbl_pemasukan_barang
where tgl_receive between @date_start and @date_stop
and (not( pemasok= 'PT EDS MANUFACTURING INDONESIA'))
and ((nullif(nullif(@jn_doc,''),'-')) is null or (upper(type_bc)=@jn_doc and (nullif(nullif(@jn_doc,''),'-')) is not null))
union all
select isnull(upper(KODE_DOKUMEN),'-') as bc_type_name
,isnull(NOMOR_DAFTAR,'-') as doc_no
,TANGGAL_DAFTAR as doc_date
,isnull(receive_no,'-') as recieve_number
,receive_date as recieve_date
,isnull(NAMA_SUPPLIER,'-') as supplier_receiver_name
,isnull(KODE_BARANG,'-') as barang_codes
,isnull(NAMA_BARANG,'-') as barang_name
,isnull(SATUAN_BARANG,'-') as doc_satuan_code
,isnull(cast(JUMLAH_SATUAN as decimal(24,4)),0) as doc_qty
,isnull(cast(AMOUNT as decimal(24,4)),0) as total_cif
,null as invoice_no
,null as invoice_date
,kode_valuta as valuta_code
from AW.DB_PASI_20201106.dbo.dv_data_pemasukan_ceisa
where receive_date between @date_start and @date_stop
and ((nullif(nullif(@jn_doc,''),'-')) is null or (upper(KODE_DOKUMEN)=@jn_doc and (nullif(nullif(@jn_doc,''),'-')) is not null))
)xdata
)
--GO
-- select * from gab_rpt_incoming ('12/12/2015', '12/12/2016','BC27')
GO
Depends On
No items found
Used By
No items found