Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
| Name | Data Type | Length | Description |
|---|---|---|---|
| @datadiff | varchar | -1 | |
| @cmd | varchar | 10 | |
| @typebc | varchar | 10 |
SQL Script
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE PROCEDURE dbo.spi_invoiceupdatebl_bc40_27
(@datadiff varchar(max), @cmd varchar(10), @typebc varchar(10))
AS
BEGIN
declare @datasplit varchar(8000)
declare @noblc varchar(50)
declare @tgblc date
declare @nobl varchar(50)
declare @tgbl date
-- if (select COUNT(*) as cnt from dbo.tbl_inv_hdr where nobl=@nobl and tgbl=@tgbl) > 0
-- begin
--select '01' as status, ' Data sudah diproses, silahkan cancel data jika ingin mengubah invoice' as description
--return
-- end
if @cmd='cancel'
begin
declare @inv_hdr_id bigint
DECLARE b_cursor CURSOR FOR select f_result from dbo.fn_ParseCSVString (@datadiff, '|')
OPEN b_cursor
FETCH NEXT FROM b_cursor INTO @datasplit
WHILE @@FETCH_STATUS = 0
BEGIN -- begin here
set @inv_hdr_id = (select data from dbo.Split(@datasplit, ',') where id=1)
if (select COUNT(*) as cnt FROM [dbo].[tbl_bc_in_hdr] where [nobl]= (select data from dbo.Split(@datasplit, ',') where id=3) and [typedok]=@typebc) >0
begin
select '02' as status, ' Ada data yang sudah diproses menjadi data bc, '+CHAR(13)+CHAR(10)+' silahkan cancel data BC jika ingin mengubah invoice '+CHAR(13)+CHAR(10)+(select data from dbo.Split(@datasplit, ',') where id=2) as description
CLOSE b_cursor
DEALLOCATE b_cursor
return
end
FETCH NEXT FROM b_cursor INTO @datasplit
END
CLOSE b_cursor
DEALLOCATE b_cursor
set @noblc = '-'
DECLARE a_cursor CURSOR FOR select f_result from dbo.fn_ParseCSVString (@datadiff, '|')
OPEN a_cursor
FETCH NEXT FROM a_cursor INTO @datasplit
WHILE @@FETCH_STATUS = 0
BEGIN -- begin here
update dbo.tbl_inv_hdr set nobl = @noblc, tgbl = null where [inv_hdr_id] = (select data from dbo.Split(@datasplit, ',') where id=1)
FETCH NEXT FROM a_cursor INTO @datasplit
END
CLOSE a_cursor
DEALLOCATE a_cursor
select '00' as status, ' SUKSES CANCLED' as description
end
if @cmd='proses'
begin
if (select COUNT(*) as cnt from dbo.tbl_bc_in_hdr where nobl=@nobl and tglbl=@tgbl) > 0
begin
select '02' as status, ' Data sudah diproses menjadi data bc, '+CHAR(13)+CHAR(10)+' silahkan recalculate data jika ingin mengubah invoice' as description
return
end
DECLARE c_cursor CURSOR FOR select f_result from dbo.fn_ParseCSVString (@datadiff, '|')
OPEN c_cursor
FETCH NEXT FROM c_cursor INTO @datasplit
WHILE @@FETCH_STATUS = 0
BEGIN -- begin here
if (select count(*) from dbo.tbl_inv_hdr where [inv_hdr_id] = (select data from dbo.Split(@datasplit, ',') where id=1) and nobl <> '-') > 0
begin
select '02' as status, ' Data sudah diproses, Silahkan Melakukan cancel' as description
return
end
FETCH NEXT FROM c_cursor INTO @datasplit
END
CLOSE c_cursor
DEALLOCATE c_cursor
set @tgbl = GETDATE()
declare @hasil varchar(50)
if @typebc = 'BC40'
begin
exec [dbo].[spu_seq] @nomor_untuk = N'noajubc40', @hasil = @hasil OUTPUT
set @nobl = 'BC40'+@hasil
end
-- if @typebc = 'BC40'
--begin
-- exec [dbo].[spu_seq] @nomor_untuk = N'noajubc40', @hasil = @hasil OUTPUT
-- set @nobl = 'BC40'+@hasil
--end
if @typebc = 'BC271'
begin
exec [dbo].[spu_seq] @nomor_untuk = N'noajubc271', @hasil = @hasil OUTPUT
set @nobl = @hasil
end
DECLARE a_cursor CURSOR FOR select f_result from dbo.fn_ParseCSVString (@datadiff, '|')
OPEN a_cursor
FETCH NEXT FROM a_cursor INTO @datasplit
WHILE @@FETCH_STATUS = 0
BEGIN -- begin here
set @noblc = @nobl
set @tgblc = @tgbl
update dbo.tbl_inv_hdr set nobl = @noblc, tgbl = @tgblc where [inv_hdr_id] = (select data from dbo.Split(@datasplit, ',') where id=1)
FETCH NEXT FROM a_cursor INTO @datasplit
END
CLOSE a_cursor
DEALLOCATE a_cursor
select '00' as status, ' SUKSES UPDATED' as description
end
END
GO
GO
CREATE PROCEDURE dbo.spi_invoiceupdatebl_bc40_27
(@datadiff varchar(max), @cmd varchar(10), @typebc varchar(10))
AS
BEGIN
declare @datasplit varchar(8000)
declare @noblc varchar(50)
declare @tgblc date
declare @nobl varchar(50)
declare @tgbl date
-- if (select COUNT(*) as cnt from dbo.tbl_inv_hdr where nobl=@nobl and tgbl=@tgbl) > 0
-- begin
--select '01' as status, ' Data sudah diproses, silahkan cancel data jika ingin mengubah invoice' as description
--return
-- end
if @cmd='cancel'
begin
declare @inv_hdr_id bigint
DECLARE b_cursor CURSOR FOR select f_result from dbo.fn_ParseCSVString (@datadiff, '|')
OPEN b_cursor
FETCH NEXT FROM b_cursor INTO @datasplit
WHILE @@FETCH_STATUS = 0
BEGIN -- begin here
set @inv_hdr_id = (select data from dbo.Split(@datasplit, ',') where id=1)
if (select COUNT(*) as cnt FROM [dbo].[tbl_bc_in_hdr] where [nobl]= (select data from dbo.Split(@datasplit, ',') where id=3) and [typedok]=@typebc) >0
begin
select '02' as status, ' Ada data yang sudah diproses menjadi data bc, '+CHAR(13)+CHAR(10)+' silahkan cancel data BC jika ingin mengubah invoice '+CHAR(13)+CHAR(10)+(select data from dbo.Split(@datasplit, ',') where id=2) as description
CLOSE b_cursor
DEALLOCATE b_cursor
return
end
FETCH NEXT FROM b_cursor INTO @datasplit
END
CLOSE b_cursor
DEALLOCATE b_cursor
set @noblc = '-'
DECLARE a_cursor CURSOR FOR select f_result from dbo.fn_ParseCSVString (@datadiff, '|')
OPEN a_cursor
FETCH NEXT FROM a_cursor INTO @datasplit
WHILE @@FETCH_STATUS = 0
BEGIN -- begin here
update dbo.tbl_inv_hdr set nobl = @noblc, tgbl = null where [inv_hdr_id] = (select data from dbo.Split(@datasplit, ',') where id=1)
FETCH NEXT FROM a_cursor INTO @datasplit
END
CLOSE a_cursor
DEALLOCATE a_cursor
select '00' as status, ' SUKSES CANCLED' as description
end
if @cmd='proses'
begin
if (select COUNT(*) as cnt from dbo.tbl_bc_in_hdr where nobl=@nobl and tglbl=@tgbl) > 0
begin
select '02' as status, ' Data sudah diproses menjadi data bc, '+CHAR(13)+CHAR(10)+' silahkan recalculate data jika ingin mengubah invoice' as description
return
end
DECLARE c_cursor CURSOR FOR select f_result from dbo.fn_ParseCSVString (@datadiff, '|')
OPEN c_cursor
FETCH NEXT FROM c_cursor INTO @datasplit
WHILE @@FETCH_STATUS = 0
BEGIN -- begin here
if (select count(*) from dbo.tbl_inv_hdr where [inv_hdr_id] = (select data from dbo.Split(@datasplit, ',') where id=1) and nobl <> '-') > 0
begin
select '02' as status, ' Data sudah diproses, Silahkan Melakukan cancel' as description
return
end
FETCH NEXT FROM c_cursor INTO @datasplit
END
CLOSE c_cursor
DEALLOCATE c_cursor
set @tgbl = GETDATE()
declare @hasil varchar(50)
if @typebc = 'BC40'
begin
exec [dbo].[spu_seq] @nomor_untuk = N'noajubc40', @hasil = @hasil OUTPUT
set @nobl = 'BC40'+@hasil
end
-- if @typebc = 'BC40'
--begin
-- exec [dbo].[spu_seq] @nomor_untuk = N'noajubc40', @hasil = @hasil OUTPUT
-- set @nobl = 'BC40'+@hasil
--end
if @typebc = 'BC271'
begin
exec [dbo].[spu_seq] @nomor_untuk = N'noajubc271', @hasil = @hasil OUTPUT
set @nobl = @hasil
end
DECLARE a_cursor CURSOR FOR select f_result from dbo.fn_ParseCSVString (@datadiff, '|')
OPEN a_cursor
FETCH NEXT FROM a_cursor INTO @datasplit
WHILE @@FETCH_STATUS = 0
BEGIN -- begin here
set @noblc = @nobl
set @tgblc = @tgbl
update dbo.tbl_inv_hdr set nobl = @noblc, tgbl = @tgblc where [inv_hdr_id] = (select data from dbo.Split(@datasplit, ',') where id=1)
FETCH NEXT FROM a_cursor INTO @datasplit
END
CLOSE a_cursor
DEALLOCATE a_cursor
select '00' as status, ' SUKSES UPDATED' as description
end
END
GO
Used By
No items found