Description
Properties
| Name | Value |
|---|---|
| Collation | SQL_Latin1_General_CP1_CI_AS |
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Schema Bound | False |
| Created | 9/11/2017 10:50:52 |
| Last Modified | 7/17/2020 13:06:32 |
Columns
| Key | Name | Description |
|---|---|---|
| ms_in_item_detail_id | ||
| mode_source | ||
| mode_source_name | ||
| mode_source_2 | ||
| mode_source_name_2 | ||
| car | ||
| bc_no | ||
| bc_date | ||
| receive_no | ||
| receive_date | ||
| status_id | ||
| status_name | ||
| KPBC | ||
| KODE_VALUTA | ||
| SERI_BARANG | ||
| quantity_pakai | ||
| quantity_sisa | ||
| qty_out | ||
| qty_plan | ||
| car_line_out | ||
| car_line_plan | ||
| memo_out | ||
| memo_plan | ||
| sto_out | ||
| sto_plan | ||
| adjustment_out | ||
| adjustment_plan | ||
| ms_type_id | ||
| ms_item_custom_no | ||
| ms_item_base_no | ||
| part_no | ||
| part_name | ||
| uom | ||
| ori_ms_in_item_detail_id | ||
| id_source_header | ||
| ms_item_id | ||
| allow_to_production | ||
| mandatory_car_line | ||
| allow_to_scrap | ||
| allow_to_repair | ||
| allow_to_selling |
SQL Script
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE view dbo.vw_ms_item_in_detail
---XencX---with encryption
as
--1 STA
--2 BC
--3 ADJUSTMENT
--4 STO
--5 RETUR
with _header as (
SELECT dt_ms_item_in_detail.ms_in_item_detail_id
, 100 + isnull(dt_ms_item_list_sta.source_sta_id,0) as mode_source_2
,case when dt_ms_item_list_sta.source_sta_id=0 then cast(dt_ms_item_list_sta.source_sta_id as varchar(255)) else 'BC ' + cast(dt_ms_item_list_sta.source_sta_id as varchar(255)) end mode_source_name_2
, dt_ms_item_list_sta.CAR as car
, dt_ms_item_list_sta.BC_NO as bc_no
, dt_ms_item_list_sta.BC_DATE as bc_date
, dt_ms_item_list_sta.receive_no
, dt_ms_item_list_sta.receive_date
, cast(1 as int) status_id
, 'FINISH' status_name
, dt_ms_item_list_sta.KODE_KANTOR as KPBC
, dt_ms_item_list_sta.KODE_VALUTA
, dt_ms_item_list_sta.SERI_BARANG
FROM dt_ms_item_list_sta INNER JOIN
enum_ms_mode_source_item_in_detail INNER JOIN
dt_ms_item_in_detail ON enum_ms_mode_source_item_in_detail.mode_source = dt_ms_item_in_detail.mode_source ON dt_ms_item_list_sta.ms_item_list_sta_id = dt_ms_item_in_detail.id_source
where dt_ms_item_in_detail.mode_source= 1
union all
SELECT dt_ms_item_in_detail.ms_in_item_detail_id
,100 + cast(isnull(dt_ms_tpb_in_header.KODE_DOKUMEN_PABEAN ,'0') as int) as mode_source_2
,'BC ' + dt_ms_tpb_in_header.KODE_DOKUMEN_PABEAN as mode_source_name_2
, dt_ms_tpb_in_header.NOMOR_AJU as car
, dt_ms_tpb_in_header.NOMOR_DAFTAR as bc_no
, dt_ms_tpb_in_header.TANGGAL_DAFTAR as bc_date
, dt_ms_tpb_in_header.receive_no
, dt_ms_tpb_in_header.receive_date
, cast(case when dt_ms_tpb_in_header_h_status.status_tpb_in_id=3 then 1 else 0 end as int) status_id
, enum_ms_status_tpb_in.status_tpb_in_name status_name
, dt_ms_tpb_in_header.KODE_KANTOR as KPBC
, dt_ms_tpb_in_header.KODE_VALUTA
, dt_ms_tpb_in_barang.SERI_BARANG
FROM dt_ms_item_in_detail INNER JOIN
enum_ms_status_tpb_in INNER JOIN
dt_ms_tpb_in_header INNER JOIN
dt_ms_tpb_in_barang ON dt_ms_tpb_in_header.ID_HEADER = dt_ms_tpb_in_barang.ID_HEADER INNER JOIN
dt_ms_tpb_in_header_h_status ON dt_ms_tpb_in_header.dt_ms_tpb_in_header_h_status_id = dt_ms_tpb_in_header_h_status.dt_ms_tpb_in_header_h_status_id ON
enum_ms_status_tpb_in.status_tpb_in_id = dt_ms_tpb_in_header_h_status.status_tpb_in_id ON dt_ms_item_in_detail.id_source = dt_ms_tpb_in_barang.ID
where dt_ms_item_in_detail.mode_source= 2
union all
SELECT
dt_ms_item_in_detail.ms_in_item_detail_id
,dt_ms_item_in_detail.mode_source as mode_source_2
,'RETUR' as mode_source_name_2
, dt_ms_production_retur_detail.retur_info as car
, dt_ms_production_retur.retur_no as bc_no
, dt_ms_production_retur.retur_date as bc_date
, dt_ms_production_retur.retur_no as receive_no
, dt_ms_production_retur.retur_date as receive_date
, cast(case when dt_ms_production_retur_h_status.ms_production_retur_id=1 then 1 else 0 end as int) status_id
, enum_status_production_retur.status_production_retur_name status_name
, '' as KPBC
, '' as KODE_VALUTA
, -1 as SERI_BARANG
FROM dt_ms_production_retur INNER JOIN
dt_ms_production_retur_detail ON dt_ms_production_retur.ms_production_retur_id = dt_ms_production_retur_detail.ms_production_retur_id INNER JOIN
dt_ms_production_retur_h_status ON dt_ms_production_retur.ms_production_retur_h_status_id = dt_ms_production_retur_h_status.ms_production_retur_h_status_id INNER JOIN
enum_status_production_retur ON dt_ms_production_retur_h_status.status_production_retur_id = enum_status_production_retur.status_production_retur_id INNER JOIN
dt_ms_item_in_detail ON dt_ms_production_retur_detail.ms_production_retur_detail_id = dt_ms_item_in_detail.id_source INNER JOIN
enum_ms_mode_source_item_in_detail ON dt_ms_item_in_detail.mode_source = enum_ms_mode_source_item_in_detail.mode_source
WHERE (dt_ms_item_in_detail.mode_source = 5)
union all
SELECT
dt_ms_item_in_detail.ms_in_item_detail_id
,dt_ms_item_in_detail.mode_source as mode_source_2
,enum_ms_mode_source_item_in_detail.mode_source_name as mode_source_name_2
, 'STO' as car
, dt_ms_adj_sto.doc_code as bc_no
, dt_ms_adj_sto.doc_date as bc_date
, dt_ms_adj_sto.doc_code as receive_no
, dt_ms_adj_sto.doc_date as receive_date
, cast(case when dt_ms_adj_sto_h_status.status_adj_sto_id =1 then 1 else 0 end as int) status_id
, enum_ms_status_adj_sto.status_adj_sto_name status_name
, '' as KPBC
, '' as KODE_VALUTA
, -1 as SERI_BARANG
FROM enum_ms_mode_source_item_in_detail INNER JOIN
dt_ms_item_in_detail ON enum_ms_mode_source_item_in_detail.mode_source = dt_ms_item_in_detail.mode_source INNER JOIN
dt_ms_adj_sto INNER JOIN
dt_ms_adj_sto_h_status ON dt_ms_adj_sto.ms_adj_sto_h_status_id = dt_ms_adj_sto_h_status.ms_adj_sto_h_status_id INNER JOIN
enum_ms_status_adj_sto ON dt_ms_adj_sto_h_status.status_adj_sto_id = enum_ms_status_adj_sto.status_adj_sto_id ON dt_ms_item_in_detail.id_source_header = dt_ms_adj_sto.ms_adj_sto_id
WHERE (dt_ms_item_in_detail.mode_source = 3)
)
SELECT
dt_ms_item_in_detail.ms_in_item_detail_id
, dt_ms_item_in_detail.mode_source
, enum_ms_mode_source_item_in_detail.mode_source_name
, _header.mode_source_2
,_header.mode_source_name_2
,_header.car
,_header.bc_no
,_header.bc_date
,_header.receive_no
,_header.receive_date
,_header.status_id
,_header.status_name
,_header.KPBC
,_header.KODE_VALUTA
,_header.SERI_BARANG
,dt_ms_item_in_detail.quantity_pakai
,isnull(dt_ms_item_in_detail.quantity_pakai,0) -( isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.plan_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.plan_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.plan_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.plan_qty end ,0)
) as quantity_sisa
,isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.out_qty end ,0) as qty_out
, isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.plan_qty end,0)
+ isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.plan_qty end,0)
+ isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.plan_qty end,0)
+ isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.plan_qty end ,0) as qty_plan
,isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.out_qty end,0) as car_line_out
,isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.plan_qty end,0) as car_line_plan
,isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.out_qty end,0) as memo_out
,isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.plan_qty end,0) as memo_plan
,isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.out_qty end,0) as sto_out
,isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.plan_qty end,0) as sto_plan
,isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.out_qty end,0) as adjustment_out
,isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.plan_qty end,0) as adjustment_plan
, vw_ms_item.ms_type_id
, vw_ms_item.ms_item_custom_no
, vw_ms_item.ms_item_base_no
, vw_ms_item.part_no
, vw_ms_item.part_name
, vw_ms_item.uom
, dt_ms_item_in_detail.ori_ms_in_item_detail_id
, dt_ms_item_in_detail.id_source_header
, dt_ms_item_in_detail.ms_item_id
, vw_ms_item.allow_to_production
, vw_ms_item.mandatory_car_line
, vw_ms_item.allow_to_scrap
, vw_ms_item.allow_to_repair
, vw_ms_item.allow_to_selling
FROM enum_ms_mode_source_item_in_detail INNER JOIN
dt_ms_item_in_detail ON enum_ms_mode_source_item_in_detail.mode_source = dt_ms_item_in_detail.mode_source INNER JOIN
vw_ms_item_no_log AS vw_ms_item ON dt_ms_item_in_detail.ms_item_id = vw_ms_item.ms_item_id INNER JOIN
--(SELECT dt_ms_item_in_detail.ms_in_item_detail_id) AS
_header ON dt_ms_item_in_detail.ms_in_item_detail_id = _header.ms_in_item_detail_id LEFT OUTER JOIN
vw_ms_item_in_sum_to_sto ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_sto.ms_in_item_detail_id LEFT OUTER JOIN
vw_ms_item_in_sum_to_adjustment ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id LEFT OUTER JOIN
vw_ms_item_in_sum_to_memo ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_memo.ms_in_item_detail_id LEFT OUTER JOIN
vw_ms_item_in_sum_to_car_line ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id
--SELECT
-- dt_ms_item_in_detail.ms_in_item_detail_id
--, dt_ms_item_in_detail.mode_source
--, enum_ms_mode_source_item_in_detail.mode_source_name
--, cast(case when dt_ms_item_in_detail.mode_source =1 then 100 + isnull(dt_ms_item_list_sta.source_sta_id,0)
-- when dt_ms_item_in_detail.mode_source =2 then 100 + cast(isnull(dt_ms_tpb_in_header.KODE_DOKUMEN_PABEAN ,'0') as int)
-- else dt_ms_item_in_detail.mode_source
-- end as int) as mode_source_2
--,cast( case when dt_ms_item_in_detail.mode_source =1 then case when dt_ms_item_list_sta.source_sta_id=0 then cast(dt_ms_item_list_sta.source_sta_id as varchar(255)) else 'BC ' + cast(dt_ms_item_list_sta.source_sta_id as varchar(255)) end
-- when dt_ms_item_in_detail.mode_source =2 then 'BC ' + dt_ms_tpb_in_header.KODE_DOKUMEN_PABEAN
-- when dt_ms_item_in_detail.mode_source =5 then 'RETUR'
-- else ''
-- end as varchar(255)) as mode_source_name_2
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.CAR
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.NOMOR_AJU
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur_detail.retur_info
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_item_in_detail.info
-- else ''
-- end as varchar(255)) as car
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.BC_NO
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.NOMOR_DAFTAR
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur.retur_no
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_adj_sto.doc_code
-- else ''
-- end as varchar(255)) as bc_no
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.BC_DATE
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.TANGGAL_DAFTAR
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur.retur_date
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_adj_sto.doc_date
-- else ''
-- end as date) as bc_date
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.receive_no
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.receive_no
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur.retur_no
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_adj_sto.doc_code
-- else ''
-- end as varchar(255)) as receive_no
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.receive_date
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.receive_date
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur.retur_date
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_adj_sto.doc_date
-- else ''
-- end as date) as receive_date
--,cast( case when dt_ms_item_in_detail.mode_source =1 then 1
-- when dt_ms_item_in_detail.mode_source =2 then case when dt_ms_tpb_in_header_h_status.status_tpb_in_id=3 then 1 else 0 end
-- when dt_ms_item_in_detail.mode_source =5 then case when dt_ms_production_retur_h_status.ms_production_retur_id=1 then 1 else 0 end
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then case when dt_ms_adj_sto_h_status.status_adj_sto_id =1 then 1 else 0 end
-- else 0
-- end as int) as status_id
--,cast( case when dt_ms_item_in_detail.mode_source =1 then 'FINISH'
-- when dt_ms_item_in_detail.mode_source =2 then enum_ms_status_tpb_in.status_tpb_in_name
-- when dt_ms_item_in_detail.mode_source =5 then enum_status_production_retur.status_production_retur_name
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then enum_ms_status_adj_sto.status_adj_sto_name
-- else ''
-- end as varchar(255)) as status_name
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.KODE_KANTOR
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.KODE_KANTOR
-- else ''
-- end as varchar(255)) as KPBC
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.KODE_VALUTA
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.KODE_VALUTA
-- else ''
-- end as varchar(255)) as KODE_VALUTA
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.SERI_BARANG
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_barang.SERI_BARANG
-- else ''
-- end as varchar(255)) as SERI_BARANG
--,dt_ms_item_in_detail.quantity_pakai
--,isnull(dt_ms_item_in_detail.quantity_pakai,0) -( isnull(vw_ms_item_in_sum_to_car_line.out_qty,0)
-- + isnull(vw_ms_item_in_sum_to_memo.out_qty,0)
-- + isnull(vw_ms_item_in_sum_to_car_line.plan_qty,0)
-- + isnull(vw_ms_item_in_sum_to_memo.plan_qty,0)
-- + isnull(vw_ms_item_in_sum_to_sto.out_qty,0)
-- + isnull(vw_ms_item_in_sum_to_sto.plan_qty,0)
-- + isnull(vw_ms_item_in_sum_to_adjustment.out_qty,0)
-- + isnull(vw_ms_item_in_sum_to_adjustment.plan_qty,0)
-- ) as quantity_sisa
--,isnull(vw_ms_item_in_sum_to_car_line.out_qty,0) + isnull(vw_ms_item_in_sum_to_memo.out_qty,0) + isnull(vw_ms_item_in_sum_to_sto.out_qty,0) + isnull(vw_ms_item_in_sum_to_adjustment.out_qty,0) as qty_out
--,isnull(vw_ms_item_in_sum_to_car_line.plan_qty,0) + isnull(vw_ms_item_in_sum_to_memo.plan_qty,0) + isnull(vw_ms_item_in_sum_to_sto.plan_qty,0) + isnull(vw_ms_item_in_sum_to_adjustment.plan_qty,0) as qty_plan
--,isnull(vw_ms_item_in_sum_to_car_line.out_qty,0) as car_line_out
--,isnull(vw_ms_item_in_sum_to_car_line.plan_qty,0) as car_line_plan
--,isnull(vw_ms_item_in_sum_to_memo.out_qty,0) as memo_out
--,isnull(vw_ms_item_in_sum_to_memo.plan_qty,0) as memo_plan
--,isnull(vw_ms_item_in_sum_to_sto.out_qty,0) as sto_out
--,isnull(vw_ms_item_in_sum_to_sto.plan_qty,0) as sto_plan
--,isnull(vw_ms_item_in_sum_to_adjustment.out_qty,0) as adjustment_out
--,isnull(vw_ms_item_in_sum_to_adjustment.plan_qty,0) as adjustment_plan
--, vw_ms_item.ms_type_id
--, vw_ms_item.ms_item_custom_no
--, vw_ms_item.ms_item_base_no
--, vw_ms_item.part_no
--, vw_ms_item.part_name
--, vw_ms_item.uom
--, dt_ms_item_in_detail.ori_ms_in_item_detail_id
--, dt_ms_item_in_detail.id_source_header
--, dt_ms_item_in_detail.ms_item_id
--, vw_ms_item.allow_to_production
--, vw_ms_item.mandatory_car_line
--, vw_ms_item.allow_to_scrap
--, vw_ms_item.allow_to_repair
--, vw_ms_item.allow_to_selling
--FROM enum_ms_mode_source_item_in_detail INNER JOIN
-- dt_ms_item_in_detail ON enum_ms_mode_source_item_in_detail.mode_source = dt_ms_item_in_detail.mode_source INNER JOIN
-- vw_ms_item ON dt_ms_item_in_detail.ms_item_id = vw_ms_item.ms_item_id LEFT OUTER JOIN
-- dt_ms_adj_sto INNER JOIN
-- dt_ms_adj_sto_h_status ON dt_ms_adj_sto.ms_adj_sto_h_status_id = dt_ms_adj_sto_h_status.ms_adj_sto_h_status_id INNER JOIN
-- enum_ms_status_adj_sto ON dt_ms_adj_sto_h_status.status_adj_sto_id = enum_ms_status_adj_sto.status_adj_sto_id ON dt_ms_item_in_detail.id_source_header = dt_ms_adj_sto.ms_adj_sto_id LEFT OUTER JOIN
-- enum_ms_status_tpb_in INNER JOIN
-- dt_ms_tpb_in_header INNER JOIN
-- dt_ms_tpb_in_barang ON dt_ms_tpb_in_header.ID_HEADER = dt_ms_tpb_in_barang.ID_HEADER INNER JOIN
-- dt_ms_tpb_in_header_h_status ON dt_ms_tpb_in_header.dt_ms_tpb_in_header_h_status_id = dt_ms_tpb_in_header_h_status.dt_ms_tpb_in_header_h_status_id ON
-- enum_ms_status_tpb_in.status_tpb_in_id = dt_ms_tpb_in_header_h_status.status_tpb_in_id ON dt_ms_item_in_detail.id_source = dt_ms_tpb_in_barang.ID LEFT OUTER JOIN
-- dt_ms_item_list_sta ON dt_ms_item_in_detail.id_source = dt_ms_item_list_sta.ms_item_list_sta_id LEFT OUTER JOIN
-- dt_ms_production_retur INNER JOIN
-- dt_ms_production_retur_detail ON dt_ms_production_retur.ms_production_retur_id = dt_ms_production_retur_detail.ms_production_retur_id INNER JOIN
-- dt_ms_production_retur_h_status ON dt_ms_production_retur.ms_production_retur_h_status_id = dt_ms_production_retur_h_status.ms_production_retur_h_status_id INNER JOIN
-- enum_status_production_retur ON dt_ms_production_retur_h_status.status_production_retur_id = enum_status_production_retur.status_production_retur_id ON
-- dt_ms_item_in_detail.id_source = dt_ms_production_retur_detail.ms_production_retur_detail_id LEFT OUTER JOIN
-- vw_ms_item_in_sum_to_sto ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_sto.ms_in_item_detail_id LEFT OUTER JOIN
-- vw_ms_item_in_sum_to_adjustment ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id LEFT OUTER JOIN
-- vw_ms_item_in_sum_to_memo ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_memo.ms_in_item_detail_id LEFT OUTER JOIN
-- vw_ms_item_in_sum_to_car_line ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id
GO
GO
CREATE view dbo.vw_ms_item_in_detail
---XencX---with encryption
as
--1 STA
--2 BC
--3 ADJUSTMENT
--4 STO
--5 RETUR
with _header as (
SELECT dt_ms_item_in_detail.ms_in_item_detail_id
, 100 + isnull(dt_ms_item_list_sta.source_sta_id,0) as mode_source_2
,case when dt_ms_item_list_sta.source_sta_id=0 then cast(dt_ms_item_list_sta.source_sta_id as varchar(255)) else 'BC ' + cast(dt_ms_item_list_sta.source_sta_id as varchar(255)) end mode_source_name_2
, dt_ms_item_list_sta.CAR as car
, dt_ms_item_list_sta.BC_NO as bc_no
, dt_ms_item_list_sta.BC_DATE as bc_date
, dt_ms_item_list_sta.receive_no
, dt_ms_item_list_sta.receive_date
, cast(1 as int) status_id
, 'FINISH' status_name
, dt_ms_item_list_sta.KODE_KANTOR as KPBC
, dt_ms_item_list_sta.KODE_VALUTA
, dt_ms_item_list_sta.SERI_BARANG
FROM dt_ms_item_list_sta INNER JOIN
enum_ms_mode_source_item_in_detail INNER JOIN
dt_ms_item_in_detail ON enum_ms_mode_source_item_in_detail.mode_source = dt_ms_item_in_detail.mode_source ON dt_ms_item_list_sta.ms_item_list_sta_id = dt_ms_item_in_detail.id_source
where dt_ms_item_in_detail.mode_source= 1
union all
SELECT dt_ms_item_in_detail.ms_in_item_detail_id
,100 + cast(isnull(dt_ms_tpb_in_header.KODE_DOKUMEN_PABEAN ,'0') as int) as mode_source_2
,'BC ' + dt_ms_tpb_in_header.KODE_DOKUMEN_PABEAN as mode_source_name_2
, dt_ms_tpb_in_header.NOMOR_AJU as car
, dt_ms_tpb_in_header.NOMOR_DAFTAR as bc_no
, dt_ms_tpb_in_header.TANGGAL_DAFTAR as bc_date
, dt_ms_tpb_in_header.receive_no
, dt_ms_tpb_in_header.receive_date
, cast(case when dt_ms_tpb_in_header_h_status.status_tpb_in_id=3 then 1 else 0 end as int) status_id
, enum_ms_status_tpb_in.status_tpb_in_name status_name
, dt_ms_tpb_in_header.KODE_KANTOR as KPBC
, dt_ms_tpb_in_header.KODE_VALUTA
, dt_ms_tpb_in_barang.SERI_BARANG
FROM dt_ms_item_in_detail INNER JOIN
enum_ms_status_tpb_in INNER JOIN
dt_ms_tpb_in_header INNER JOIN
dt_ms_tpb_in_barang ON dt_ms_tpb_in_header.ID_HEADER = dt_ms_tpb_in_barang.ID_HEADER INNER JOIN
dt_ms_tpb_in_header_h_status ON dt_ms_tpb_in_header.dt_ms_tpb_in_header_h_status_id = dt_ms_tpb_in_header_h_status.dt_ms_tpb_in_header_h_status_id ON
enum_ms_status_tpb_in.status_tpb_in_id = dt_ms_tpb_in_header_h_status.status_tpb_in_id ON dt_ms_item_in_detail.id_source = dt_ms_tpb_in_barang.ID
where dt_ms_item_in_detail.mode_source= 2
union all
SELECT
dt_ms_item_in_detail.ms_in_item_detail_id
,dt_ms_item_in_detail.mode_source as mode_source_2
,'RETUR' as mode_source_name_2
, dt_ms_production_retur_detail.retur_info as car
, dt_ms_production_retur.retur_no as bc_no
, dt_ms_production_retur.retur_date as bc_date
, dt_ms_production_retur.retur_no as receive_no
, dt_ms_production_retur.retur_date as receive_date
, cast(case when dt_ms_production_retur_h_status.ms_production_retur_id=1 then 1 else 0 end as int) status_id
, enum_status_production_retur.status_production_retur_name status_name
, '' as KPBC
, '' as KODE_VALUTA
, -1 as SERI_BARANG
FROM dt_ms_production_retur INNER JOIN
dt_ms_production_retur_detail ON dt_ms_production_retur.ms_production_retur_id = dt_ms_production_retur_detail.ms_production_retur_id INNER JOIN
dt_ms_production_retur_h_status ON dt_ms_production_retur.ms_production_retur_h_status_id = dt_ms_production_retur_h_status.ms_production_retur_h_status_id INNER JOIN
enum_status_production_retur ON dt_ms_production_retur_h_status.status_production_retur_id = enum_status_production_retur.status_production_retur_id INNER JOIN
dt_ms_item_in_detail ON dt_ms_production_retur_detail.ms_production_retur_detail_id = dt_ms_item_in_detail.id_source INNER JOIN
enum_ms_mode_source_item_in_detail ON dt_ms_item_in_detail.mode_source = enum_ms_mode_source_item_in_detail.mode_source
WHERE (dt_ms_item_in_detail.mode_source = 5)
union all
SELECT
dt_ms_item_in_detail.ms_in_item_detail_id
,dt_ms_item_in_detail.mode_source as mode_source_2
,enum_ms_mode_source_item_in_detail.mode_source_name as mode_source_name_2
, 'STO' as car
, dt_ms_adj_sto.doc_code as bc_no
, dt_ms_adj_sto.doc_date as bc_date
, dt_ms_adj_sto.doc_code as receive_no
, dt_ms_adj_sto.doc_date as receive_date
, cast(case when dt_ms_adj_sto_h_status.status_adj_sto_id =1 then 1 else 0 end as int) status_id
, enum_ms_status_adj_sto.status_adj_sto_name status_name
, '' as KPBC
, '' as KODE_VALUTA
, -1 as SERI_BARANG
FROM enum_ms_mode_source_item_in_detail INNER JOIN
dt_ms_item_in_detail ON enum_ms_mode_source_item_in_detail.mode_source = dt_ms_item_in_detail.mode_source INNER JOIN
dt_ms_adj_sto INNER JOIN
dt_ms_adj_sto_h_status ON dt_ms_adj_sto.ms_adj_sto_h_status_id = dt_ms_adj_sto_h_status.ms_adj_sto_h_status_id INNER JOIN
enum_ms_status_adj_sto ON dt_ms_adj_sto_h_status.status_adj_sto_id = enum_ms_status_adj_sto.status_adj_sto_id ON dt_ms_item_in_detail.id_source_header = dt_ms_adj_sto.ms_adj_sto_id
WHERE (dt_ms_item_in_detail.mode_source = 3)
)
SELECT
dt_ms_item_in_detail.ms_in_item_detail_id
, dt_ms_item_in_detail.mode_source
, enum_ms_mode_source_item_in_detail.mode_source_name
, _header.mode_source_2
,_header.mode_source_name_2
,_header.car
,_header.bc_no
,_header.bc_date
,_header.receive_no
,_header.receive_date
,_header.status_id
,_header.status_name
,_header.KPBC
,_header.KODE_VALUTA
,_header.SERI_BARANG
,dt_ms_item_in_detail.quantity_pakai
,isnull(dt_ms_item_in_detail.quantity_pakai,0) -( isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.plan_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.plan_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.plan_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.plan_qty end ,0)
) as quantity_sisa
,isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.out_qty end ,0)
+ isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.out_qty end ,0) as qty_out
, isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.plan_qty end,0)
+ isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.plan_qty end,0)
+ isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.plan_qty end,0)
+ isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.plan_qty end ,0) as qty_plan
,isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.out_qty end,0) as car_line_out
,isnull(case when vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_car_line.plan_qty end,0) as car_line_plan
,isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.out_qty end,0) as memo_out
,isnull(case when vw_ms_item_in_sum_to_memo.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_memo.plan_qty end,0) as memo_plan
,isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.out_qty end,0) as sto_out
,isnull(case when vw_ms_item_in_sum_to_sto.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_sto.plan_qty end,0) as sto_plan
,isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.out_qty end,0) as adjustment_out
,isnull(case when vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id is null then 0 else vw_ms_item_in_sum_to_adjustment.plan_qty end,0) as adjustment_plan
, vw_ms_item.ms_type_id
, vw_ms_item.ms_item_custom_no
, vw_ms_item.ms_item_base_no
, vw_ms_item.part_no
, vw_ms_item.part_name
, vw_ms_item.uom
, dt_ms_item_in_detail.ori_ms_in_item_detail_id
, dt_ms_item_in_detail.id_source_header
, dt_ms_item_in_detail.ms_item_id
, vw_ms_item.allow_to_production
, vw_ms_item.mandatory_car_line
, vw_ms_item.allow_to_scrap
, vw_ms_item.allow_to_repair
, vw_ms_item.allow_to_selling
FROM enum_ms_mode_source_item_in_detail INNER JOIN
dt_ms_item_in_detail ON enum_ms_mode_source_item_in_detail.mode_source = dt_ms_item_in_detail.mode_source INNER JOIN
vw_ms_item_no_log AS vw_ms_item ON dt_ms_item_in_detail.ms_item_id = vw_ms_item.ms_item_id INNER JOIN
--(SELECT dt_ms_item_in_detail.ms_in_item_detail_id) AS
_header ON dt_ms_item_in_detail.ms_in_item_detail_id = _header.ms_in_item_detail_id LEFT OUTER JOIN
vw_ms_item_in_sum_to_sto ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_sto.ms_in_item_detail_id LEFT OUTER JOIN
vw_ms_item_in_sum_to_adjustment ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id LEFT OUTER JOIN
vw_ms_item_in_sum_to_memo ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_memo.ms_in_item_detail_id LEFT OUTER JOIN
vw_ms_item_in_sum_to_car_line ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id
--SELECT
-- dt_ms_item_in_detail.ms_in_item_detail_id
--, dt_ms_item_in_detail.mode_source
--, enum_ms_mode_source_item_in_detail.mode_source_name
--, cast(case when dt_ms_item_in_detail.mode_source =1 then 100 + isnull(dt_ms_item_list_sta.source_sta_id,0)
-- when dt_ms_item_in_detail.mode_source =2 then 100 + cast(isnull(dt_ms_tpb_in_header.KODE_DOKUMEN_PABEAN ,'0') as int)
-- else dt_ms_item_in_detail.mode_source
-- end as int) as mode_source_2
--,cast( case when dt_ms_item_in_detail.mode_source =1 then case when dt_ms_item_list_sta.source_sta_id=0 then cast(dt_ms_item_list_sta.source_sta_id as varchar(255)) else 'BC ' + cast(dt_ms_item_list_sta.source_sta_id as varchar(255)) end
-- when dt_ms_item_in_detail.mode_source =2 then 'BC ' + dt_ms_tpb_in_header.KODE_DOKUMEN_PABEAN
-- when dt_ms_item_in_detail.mode_source =5 then 'RETUR'
-- else ''
-- end as varchar(255)) as mode_source_name_2
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.CAR
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.NOMOR_AJU
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur_detail.retur_info
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_item_in_detail.info
-- else ''
-- end as varchar(255)) as car
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.BC_NO
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.NOMOR_DAFTAR
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur.retur_no
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_adj_sto.doc_code
-- else ''
-- end as varchar(255)) as bc_no
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.BC_DATE
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.TANGGAL_DAFTAR
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur.retur_date
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_adj_sto.doc_date
-- else ''
-- end as date) as bc_date
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.receive_no
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.receive_no
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur.retur_no
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_adj_sto.doc_code
-- else ''
-- end as varchar(255)) as receive_no
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.receive_date
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.receive_date
-- when dt_ms_item_in_detail.mode_source =5 then dt_ms_production_retur.retur_date
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then dt_ms_adj_sto.doc_date
-- else ''
-- end as date) as receive_date
--,cast( case when dt_ms_item_in_detail.mode_source =1 then 1
-- when dt_ms_item_in_detail.mode_source =2 then case when dt_ms_tpb_in_header_h_status.status_tpb_in_id=3 then 1 else 0 end
-- when dt_ms_item_in_detail.mode_source =5 then case when dt_ms_production_retur_h_status.ms_production_retur_id=1 then 1 else 0 end
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then case when dt_ms_adj_sto_h_status.status_adj_sto_id =1 then 1 else 0 end
-- else 0
-- end as int) as status_id
--,cast( case when dt_ms_item_in_detail.mode_source =1 then 'FINISH'
-- when dt_ms_item_in_detail.mode_source =2 then enum_ms_status_tpb_in.status_tpb_in_name
-- when dt_ms_item_in_detail.mode_source =5 then enum_status_production_retur.status_production_retur_name
-- when dt_ms_item_in_detail.mode_source =3 or dt_ms_item_in_detail.mode_source =3 then enum_ms_status_adj_sto.status_adj_sto_name
-- else ''
-- end as varchar(255)) as status_name
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.KODE_KANTOR
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.KODE_KANTOR
-- else ''
-- end as varchar(255)) as KPBC
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.KODE_VALUTA
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_header.KODE_VALUTA
-- else ''
-- end as varchar(255)) as KODE_VALUTA
--,cast( case when dt_ms_item_in_detail.mode_source =1 then dt_ms_item_list_sta.SERI_BARANG
-- when dt_ms_item_in_detail.mode_source =2 then dt_ms_tpb_in_barang.SERI_BARANG
-- else ''
-- end as varchar(255)) as SERI_BARANG
--,dt_ms_item_in_detail.quantity_pakai
--,isnull(dt_ms_item_in_detail.quantity_pakai,0) -( isnull(vw_ms_item_in_sum_to_car_line.out_qty,0)
-- + isnull(vw_ms_item_in_sum_to_memo.out_qty,0)
-- + isnull(vw_ms_item_in_sum_to_car_line.plan_qty,0)
-- + isnull(vw_ms_item_in_sum_to_memo.plan_qty,0)
-- + isnull(vw_ms_item_in_sum_to_sto.out_qty,0)
-- + isnull(vw_ms_item_in_sum_to_sto.plan_qty,0)
-- + isnull(vw_ms_item_in_sum_to_adjustment.out_qty,0)
-- + isnull(vw_ms_item_in_sum_to_adjustment.plan_qty,0)
-- ) as quantity_sisa
--,isnull(vw_ms_item_in_sum_to_car_line.out_qty,0) + isnull(vw_ms_item_in_sum_to_memo.out_qty,0) + isnull(vw_ms_item_in_sum_to_sto.out_qty,0) + isnull(vw_ms_item_in_sum_to_adjustment.out_qty,0) as qty_out
--,isnull(vw_ms_item_in_sum_to_car_line.plan_qty,0) + isnull(vw_ms_item_in_sum_to_memo.plan_qty,0) + isnull(vw_ms_item_in_sum_to_sto.plan_qty,0) + isnull(vw_ms_item_in_sum_to_adjustment.plan_qty,0) as qty_plan
--,isnull(vw_ms_item_in_sum_to_car_line.out_qty,0) as car_line_out
--,isnull(vw_ms_item_in_sum_to_car_line.plan_qty,0) as car_line_plan
--,isnull(vw_ms_item_in_sum_to_memo.out_qty,0) as memo_out
--,isnull(vw_ms_item_in_sum_to_memo.plan_qty,0) as memo_plan
--,isnull(vw_ms_item_in_sum_to_sto.out_qty,0) as sto_out
--,isnull(vw_ms_item_in_sum_to_sto.plan_qty,0) as sto_plan
--,isnull(vw_ms_item_in_sum_to_adjustment.out_qty,0) as adjustment_out
--,isnull(vw_ms_item_in_sum_to_adjustment.plan_qty,0) as adjustment_plan
--, vw_ms_item.ms_type_id
--, vw_ms_item.ms_item_custom_no
--, vw_ms_item.ms_item_base_no
--, vw_ms_item.part_no
--, vw_ms_item.part_name
--, vw_ms_item.uom
--, dt_ms_item_in_detail.ori_ms_in_item_detail_id
--, dt_ms_item_in_detail.id_source_header
--, dt_ms_item_in_detail.ms_item_id
--, vw_ms_item.allow_to_production
--, vw_ms_item.mandatory_car_line
--, vw_ms_item.allow_to_scrap
--, vw_ms_item.allow_to_repair
--, vw_ms_item.allow_to_selling
--FROM enum_ms_mode_source_item_in_detail INNER JOIN
-- dt_ms_item_in_detail ON enum_ms_mode_source_item_in_detail.mode_source = dt_ms_item_in_detail.mode_source INNER JOIN
-- vw_ms_item ON dt_ms_item_in_detail.ms_item_id = vw_ms_item.ms_item_id LEFT OUTER JOIN
-- dt_ms_adj_sto INNER JOIN
-- dt_ms_adj_sto_h_status ON dt_ms_adj_sto.ms_adj_sto_h_status_id = dt_ms_adj_sto_h_status.ms_adj_sto_h_status_id INNER JOIN
-- enum_ms_status_adj_sto ON dt_ms_adj_sto_h_status.status_adj_sto_id = enum_ms_status_adj_sto.status_adj_sto_id ON dt_ms_item_in_detail.id_source_header = dt_ms_adj_sto.ms_adj_sto_id LEFT OUTER JOIN
-- enum_ms_status_tpb_in INNER JOIN
-- dt_ms_tpb_in_header INNER JOIN
-- dt_ms_tpb_in_barang ON dt_ms_tpb_in_header.ID_HEADER = dt_ms_tpb_in_barang.ID_HEADER INNER JOIN
-- dt_ms_tpb_in_header_h_status ON dt_ms_tpb_in_header.dt_ms_tpb_in_header_h_status_id = dt_ms_tpb_in_header_h_status.dt_ms_tpb_in_header_h_status_id ON
-- enum_ms_status_tpb_in.status_tpb_in_id = dt_ms_tpb_in_header_h_status.status_tpb_in_id ON dt_ms_item_in_detail.id_source = dt_ms_tpb_in_barang.ID LEFT OUTER JOIN
-- dt_ms_item_list_sta ON dt_ms_item_in_detail.id_source = dt_ms_item_list_sta.ms_item_list_sta_id LEFT OUTER JOIN
-- dt_ms_production_retur INNER JOIN
-- dt_ms_production_retur_detail ON dt_ms_production_retur.ms_production_retur_id = dt_ms_production_retur_detail.ms_production_retur_id INNER JOIN
-- dt_ms_production_retur_h_status ON dt_ms_production_retur.ms_production_retur_h_status_id = dt_ms_production_retur_h_status.ms_production_retur_h_status_id INNER JOIN
-- enum_status_production_retur ON dt_ms_production_retur_h_status.status_production_retur_id = enum_status_production_retur.status_production_retur_id ON
-- dt_ms_item_in_detail.id_source = dt_ms_production_retur_detail.ms_production_retur_detail_id LEFT OUTER JOIN
-- vw_ms_item_in_sum_to_sto ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_sto.ms_in_item_detail_id LEFT OUTER JOIN
-- vw_ms_item_in_sum_to_adjustment ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_adjustment.ms_in_item_detail_id LEFT OUTER JOIN
-- vw_ms_item_in_sum_to_memo ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_memo.ms_in_item_detail_id LEFT OUTER JOIN
-- vw_ms_item_in_sum_to_car_line ON dt_ms_item_in_detail.ms_in_item_detail_id = vw_ms_item_in_sum_to_car_line.ms_in_item_detail_id
GO
Depends On
20- dbo.dt_ms_item_list_sta
- dbo.enum_ms_mode_source_item_in_detail
- dbo.dt_ms_item_in_detail
- dbo.enum_ms_status_tpb_in
- dbo.dt_ms_tpb_in_header
- dbo.dt_ms_tpb_in_barang
- dbo.dt_ms_tpb_in_header_h_status
- dbo.dt_ms_production_retur
- dbo.dt_ms_production_retur_detail
- dbo.dt_ms_production_retur_h_status
- dbo.enum_status_production_retur
- dbo.dt_ms_adj_sto
- dbo.dt_ms_adj_sto_h_status
- dbo.enum_ms_status_adj_sto
- dbo.vw_ms_item_no_log
- dbo.vw_ms_item
- dbo.vw_ms_item_in_sum_to_sto
- dbo.vw_ms_item_in_sum_to_adjustment
- dbo.vw_ms_item_in_sum_to_memo
- dbo.vw_ms_item_in_sum_to_car_line
Used By
19- dbo.vw_ms_adjustment_detail
- dbo.vw_ms_adjustment_item
- dbo.vw_ms_memo_detail_suplly_source_stock
- dbo.vw_ms_out_car_line_detail_suplly
- dbo.vw_ms_production_in_detail_with_source
- dbo.vw_ms_sto_detail
- dbo.vw_ms_sto_item
- dbo.MG_MS_ADJUSTMENT_DETAIL_ADD
- dbo.MG_MS_ADJUSTMENT_DETAIL_EDIT
- dbo.MG_MS_ADJUSTMENT_HEADER_EDIT
- dbo.MG_MS_MEMO_DETAIL_SUPPLY_ADD
- dbo.MG_MS_MEMO_DETAIL_SUPPLY_EDIT
- dbo.MG_MS_OUT_CAR_LINE_DETAIL_SUPPLY_ADD
- dbo.MG_MS_STO_DETAIL_ADD
- dbo.MG_MS_STO_DETAIL_EDIT
- dbo.MG_MS_STO_HEADER_EDIT
- dbo.fn_ms_auto_supply_production
- dbo.vw_fn_ms_mutasi_mesin
- dbo.vw_fn_ms_mutasi_mesin_test