0% found this document useful (0 votes)
134 views

UDT and UDF Related Issues

Uploaded by

Wesley Medeiros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views

UDT and UDF Related Issues

Uploaded by

Wesley Medeiros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SAP Business One Notes

1076082 - UDT and UDF Related Issues


Component: SBO-GEN-UDF (User-Defined Fields), Version: 39, Released On: 25.07.2022

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 = '@'

*** Detect tables without a name in a database:


SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '@'
DETECTION QUERIES FOR HANA:

1) UDT is defined but does not exist.


select T0."TableName" from OUTB T0 where not exists (select 1 from sys.tables T1 where T1.schema_name =
current_schema and T1.is_system_table = 'FALSE' and T1.table_name = '@' || "TableName");

2) UDT is not registered

select * from sys.tables


where schema_name = current_schema and is_system_table = 'FALSE' and table_name like '@%'
and table_name not in
(
select '@' || "TableName" from outb
union all
select '@' || "LogTable" from outb where "LogTable" is not null
);
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 1 from sys.tables t0 inner join sys.columns t1 on t0.table_oid=t1.table_oid
where t0.schema_name = current_schema and t0.is_system_table = 'FALSE'
and t0.table_name="TableID" and t1.column_name='U_' || "AliasID")
and "TableID" not in ('BTNT', 'BTNT1', 'OIBT', 'OSRI', 'SRNT', 'SRNT1', 'ODIB', 'ODSR'
);

5) UDF valid values are defined for 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 T2.table_name, T3.column_name "UDF", T3.length, T0."EditSize" from sys.tables T2
inner join sys.columns T3 on t2.table_oid=t3.table_oid
inner join cufd T0 on T0."TableID" = T2.table_name and ('U_' || T0."AliasID") = T3.column_name
where t2.schema_name = current_schema and T2.is_system_table = 'FALSE'
and T3.data_type_name ='NVARCHAR'
and T0."TypeID"='A' and T0."EditSize">1
and T3.length>T0."EditSize" ;
7a) UDF contains extra spaces in field TableID in User-fields description CUFD table.
select "TableID", "AliasID", "Descr" from CUFD where "TableID" LIKE '% %';

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 '@% %';

8) UDF exists but is not registered


select T2.table_name, T1.column_name "UDF" from sys.columns T1
join sys.tables T2 on t1.table_oid=t2.table_oid
left join CUFD T0 on T2.table_name = T0."TableID" and T1.column_name = ('U_' || T0."AliasID")
where t2.schema_name = current_schema and T2.is_system_table = 'FALSE'
and T1.column_name like 'U/_%' escape '/'
and ('U_' || T0."AliasID") is null
and T2.table_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" = '@'
*** Detect tables without a name in a database:
SELECT * FROM public.tables WHERE schema_name = current_schema AND table_name = '@'
Note for Points 2 and 8: The result set includes columns created both on SAP Business One system tables and user tables.
However, only columns created on SAP Business One tables should be considered, as those are potentially harmful.
A list of SAP Business One system tables is not available as it may differ from patch to patch.
Note for Point 4: After running the fix for Point 4, please run the detect query for Point 5 also and run the relevant fix if the
detect query returns any result.
Note: Issue related to point 1,3,4,5,7a and 7b will be fixed after upgrading the database to SAP Business One 9.3 PL 10, check
the SAP Note 2727525 - Auto-fixes for Upgrade UDT / UDF Related Issues for more detail.
Note: Issue related to point 9 will be fixed after upgrading the database to SAP Business one 9.3 PL 09, check the SAP
Note 2732587 - Upgrade Wizard Error Precheck: Detect User Defined Value Linked to a Table Without a Name

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

Other Components SBO-BC-UPG (Upgrade)

Products
Products
SAP B1 VERSION FOR SAP HANA all versions

SAP BUSINESS ONE all versions

This document refers to


SAP Note/KBA Component Title

946498

1531620

1253143

1056335

1021726

This document is referenced by


SAP Component Title
Note/KBA

3024475 RU_System User-Defined Fields Definition Does not Match

2996167 SBO-GEN- BR_System User-Defined Fields Definition does not match


UDF

2836348 SBO-BC-UPG Pre-upgrade Check ID 42 and ID 91 Are Merged

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

2727525 SBO-BC-UPG Auto-fixes for Upgrade UDT / UDF Related Issues

2029714 SBO-INT-B1IF Troubleshooting Integration Framework SLD DI Connection

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

2588086 SBO-BC-UPG Upgrade Wizard Fails Due to System User-Defined Fields

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

2207930 SBO-BC-MW Incorrect precheck severity in HANA migration tool

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

You might also like