Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
| Name | Data Type | Length | Description |
|---|---|---|---|
| @PARAMETER | xml | -1 |
SQL Script
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
create procedure dbo.MG_MS_ITEM_CUSTOM_EDIT
@PARAMETER xml=''
---XencX---with encryption
as
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @pemisah varchar(255)
declare @pemisah_replace varchar(255)
set @pemisah_replace='<br />'
--set @pemisah=CHAR(13) + CHAR(10) + '
'
set @pemisah = '
'
declare @resultX varchar(max)
declare @resultX2 varchar(max)
declare @XmlSts xml
declare @raw xml
declare @xStsnoheader varchar(2),
@xStsno varchar(2),
@xStsdes varchar(max)
set @xStsnoheader='07'
set @xStsno='00';
set @xStsdes='sukses'
BEGIN TRY
SET NOCOUNT ON
DECLARE @NOW datetime
set @NOW =GETDATE()
DECLARE
@data_by varchar(50)
,@ms_item_custom_no_old varchar(50)
,@ms_item_custom_no varchar(50)
,@ms_item_custom_name varchar(255)
,@nomor_hs varchar(50)
,@tarif_bm decimal(18,4)
,@tarif_cukai decimal(18,4)
,@tarif_pph decimal(18,4)
,@tarif_ppn decimal(18,4)
,@tarif_ppnbm decimal(18,4)
SELECT
@data_by=left(ltrim(rtrim(isnull(tempTable.item.value('data_by[1]', 'varchar(100)'),''))),50)
,@ms_item_custom_no_old=left(ltrim(rtrim(isnull(tempTable.item.value('ms_item_custom_no_old[1]', 'varchar(100)'),''))),50)
,@ms_item_custom_no=left(ltrim(rtrim(isnull(tempTable.item.value('ms_item_custom_no[1]', 'varchar(100)'),''))),50)
,@ms_item_custom_name=left(ltrim(rtrim(isnull(tempTable.item.value('ms_item_custom_name[1]', 'varchar(305)'),''))),255)
,@nomor_hs=left(ltrim(rtrim(isnull(tempTable.item.value('nomor_hs[1]', 'varchar(100)'),''))),50)
,@tarif_bm=dbo.StrToDec4(isnull( tempTable.item.value('tarif_bm[1]', 'varchar(255)'),'0'))
,@tarif_cukai=dbo.StrToDec4(isnull( tempTable.item.value('tarif_cukai[1]', 'varchar(255)'),'0'))
,@tarif_pph=dbo.StrToDec4(isnull( tempTable.item.value('tarif_pph[1]', 'varchar(255)'),'0'))
,@tarif_ppn=dbo.StrToDec4(isnull( tempTable.item.value('tarif_ppn[1]', 'varchar(255)'),'0'))
,@tarif_ppnbm=dbo.StrToDec4(isnull( tempTable.item.value('tarif_ppnbm[1]', 'varchar(255)'),'0'))
FROM @PARAMETER.nodes('param/field') tempTable(item)
if @ms_item_custom_no =''
begin
set @xStsno='02';
set @xStsdes='Gagal, Custom Part No tidak boleh kosong' ;
goto f
end
if (
SELECT COUNT(*) AS Expr1
FROM dt_ms_item_custom
WHERE (ms_item_custom_no = @ms_item_custom_no) and (ms_item_custom_no <> @ms_item_custom_no_old)) >0
begin
set @xStsno='02';
set @xStsdes='Gagal, Custom Part No Sudah terdaftar , gunakan Custom part no lainnya' ;
goto f
end
if @ms_item_custom_name =''
begin
set @xStsno='02';
set @xStsdes='Gagal, Custom Part Name tidak boleh kosong' ;
goto f
end
if @nomor_hs =''
begin
set @xStsno='02';
set @xStsdes='Gagal, HS code tidak boleh kosong' ;
goto f
end
-- declare @bc_prefix varchar(25)
--declare @c_id_header bigint
--,@c_status_tpb_out_id int
--,@c_status_tpb_out_name varchar(255)
--,@c_NOMOR_AJU varchar(255)
--,@c_TANGGAL_DAFTAR date
--,@c_NOMOR_DAFTAR varchar(255)
--,@c_ID_HEADER_ORI bigint
-- declare @c_KODE_STATUS varchar(10)
--if @c_id_header =-1
--begin
-- set @xStsno='02';
-- set @xStsdes='Gagal, Header dokumen tidak di temukan(-1)' ;
-- goto f
--end
declare @ms_item_custom_h_tarif_id bigint=-1
BEGIN TRANSACTION;
if (SELECT COUNT(*) AS Expr1
FROM vw_ms_part_custom
WHERE (ms_item_custom_no = @ms_item_custom_no_old) AND (nomor_hs = @nomor_hs) AND (tarif_bm = @tarif_bm) AND (tarif_ppnbm = @tarif_ppnbm) AND (tarif_pph = @tarif_pph) AND (tarif_ppn = @tarif_ppn) AND
(tarif_cukai = @tarif_cukai))=0
begin
INSERT INTO dt_ms_item_custom_h_tarif
(ms_item_custom_no, nomor_hs, tarif_bm, tarif_cukai, tarif_pph, tarif_ppn, tarif_ppnbm, create_date, create_by)
VALUES (@ms_item_custom_no_old,@nomor_hs,@tarif_bm,@tarif_cukai,@tarif_pph,@tarif_ppn,@tarif_ppnbm,@now,@data_by)
set @ms_item_custom_h_tarif_id=SCOPE_IDENTITY();
end
UPDATE dt_ms_item_custom
SET ms_item_custom_no = @ms_item_custom_no
, ms_item_custom_name = @ms_item_custom_name
, ms_item_custom_h_tarif_id=case when @ms_item_custom_h_tarif_id=-1 then ms_item_custom_h_tarif_id else @ms_item_custom_h_tarif_id end
WHERE (ms_item_custom_no = @MS_ITEM_CUSTOM_NO_OLD)
if not(@ms_item_custom_no=@ms_item_custom_no_old)
begin
UPDATE dt_ms_item
SET ms_item_custom_no = @ms_item_custom_no
WHERE (ms_item_custom_no = @ms_item_custom_no_old)
UPDATE dt_ms_item_custom_h_tarif
SET ms_item_custom_no = @ms_item_custom_no
WHERE (ms_item_custom_no = @ms_item_custom_no_old)
end
COMMIT TRANSACTION;
f:
set nocount off
END TRY
BEGIN CATCH
IF (@@TRANCOUNT > 0) ROLLBACK TRAN;
set @xStsno='88'
set @xStsdes= ERROR_MESSAGE()
END CATCH
g:
set @XmlSts=(select @xStsnoheader + @xStsno as 'no', @xStsdes as 'des' for xml path('sts'))
select CAST( (select @XmlSts,isnull(@raw ,'') for xml path ('result')
) as XML) as dt
--GO
--EXEC MG_MS_ITEM_CUSTOM_EDIT
--'1 2 json 2 ::1 ABA01 27 8 10007 '
GO
GO
create procedure dbo.MG_MS_ITEM_CUSTOM_EDIT
@PARAMETER xml=''
---XencX---with encryption
as
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @pemisah varchar(255)
declare @pemisah_replace varchar(255)
set @pemisah_replace='<br />'
--set @pemisah=CHAR(13) + CHAR(10) + '
'
set @pemisah = '
'
declare @resultX varchar(max)
declare @resultX2 varchar(max)
declare @XmlSts xml
declare @raw xml
declare @xStsnoheader varchar(2),
@xStsno varchar(2),
@xStsdes varchar(max)
set @xStsnoheader='07'
set @xStsno='00';
set @xStsdes='sukses'
BEGIN TRY
SET NOCOUNT ON
DECLARE @NOW datetime
set @NOW =GETDATE()
DECLARE
@data_by varchar(50)
,@ms_item_custom_no_old varchar(50)
,@ms_item_custom_no varchar(50)
,@ms_item_custom_name varchar(255)
,@nomor_hs varchar(50)
,@tarif_bm decimal(18,4)
,@tarif_cukai decimal(18,4)
,@tarif_pph decimal(18,4)
,@tarif_ppn decimal(18,4)
,@tarif_ppnbm decimal(18,4)
SELECT
@data_by=left(ltrim(rtrim(isnull(tempTable.item.value('data_by[1]', 'varchar(100)'),''))),50)
,@ms_item_custom_no_old=left(ltrim(rtrim(isnull(tempTable.item.value('ms_item_custom_no_old[1]', 'varchar(100)'),''))),50)
,@ms_item_custom_no=left(ltrim(rtrim(isnull(tempTable.item.value('ms_item_custom_no[1]', 'varchar(100)'),''))),50)
,@ms_item_custom_name=left(ltrim(rtrim(isnull(tempTable.item.value('ms_item_custom_name[1]', 'varchar(305)'),''))),255)
,@nomor_hs=left(ltrim(rtrim(isnull(tempTable.item.value('nomor_hs[1]', 'varchar(100)'),''))),50)
,@tarif_bm=dbo.StrToDec4(isnull( tempTable.item.value('tarif_bm[1]', 'varchar(255)'),'0'))
,@tarif_cukai=dbo.StrToDec4(isnull( tempTable.item.value('tarif_cukai[1]', 'varchar(255)'),'0'))
,@tarif_pph=dbo.StrToDec4(isnull( tempTable.item.value('tarif_pph[1]', 'varchar(255)'),'0'))
,@tarif_ppn=dbo.StrToDec4(isnull( tempTable.item.value('tarif_ppn[1]', 'varchar(255)'),'0'))
,@tarif_ppnbm=dbo.StrToDec4(isnull( tempTable.item.value('tarif_ppnbm[1]', 'varchar(255)'),'0'))
FROM @PARAMETER.nodes('param/field') tempTable(item)
if @ms_item_custom_no =''
begin
set @xStsno='02';
set @xStsdes='Gagal, Custom Part No tidak boleh kosong' ;
goto f
end
if (
SELECT COUNT(*) AS Expr1
FROM dt_ms_item_custom
WHERE (ms_item_custom_no = @ms_item_custom_no) and (ms_item_custom_no <> @ms_item_custom_no_old)) >0
begin
set @xStsno='02';
set @xStsdes='Gagal, Custom Part No Sudah terdaftar , gunakan Custom part no lainnya' ;
goto f
end
if @ms_item_custom_name =''
begin
set @xStsno='02';
set @xStsdes='Gagal, Custom Part Name tidak boleh kosong' ;
goto f
end
if @nomor_hs =''
begin
set @xStsno='02';
set @xStsdes='Gagal, HS code tidak boleh kosong' ;
goto f
end
-- declare @bc_prefix varchar(25)
--declare @c_id_header bigint
--,@c_status_tpb_out_id int
--,@c_status_tpb_out_name varchar(255)
--,@c_NOMOR_AJU varchar(255)
--,@c_TANGGAL_DAFTAR date
--,@c_NOMOR_DAFTAR varchar(255)
--,@c_ID_HEADER_ORI bigint
-- declare @c_KODE_STATUS varchar(10)
--if @c_id_header =-1
--begin
-- set @xStsno='02';
-- set @xStsdes='Gagal, Header dokumen tidak di temukan(-1)' ;
-- goto f
--end
declare @ms_item_custom_h_tarif_id bigint=-1
BEGIN TRANSACTION;
if (SELECT COUNT(*) AS Expr1
FROM vw_ms_part_custom
WHERE (ms_item_custom_no = @ms_item_custom_no_old) AND (nomor_hs = @nomor_hs) AND (tarif_bm = @tarif_bm) AND (tarif_ppnbm = @tarif_ppnbm) AND (tarif_pph = @tarif_pph) AND (tarif_ppn = @tarif_ppn) AND
(tarif_cukai = @tarif_cukai))=0
begin
INSERT INTO dt_ms_item_custom_h_tarif
(ms_item_custom_no, nomor_hs, tarif_bm, tarif_cukai, tarif_pph, tarif_ppn, tarif_ppnbm, create_date, create_by)
VALUES (@ms_item_custom_no_old,@nomor_hs,@tarif_bm,@tarif_cukai,@tarif_pph,@tarif_ppn,@tarif_ppnbm,@now,@data_by)
set @ms_item_custom_h_tarif_id=SCOPE_IDENTITY();
end
UPDATE dt_ms_item_custom
SET ms_item_custom_no = @ms_item_custom_no
, ms_item_custom_name = @ms_item_custom_name
, ms_item_custom_h_tarif_id=case when @ms_item_custom_h_tarif_id=-1 then ms_item_custom_h_tarif_id else @ms_item_custom_h_tarif_id end
WHERE (ms_item_custom_no = @MS_ITEM_CUSTOM_NO_OLD)
if not(@ms_item_custom_no=@ms_item_custom_no_old)
begin
UPDATE dt_ms_item
SET ms_item_custom_no = @ms_item_custom_no
WHERE (ms_item_custom_no = @ms_item_custom_no_old)
UPDATE dt_ms_item_custom_h_tarif
SET ms_item_custom_no = @ms_item_custom_no
WHERE (ms_item_custom_no = @ms_item_custom_no_old)
end
COMMIT TRANSACTION;
f:
set nocount off
END TRY
BEGIN CATCH
IF (@@TRANCOUNT > 0) ROLLBACK TRAN;
set @xStsno='88'
set @xStsdes= ERROR_MESSAGE()
END CATCH
g:
set @XmlSts=(select @xStsnoheader + @xStsno as 'no', @xStsdes as 'des' for xml path('sts'))
select CAST( (select @XmlSts,isnull(@raw ,'') for xml path ('result')
) as XML) as dt
--GO
--EXEC MG_MS_ITEM_CUSTOM_EDIT
--'
GO
Depends On
5Used By
No items found