Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
| Name | Data Type | Length | Description |
|---|---|---|---|
| @id_hdr | bigint | 8 | |
| @doc_in_from_id | int | 4 |
SQL Script
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE PROCEDURE dbo.spu_bc23_to_inventory(@id_hdr as bigint, @doc_in_from_id int )
AS
BEGIN
declare @count int
set @count = (select COUNT(*) from dbo.tbl_bc_in_hdr where id_bc_in_hdr = @id_hdr)
if @count = 0
begin
select '01' as status, ' DATA NOT FOUND' as description
return
end
if (select COUNT(*) from dbo.tbl_data_in_hdr where tbl_data_in_hdr.id_terkait = @id_hdr and tbl_data_in_hdr.status='APPROVED' and doc_in_from_id=@doc_in_from_id) > 0
begin
select '02' as status, ' DATA SUDAH APPROVED DI RECEIVING' as description
return
end
if (select COUNT(*) from dbo.tbl_data_in_hdr where id_terkait = @id_hdr and doc_in_from_id=@doc_in_from_id) > 0
begin
select '03' as status, ' DATA SEDANG DIPROSES DI INVENTORY SILAHKAN CANCEL DAHULU' as description
return
end
BEGIN TRY
BEGIN TRANSACTION
UPDATE dbo.tbl_bc_in_hdr set statusdok = 'DATA SENT TO INVENTORY' where id_bc_in_hdr = @id_hdr
INSERT INTO tbl_bc_in_hdr_h_status
(id_bc_in_hdr, statusdok, status_date)
VALUES (@id_hdr, (select top 1 statusdok from tbl_bc_in_hdr where id_bc_in_hdr = @id_hdr), GETDATE())
select '00' as status, ' SUKSES UPDATED' as description
COMMIT
END TRY
BEGIN CATCH
-- Whoops, there was an error
IF @@TRANCOUNT > 0
ROLLBACK
-- Raise an error with the details of the exception
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
Set @ErrMsg = ERROR_MESSAGE()
set @ErrSeverity = ERROR_SEVERITY()
select @ErrMsg as description,@ErrSeverity as status
RAISERROR(@ErrMsg, @ErrSeverity, 1)
END CATCH
END
GO
GO
CREATE PROCEDURE dbo.spu_bc23_to_inventory(@id_hdr as bigint, @doc_in_from_id int )
AS
BEGIN
declare @count int
set @count = (select COUNT(*) from dbo.tbl_bc_in_hdr where id_bc_in_hdr = @id_hdr)
if @count = 0
begin
select '01' as status, ' DATA NOT FOUND' as description
return
end
if (select COUNT(*) from dbo.tbl_data_in_hdr where tbl_data_in_hdr.id_terkait = @id_hdr and tbl_data_in_hdr.status='APPROVED' and doc_in_from_id=@doc_in_from_id) > 0
begin
select '02' as status, ' DATA SUDAH APPROVED DI RECEIVING' as description
return
end
if (select COUNT(*) from dbo.tbl_data_in_hdr where id_terkait = @id_hdr and doc_in_from_id=@doc_in_from_id) > 0
begin
select '03' as status, ' DATA SEDANG DIPROSES DI INVENTORY SILAHKAN CANCEL DAHULU' as description
return
end
BEGIN TRY
BEGIN TRANSACTION
UPDATE dbo.tbl_bc_in_hdr set statusdok = 'DATA SENT TO INVENTORY' where id_bc_in_hdr = @id_hdr
INSERT INTO tbl_bc_in_hdr_h_status
(id_bc_in_hdr, statusdok, status_date)
VALUES (@id_hdr, (select top 1 statusdok from tbl_bc_in_hdr where id_bc_in_hdr = @id_hdr), GETDATE())
select '00' as status, ' SUKSES UPDATED' as description
COMMIT
END TRY
BEGIN CATCH
-- Whoops, there was an error
IF @@TRANCOUNT > 0
ROLLBACK
-- Raise an error with the details of the exception
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
Set @ErrMsg = ERROR_MESSAGE()
set @ErrSeverity = ERROR_SEVERITY()
select @ErrMsg as description,@ErrSeverity as status
RAISERROR(@ErrMsg, @ErrSeverity, 1)
END CATCH
END
GO
Used By
No items found