UDT and UDF Related Issues
UDT and UDF Related Issues
Symptom
User-defined table (UDT) and user-defined field (UDF) related issues often have different impacts. For instance, you may not
be able to perform an upgrade of the database or you may receive the following error message after logging on to an SAP
Business One database: "The database structure has been modified. In order to resume the process, all open windows will be
closed. Do you want to continue adding the user-defined field?"
This note provides a few generic queries to detect some common issues about UDTs and UDFs. If an issue is related to a
UDT and UDF, the queries provided below will detect the known inconsistencies.
1. UDT is defined but does not exist.
2. UDT is not registered.
3. UDF is defined on an unregistered UDT.
4. UDF is defined but does not exist.
5. UDF valid values are defined for a non-existing UDF.
6. UDF definition does not match actuality.
7. UDF/UDT contains extra spaces.
a. UDF contains extra spaces in the TableID field in User-fields description in the CUFD table.
b. UDF contains extra spaces in the AliasID field in User-fields description in the CUFD table.
c. UDF column with space characters in its name was found by the SAP Business One upgrade Wizard.
d. UDT with space characters in its name was found by the SAP Business One upgrade Wizard.
8. UDF exists but is not defined in the CUFD table.
9. UDT exists with the name '@'.
Solution
In order to detect whether this issue affects your database, please run the following queries:
DETECTION QUERIES FOR SQL:
1. UDT is defined but does not exist:
***
select TableName from OUTB
where not exists (
select 1 from sysobjects where xtype='U' and [name]='@'+TableName
)
***
2. UDT is not registered:
***
select * from sysobjects where [name] like '@%' and name not in
(select '@'+tablename from outb
union all
select '@'+logtable from outb where logtable is not null) and xtype='U'
***
3. UDF is defined on an unregistered UDT:
***
select T0.TableID from CUFD T0 where left(T0.TableID,1)='@' and not exists (
select 1 from OUTB T1 where '@'+T1.TableName = T0.TableID or '@'+T1.LogTable = T0.TableID
)
***
4. UDF is defined but does not exist:
***
select TableID, AliasID from CUFD where not exists (
select t0.name, t1.name
from sysobjects t0 inner join syscolumns t1
on t0.xtype='U' and t0.id=t1.id
where t0.name=TableID and t1.name='U_'+AliasID
)
and TableID not in ('BTNT', 'BTNT1', 'OIBT', 'OSRI', 'SRNT', 'SRNT1', 'ODIB', 'ODSR')
***
5. UDF valid values are defined for a non-existing UDF:
select TableId, FieldID from UFD1 T
where not exists (
select 1 from CUFD where TableId=T.TableId and FieldID=T.FieldID
)
***
6. UDF definition does not match actuality:
***
select T1.UDF, T0.nvarchar_size as 'act_size', T1.nvarchar_size as 'def_size' from (
select T2.name + '.' + T3.name as 'UDF', T3.length/2 as 'nvarchar_size' from sysobjects T2 inner join syscolumns T3 on
T2.id=T3.id where T2.xtype='U' and T3.xtype in
(select xtype from systypes where [name]='nvarchar')
) T0
inner join (
select tableid + '.U_' + aliasid as 'UDF', editsize as 'nvarchar_size'
from cufd where typeid='A' and editsize>1
) T1
on T0.UDF=T1.UDF
where T0.nvarchar_size>T1.nvarchar_size
***
7. UDF contains extra spaces:
a. UDF contains extra spaces in the TableID field in User-fields description in the CUFD table:
***
select * from CUFD
where datalength(TableID)<>LEN(TableID)
and ascii(SUBSTRING (TableID, LEN(TableID)+1, 1)) =32
***
b. UDF contains extra spaces in the AliasID field in User-fields description in the CUFD table:
***
select * from CUFD
where datalength(AliasID)<>len(AliasID)
and ascii(SUBSTRING (AliasID, LEN(AliasID)+1, 1)) =32
***
c. UDF column with space characters in its name was found by the SAP Business One Upgrade Wizard.
***
Select 'UDF column name ''' + COLUMN_NAME + ''' contains space characters in table ' + TABLE_NAME as
"Resolution"
FROM INFORMATION_SCHEMA.COLUMNS t0 inner join cufd t1 on t0.TABLE_NAME = t1.TableID and
t0.COLUMN_NAME = 'U_' + t1.AliasID
where t0.[COLUMN_NAME] like 'U[_]% %'
***
d. UDT with space characters in its name was found by the SAP Business One Upgrade Wizard
***
Select 'UDT name ''' + TABLE_NAME + ''' contains space characters' as "Resolution"
FROM INFORMATION_SCHEMA.TABLES t0 inner join outb t1 on t0.TABLE_NAME = '@' + t1.TableName
where t0.[TABLE_NAME] like '@% %'
***
For more information on checks 7c and 7d please see note 2781726
8. UDF exists but is not defined:
***
select T1.name [Table name], T0.name [Column name] from sys.columns T0 join sys.objects T1 on T0.object_id =
T1.object_id
left join CUFD T2 on T2.TableID = T1.name and ('U_' + T2.AliasID) = T0.name
where T1.type = 'U' and T0.name like 'U/_%' escape '/'
and ('U_' + T2.AliasID) is null
and (T0.name !='U_NAME' and T1.name not in ('OUSR', 'AUSR', 'TDIB', 'TIBT', 'TDSR', 'TSRI','OEML'))
***
9. UDT exists with the name '@'
*** Detect user-defined value linked to a table without a name:
SELECT * FROM CUFD WHERE TableID = '@'
7b) UDF contains extra spaces in field AliasID in User-fields description CUFD table
select "TableID", "AliasID", "Descr" from CUFD where "AliasID" LIKE '% %';
7c) UDF column with space characters in its name was found by the SAP business One upgrade Wizard
select 'UDF column name ''' || column_name || ''' contains space characters in table ' || table_name as "Resolution"
FROM public.table_columns t0 inner join cufd t1 on t0.table_name = t1."TableID" and t0.column_name = 'U_' ||
t1."AliasID"
where schema_name = current_schema and column_name like 'U\_% %' escape '\';
7d) UDT with space characters in its name was found by the SAP business One upgrade Wizard
select 'UDT name ''' || table_name || ''' contains space characters' as "Resolution"
FROM public.tables t0 inner join outb t1 on t0.table_name = '@' || t1."TableName"
where schema_name = current_schema and table_name like '@% %';
If you receive any results from above queries, please create an incident using the Support Launchpad for SAP Business
One and refer to this SAP Note. Also attach the results of the (attached) detection scripts to the newly created incident.
Other terms
CULG; the database structure has been modified; You can only specify the READPAST lock in the READ COMMITTED or
REPEATABLE READ isolation levels
A_TABLE was not found in metadata, when loading existing UDFs.
General error; invalid name of function or procedure; CFF_CASHFLOW_OVERVIEW
Attributes
Key Value
Products
Products
SAP B1 VERSION FOR SAP HANA all versions
946498
1531620
1253143
1056335
1021726
2781726 SBO-BC-UPG Upgrade Wizard Error Precheck: Detect User Defined Value Linked to Table with Space Character
in Name
2732587 SBO-BC-UPG Upgrade Wizard Error Precheck: Detect User Defined Value Linked to a Table Without a Name
1360832 SBO-BC-UPG Upgrade Wizard Precheck: User Defined Table Structure Check
2547151 SBO-BC Overview Note for SAP Business One 9.2 PL11, version for SAP HANA
2547047 SBO-BC Overview Note for SAP Business One 9.2 PL11
2573722 SBO-BC-UW Table OEML in Upgrade Wizard or Migration Wizard Precheck Error for Note 1076082
2205720 SBO-BC-UPG Overview Note for SAP Business One 9.1 PL09, version for SAP HANA
2219105 SBO-BC-MW Skip query 8 of SAP Note 1076082 during migration precheck
2175432 SBO-BC-UPG Overview Note for SAP Business One 9.1 PL08
2149308 SBO-BC-MW Migration Wizard Precheck: Collective SAP Note for all check items
1821938 SBO-GEN- User Defined Field and User Defined Table Length Inconsistencies
UDF
1343077 SBO-BC-UPG Upgrade / Setup Wizard Precheck: User-Defined Table Unique Index