Script out UET
When deploying an UET customization in Syteline 7 & 8, there is SP can be used to script out the UET. Just do
exec ExportUETClassSP ‘classname’
Some server don’t this SP installed. I just keep a copy here for in case
set ANSI_NULLS ON
set QUOTED_IDENTIFIER OFF
GOALTER PROCEDURE [dbo].[ExportUETClassSP] (
@PClassName Infobar
)
AS
DECLARE
@ClassName ClassNameType
, @ClassLabel LabelType
, @ClassDesc DescriptionType
, @SysHasFields ListYesNoType
, @SysHasTables ListYesNoType
, @SysApply UetSysApplyType
, @SysDelete ListYesNoType
, @FldName FldNameType
, @FldDataType UetDataTypeType
, @FldInitial UetDefaultType
, @FldDecimals UetScaleType
, @FldDesc ToolTipType
, @FldUDT sysname
, @FldPrec tinyint
, @IndexName IndexNameType
, @IndexDesc DescriptionType
, @IndexUnique ListYesNoType
, @IndexWord ListYesNoType
, @IndexSeq UetIndexSeqType
, @IndexAsc ListYesNoType
, @TableName TableNameType
, @TableRule QueryExpressionType
, @ExtendAllRecs ListYesNoType
, @AllowRecordAssoc ListYesNoType
, @Active ListYesNoType
, @SQLCmd InfobarType
, @SQLCmdWait InfobarType
, @Severity INT
, @Quote NCHAR(1)
, @RecordDate CurrentDateType
, @RowPointer RowPointerType
, @CommittedRowPointer RowPointerType
, @CreatedBy UsernameType
, @UpdatedBy UsernameType
, @CreateDate CurrentDateType
, @InWorkflow FlagNyType
SET @Severity = 0
SET @Quote = ””
DECLARE UserClassCrs CURSOR LOCAL STATIC
FOR SELECT
uc.class_name
, uc.class_label
, uc.class_desc
, uc.sys_has_fields
, uc.sys_has_tables
, uc.sys_apply
, uc.sys_delete
FROM user_class uc
WHERE class_name = @PClassName
OPEN UserClassCrs
WHILE @Severity = 0
BEGIN — cursor loop
FETCH UserClassCrs INTO
@ClassName
, @ClassLabel
, @ClassDesc
, @SysHasFields
, @SysHasTables
, @SysApply
, @SysDelete
IF @@FETCH_STATUS = -1
BREAK
SET @SQLCmd = ‘INSERT INTO user_class ( class_name, class_label,
class_desc, sys_has_fields, ‘
SET @SQLCmd = @SQLCmd + ‘sys_has_tables, sys_apply, sys_delete
) VALUES ( ‘
SET @SQLCmd = @SQLCmd + dbo.Quote(@ClassName) + ‘, ‘ +
dbo.Quote(@ClassLabel)
SET @SQLCmd = @SQLCmd + ‘, ‘ + dbo.Quote(@ClassDesc) + ‘, ‘ +
STR(ISNULL(@SysHasFields, 0))
SET @SQLCmd = @SQLCmd + ‘, ‘ + STR(ISNULL(@SysHasTables, 0)) +
‘, ‘ + dbo.Quote(@SysApply)
SET @SQLCmd = @SQLCmd + ‘, ‘ + STR(ISNULL(@SysDelete, 0)) + ‘ )’
print @SQLCmd
DECLARE UserClassFldCrs CURSOR LOCAL STATIC
FOR SELECT
ucf.class_name
, ucf.fld_name
, ucf.sys_apply
, ucf.sys_delete
FROM user_class_fld ucf
WHERE class_name = @PClassName
OPEN UserClassFldCrs
WHILE @Severity = 0
BEGIN — cursor loop
FETCH UserClassFldCrs INTO
@ClassName
, @FldName
, @SysApply
, @SysDelete
IF @@FETCH_STATUS = -1
BREAK
SET @SQLCmd = ‘INSERT INTO user_class_fld ( class_name,
fld_name, sys_apply, sys_delete ) VALUES ( ‘
SET @SQLCmd = @SQLCmd + dbo.Quote(@ClassName) + ‘, ‘ +
dbo.Quote(@FldName) + ‘, ‘ + dbo.Quote(@SysApply) + ‘, ‘ +
STR(ISNULL(@SysDelete, 0)) + ‘ )’
SET @SQLCmdWait = @SQLCmd
SELECT @FldName = fld_name
, @FldDataType = fld_data_type
, @FldInitial = fld_initial
, @FldDecimals = fld_decimals
, @FldDesc = fld_desc
, @SysApply = sys_apply
, @SysDelete = sys_delete
, @FldUDT = fld_UDT
, @FldPrec = fld_prec
FROM user_fld uf
WHERE uf.fld_name = @FldName
SET @SQLCmd = ‘INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete,
fld_UDT, fld_prec ) VALUES ( ‘
SET @SQLCmd = @SQLCmd + dbo.Quote(@FldName) + ‘, ‘ +
dbo.Quote(@FldDataType) + ‘, ‘ + dbo.Quote(@FldInitial)
SET @SQLCmd = @SQLCmd + ‘, ‘ + STR(ISNULL(@FldDecimals, 0)) +
‘, ‘ + dbo.Quote(@FldDesc) + ‘, ‘ + dbo.Quote(@SysApply)
SET @SQLCmd = @SQLCmd + ‘, ‘ + STR(ISNULL(@SysDelete, 0)) + ‘,
‘ + dbo.Quote(@FldUDT) + ‘, ‘ + STR(ISNULL(@FldPrec, 0)) + ‘ )’
PRINT @SQLCmd
PRINT @SQLCmdWait
END — Cursor Loop UserClassFld
CLOSE UserClassFldCrs
DEALLOCATE UserClassFldCrs
DECLARE UserIndexCrs CURSOR LOCAL STATIC
FOR SELECT
ui.class_name
, ui.index_name
, ui.index_desc
, ui.index_unique
, ui.index_word
, ui.sys_apply
, ui.sys_delete
FROM user_index ui
WHERE class_name = @PClassName
OPEN UserIndexCrs
WHILE @Severity = 0
BEGIN — cursor loop
FETCH UserIndexCrs INTO
@ClassName
, @IndexName
, @IndexDesc
, @IndexUnique
, @IndexWord
, @SysApply
, @SysDelete
IF @@FETCH_STATUS = -1
BREAK
SET @SQLCmd = ‘INSERT INTO user_index ( class_name, index_name,
index_desc, index_unique, index_word, sys_apply, sys_delete )
VALUES ( ‘
SET @SQLCmd = @SQLCmd + dbo.Quote(@ClassName) + ‘, ‘ +
dbo.Quote(@IndexName) + ‘, ‘ + dbo.Quote(@IndexDesc)
SET @SQLCmd = @SQLCmd + ‘, ‘ + STR(ISNULL(@IndexUnique, 0)) +
‘, ‘ + STR(ISNULL(@IndexWord, 0))
SET @SQLCmd = @SQLCmd + ‘, ‘ + dbo.Quote(@SysApply) + ‘, ‘ +
STR(ISNULL(@SysDelete, 0)) + ‘ )’
PRINT @SQLCmd
DECLARE UserIndexFldCrs CURSOR LOCAL STATIC
FOR SELECT
uif.class_name
, uif.index_name
, uif.index_seq
, uif.fld_name
, uif.index_asc
FROM user_index_fld uif
WHERE class_name = @PClassName
AND index_name = @IndexName
OPEN UserIndexFldCrs
WHILE @Severity = 0
BEGIN — cursor loop
FETCH UserIndexFldCrs INTO
@ClassName
, @IndexName
, @IndexSeq
, @FldName
, @IndexAsc
IF @@FETCH_STATUS = -1
BREAK
SET @SQLCmd = ‘INSERT INTO user_index_fld ( class_name,
Scripting UET Definitions D-8
Modifying Infor ERP SyteLine
Copyright © 2009 Infor
index_name, index_seq, fld_name, index_asc ) VALUES ( ‘
SET @SQLCmd = @SQLCmd + dbo.Quote(@ClassName) + ‘, ‘ +
dbo.Quote(@IndexName) + ‘, ‘ + STR(ISNULL(@IndexSeq, 0))
SET @SQLCmd = @SQLCmd + ‘, ‘ + dbo.Quote(@FldName) + ‘, ‘ +
STR(ISNULL(@IndexAsc, 0)) + ‘ )’
PRINT @SQLCmd
END — Cursor Loop UserIndexFld
CLOSE UserIndexFldCrs
DEALLOCATE UserIndexFldCrs
END — Cursor Loop UserIndex
CLOSE UserIndexCrs
DEALLOCATE UserIndexCrs
DECLARE TableClassCrs CURSOR LOCAL STATIC
FOR SELECT
tc.table_name
, tc.class_name
, tc.table_rule
, tc.extend_all_recs
, tc.sys_apply
, tc.sys_delete
, tc.allow_record_assoc
, tc.active
FROM table_class tc
WHERE class_name = @PClassName
OPEN TableClassCrs
WHILE @Severity = 0
BEGIN — cursor loop
FETCH TableClassCrs INTO
@TableName
, @ClassName
, @TableRule
, @ExtendAllRecs
, @SysApply
, @SysDelete
, @AllowRecordAssoc
, @Active
IF @@FETCH_STATUS = -1
BREAK
SET @SQLCmd = ‘INSERT INTO table_class ( table_name, class_name,
table_rule, extend_all_recs, sys_apply, sys_delete,
allow_record_assoc, active ) VALUES ( ‘
SET @SQLCmd = @SQLCmd + dbo.Quote(@TableName) + ‘, ‘ +
dbo.Quote(@ClassName) + ‘, ‘ + dbo.Quote(@TableRule)
SET @SQLCmd = @SQLCmd + ‘, ‘ + STR(ISNULL(@ExtendAllRecs, 0)) +
‘, ‘ + dbo.Quote(@SysApply)
SET @SQLCmd = @SQLCmd + ‘, ‘ + STR(ISNULL(@SysDelete, 0)) + ‘,
‘ + STR(ISNULL(@AllowRecordAssoc, 0))
SET @SQLCmd = @SQLCmd + ‘, ‘ + STR(ISNULL(@Active, 0)) + ‘)’
PRINT @SQLCmd
END — Cursor Loop TableClass
CLOSE TableClassCrs
DEALLOCATE TableClassCrs
END — Cursor Loop UserClass
CLOSE UserClassCrs
DEALLOCATE UserClassCrs
RETURN @Severity
Hi Jian,
If it’s not too much of a hassle, can you give an example please?
Thank,
Kazi.
OK Kazi, here is an example.
Said you have an UET class: COLines, with UET fields such as Uf_COLines_CancelDate.
Run the following in your App DB:
exec ExportUETClassSP ‘COLines’
And here is what it generated:
INSERT INTO user_class ( class_name, class_label,
class_desc, sys_has_fields, sys_has_tables, sys_apply, sys_delete ) VALUES
( N’COLines’, NULL, NULL, 0, 0, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_ApplyToAllLines’, N’tinyint’, NULL, 0, NULL, NULL, 0, NULL, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_ApplyToAllLines’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_COLines_CancelDate’, N’datetime’, NULL, 0, NULL, NULL, 0, N’DateType’, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_COLines_CancelDate’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_COLines_CancReason’, N’nvarchar’, NULL, 0, NULL, NULL, 0, NULL, 30 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_COLines_CancReason’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_COLines_OrigQty’, N’decimal’, NULL, 8, NULL, NULL, 0, N’QtyUnitNoNegType’, 19 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_COLines_OrigQty’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_COLines_Type’, N’nvarchar’, NULL, 0, NULL, NULL, 0, NULL, 20 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_COLines_Type’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_Disc’, N’decimal’, N’0′, 8, NULL, NULL, 0, N’AmountType’, 21 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_Disc’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_DiscAmount’, N’decimal’, NULL, 0, NULL, NULL, 0, N’AmountType’, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_DiscAmount’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_DiscCode’, N’nvarchar’, NULL, 0, NULL, NULL, 0, NULL, 12 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_DiscCode’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_DiscError’, N’decimal’, NULL, 0, NULL, NULL, 0, N’AmountType’, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_DiscError’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_DiscFormulaSeq’, N’int’, NULL, 0, NULL, NULL, 0, N’CustSeqType’, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_DiscFormulaSeq’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_DiscLine’, N’tinyint’, NULL, 0, NULL, NULL, 0, NULL, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_DiscLine’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_DiscType’, N’nchar’, NULL, 0, NULL, NULL, 0, NULL, 1 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_DiscType’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_PcrNum’, N’nvarchar’, NULL, 0, NULL, NULL, 0, NULL, 7 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_PcrNum’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_Promise_Date’, N’datetime’, NULL, 0, NULL, NULL, 0, NULL, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_Promise_Date’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_Promise_Date_Count’, N’int’, NULL, 0, NULL, NULL, 0, NULL, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_Promise_Date_Count’, NULL, 0 )
INSERT INTO user_fld ( fld_name, fld_data_type,
fld_initial, fld_decimals, fld_desc, sys_apply, sys_delete, fld_UDT,
fld_prec ) VALUES ( N’Uf_Request_Date_Count’, N’int’, NULL, 0, NULL, NULL, 0, NULL, 0 )
INSERT INTO user_class_fld ( class_name, fld_name,
sys_apply, sys_delete ) VALUES ( N’COLines’, N’Uf_Request_Date_Count’, NULL, 0 )
INSERT INTO table_class ( table_name, class_name,
table_rule, extend_all_recs, sys_apply, sys_delete, allow_record_assoc,
active ) VALUES ( N’coitem’, N’COLines’, NULL, 1, NULL, 0, 0, 1)
You can then run this generated script in your “deploy to” App DB, to get the UET set up there.
Hope this help.
Jian
Thank you. That was very helpful.