top of page
Traceability (1) - Automated Stock Barcode Solution

The first step of traceability is to create the barcode coding of the inventory code to be defined in the existing ERP system.

In this context, defining separate barcodes for each stock defined on NETSIS, and the controllability of the unit of measure in this coding will make the process even more complicated.

All these operations will be defined automatically with the Triger definition given below to the TBLSTSABIT table where inventory definitions are performed on Netsis and possible errors will be prevented.

A coding standard has been established on the trigger based on "KG" and "PCS" sized units.

================================================== ================================ CREATE TRIGGER [dbo]. [BARCODOLUSTUR] ON
[dbo]. [TBLSTSABIT] FOR INSERT, UPDATE
AS BEGIN
DECLARE @STOKKODU TDBSTOKKOD
DECLARE @ OLCUBR1 VARCHAR (2)
DECLARE @BARKODNO VARCHAR (35)
DECLARE @TARIH SMALLDATETIME
SELECT @ TARIH = CAST (FLOOR (CAST (GETDATE () AS FLOAT)) AS SMALLDATETIME)
DECLARE STOCK CODE_CRS cursor for
SELECT STOCK_ CODE, OLCU_BR1
FROM INSERTED with (NOLOCK)
OPEN STOCK CODE_CRS
FETCH STOKKODU_CRS into
@ STOCK CODE, @ OLCUBR1
WHILE (@@ FETCH_STATUS <> -1) BEGIN
IF ISNULL ((SELECT COUNT (*) FROM TBLSTOKBAR WHERE STOCK_ CODE = @ STOCK CODE), 0) <> 0
GOTO DONE
IF UPPER (ISNULL (@ OLCUBR1, '')) = 'KG' or UPPER (ISNULL (@ OLCUBR1, '')) = 'MT' or UPPER (ISNULL (@ OLCUBR1, '')) = 'LT' or UPPER (ISNULL (@ OLCUBR1, '')) = 'M2'
GOTO FIRST ARTICLE_28
IF UPPER (ISNULL (@ OLCUBR1, '')) = 'KT' OR UPPER (ISNULL (@ OLCUBR1, '')) = 'TK' OR UPPER (ISNULL (@ OLCUBR1, '')) = 'VR' OR UPPER (ISNULL (@ OLCUBR1, '')) = 'TB' OR UPPER (ISNULL (@ OLCUBR1, '')) = 'PK' OR UPPER (ISNULL (@ OLCUBR1, '')) = 'AD' OR UPPER (ISNULL (@ OLCUBR1, '')) = 'PL'
GOTO FIRST ARTICLE_29
-------------------------------------------------- -------------------------------------------------- -----------
GOTO DONE
-------------------------------------------------- -------------------------------------------------- -----------
FIRST ARTICLE_28:
SELECT @BARKODNO = '28' + RIGHT ('00000' + (SELECT CAST (CAST (MAX (RIGHT (BARKOD, 5)) AS INT) +1 AS VARCHAR) FROM TBLSTOKBAR WHERE LEN (BARKOD) = 7 AND BARKOD LIKE ' 28% '), 5)
INSERT INTO TBLSTOKBAR
(STOK_KODU, BARCODE, BARTIP, BARTARIH, I_YEDEK1)
VALUES (@ STOKKODU, @ BARKODNO, 'T', @ DATE, '1')
GOTO DONE
-------------------------------------------------- -------------------------------------------------- -----------
FIRST ARTICLE_29:
SELECT @BARKODNO = '29' + RIGHT ('00000' + (SELECT CAST (CAST (MAX (RIGHT (BARKOD, 5)) AS INT) +1 AS VARCHAR) FROM TBLSTOKBAR WHERE LEN (BARKOD) = 7 AND BARKOD LIKE ' 29% '), 5)
INSERT INTO TBLSTOKBAR
(STOK_KODU, BARCODE, BARTIP, BARTARIH, I_YEDEK1)
VALUES (@ STOKKODU, @ BARKODNO, 'T', @ DATE, '1')
GOTO DONE
-------------------------------------------------- -------------------------------------------------- -----------
DONE:
fetch STOKKODU_CRS into
@ STOCK CODE, @ OLCUBR1
end
close STOK CODE_CRS
deallocate STOCK CODE_CRS
end

bottom of page