User-Defined Fields (UDFs) in SAP Business One: A Practical Guide - featured image

Publications

User Defined Fields (UDF) in SAP Business One: A Practical Guide

Hector Pincheira

Hector Pincheira

CIO | CTO
Digital Strategy & Technology Innovation

items

Your ERP was not designed for your company. It was designed for all companies. And that difference—between a generic system and one adapted to your reality—is built by you with the user-defined fields UDF in SAP Business One.

Consequently, if you have ever told your team «we keep that data in a separate Excel file,» you are reading the right article. For example, the customer's commercial segment, the type of project associated with a sales order, a delivery carrier code, or any internal classification that SAP does not include out of the box: all that data can live inside your ERP with just a few clicks, without programming and without external consultants.

In this tutorial, you will learn how to create user-defined fields (UDFs) in SAP Business One, configure types and validations, query them using SQL from the Query Manager, and turn them into strategic reports that transform scattered data into real business intelligence.

SAP Business One UDF user fields - ERP customization
UDFs turn scattered data into business intelligence within the ERP

Why Are UDF User Fields Strategic?

A User Defined Field (UDF, user-defined field in Spanish) is a custom field that you can add to almost any SAP Business One object: customer master data, items, vendors, sales orders, invoices, delivery notes, production orders, and many more.

However, the real value is not technical, but operational. For example, adding a «Market Segment» field to the customer profile allows you to segment all your sales by that criterion in seconds using a SQL query. In this way, what used to be an Excel spreadsheet disconnected from the ERP becomes real-time analysis available to the entire organization.

Furthermore, unlike SDK-based customizations—which require specialized development and maintenance—UDFs are native to SAP Business One. Therefore, they do not break with system updates and do not require additional licenses. They are the most accessible customization tool available from day one of your license.

Prerequisites for Creating User-Defined Fields in SAP B1

  • SAP Business One version 9.3 or later (compatible with SQL Server and SAP HANA)
  • Superuser profile or role with access to Customization Tools
  • Access to Query Manager (Tools > User Queries)

Types of UDFs Available in SAP Business One

First of all, before creating a user-defined field, it is essential to choose the correct data type. SAP Business One offers the following types for UDFs:

  • AlphanumericFree text up to 254 characters. Ideal for notes, internal codes, or cross-references.
  • NumericInteger values. Useful for counts, priorities, or numeric codes.
  • Decimal: Values with decimals. For percentages, rates, or physical measurements.
  • DateDates in DD/MM/YYYY format. For deadlines, commitments, or follow-up dates.
  • Memo: Long text up to 65,000 characters. For detailed observations or technical instructions.

Additionally, you can define Valid Values —a drop-down list of controlled options—for any alphanumeric field. Consequently, you reduce entry errors and standardize information right at the point of capture, which is where inconsistency does the most damage.

Step-by-Step Tutorial: Creating User-Defined Fields (UDF) in SAP Business One

Step 1: Access the User Field Management

To begin, go to Tools > Tool Customization > User-Defined Fields. Next, SAP will display a window with the complete tree of system objects available for customization.

Step 2: Select the Target Object

In the list of objects, select the field destination. For example, to add a UDF to customer invoices, expand Marketing documents and select Document header. However, if you need the field per line item —for example, the «Line item discount reason»—, select Document lines instead. Both levels are valid and complementary.

Step 3: Create the New Field

Right click on the object and choose Add field. Complete the following information:

  • Name (AliasID)Internal identifier, maximum 8 characters, no spaces or accents. SAP will automatically add the prefix U_. For example, if you write SEGMENT, in the database the field will be called U_SEGMENTO.
  • DescriptionDisplay name visible on screen to the end user.
  • Type: The data type according to the previous section.
  • Length: For alphanumeric fields only.
  • Mandatory: If the document cannot be saved without completing this field.

Step 4: Configure Valid Values (Highly Recommended)

If the field must be a controlled selector, go to the tab Valid values and add the options. This way, the user will see a dropdown instead of a free-form field. For example, for «Market Segment»: Retail, Industrial, Export, Government. As a result, the company uses uniform terminology and the reports are consistent and reliable.

Step 5: Update the Database

Click on Update. SAP Business One will execute an ALTER TABLE on the database to add the physical column to the schema. Consequently, it is recommended to perform this step during low-activity hours if the table has millions of historical records.

Step 6: Activate the Field in the Form

The created UDF does not automatically appear on screen. To view it, open the corresponding document and activate View > User-defined fields or use the user sidebar icon. Additionally, you can position and configure which fields are visible using the SAP B1 form customization mode, dragging and sorting the fields according to your team's operational logic.

SAP Business One UDF user fields - business data analysis with SQL
Data captured in UDFs is converted into strategic reports using SQL

SQL Queries to Exploit UDF User Fields

So far we have created the field. However, the true power of UDFs appears when we query them with SQL to generate reports, audits, and cross-analysis. Below are four essential queries, each with its version for SQL Server and SAP HANA.

Query 1: Inventory of All System-Defined UDFs

This query queries the table CUFD (Custom User Fields Definition) and lists all existing custom fields in your database. Therefore, it is ideal for documenting the configuration or performing a complete technical audit of the system.

SQL Server

-- Complete inventory of User-Defined Fields (UDF) in SAP B1
SELECT
    T0.TableID          AS [Table],
    T0.AliasID          AS [Field_Name],
    'U_' + T0.AliasID   AS [DB_Column],
    T0.Descr            AS [Description],
    CASE T0.Type
        WHEN 'A' THEN 'Alphanumeric'
        WHEN 'N' THEN 'Numeric'
        WHEN 'D' THEN 'Date'
        WHEN 'F' THEN 'Decimal'
        WHEN 'M' THEN 'Memo'
        ELSE T0.Type
    END                 AS [Type],
    T0.EditSize         AS [Length],
    CASE T0.Mandatory
        WHEN 'Y' THEN 'Yes'
        ELSE 'No'
    END                 AS [Mandatory]
FROM CUFD T0
ORDER BY T0.TableID, T0.AliasID

SAP HANA

-- Complete list of user-defined fields (UDFs) in SAP B1
SELECT
    T0."TableID"                AS "Table",
    T0."AliasID"                AS "Field_Name",
    'U_' || T0."AliasID"       AS "DB_Column",
    T0."Descr"                  AS "Description",
    CASE T0."Type"
        WHEN 'A' THEN 'Alphanumeric'
        WHEN 'N' THEN 'Numeric'
        WHEN 'D' THEN 'Date'
        WHEN 'F' THEN 'Decimal'
        WHEN 'M' THEN 'Memo'
        ELSE T0."Type"
    END                         AS "Type",
    T0."EditSize"               AS "Length",
    CASE T0."Mandatory"
        WHEN 'Y' THEN 'Yes'
        ELSE 'No'
    END                         AS "Required"
FROM CUFD T0
ORDER BY T0."TableID", T0."AliasID""

Query 2: Segmented Sales by UDF User Field

In this example, the field U_SEGMENTO was created in the OINV table (A/R Invoices). This way, you can analyze sales performance segmented by your custom classification. Adjust the field name according to the UDF you have configured in your system.

SQL Server

-- Sales by market segment using a user-defined field (UDF)
SELECT
    ISNULL(T0.U_SEGMENTO, 'Unclassified')  AS [Segment],
    COUNT(DISTINCT T0.DocNum)                AS [Invoices],
    COUNT(DISTINCT T0.CardCode)              AS [Unique_Customers],
    SUM(T0.DocTotal)                         AS [Total_Invoiced],
    AVG(T0.DocTotal)                         AS [Average_Receipt]
FROM OINV T0
WHERE T0.CANCELED = 'N'
  AND T0.DocDate >= DATEADD(MONTH, -12, GETDATE())
GROUP BY ISNULL(T0.U_SEGMENTO, 'Unclassified')
ORDER BY SUM(T0.DocTotal) DESC

SAP HANA

-- Sales by market segment using a UDF user field
SELECT
    IFNULL(T0."U_SEGMENTO", 'Unclassified') AS "Segment",
    COUNT(DISTINCT T0."DocNum")               AS "Invoices",
    COUNT(DISTINCT T0."CardCode")             AS "Unique_Customers",
    SUM(T0."DocTotal")                        AS "Total_Billed",
    AVG(T0."DocTotal")                        AS "Average_Receipt"
FROM OINV T0
WHERE T0."CANCELED" = 'N'
  AND T0."DocDate" >= ADD_MONTHS(CURRENT_DATE, -12)
GROUP BY IFNULL(T0."U_SEGMENTO", 'Unclassified')
ORDER BY SUM(T0."DocTotal") DESC

Query 3: UDF Field Completeness Audit by Month

However, the biggest problem with UDFs is not creating them, but getting users to complete them consistently. Therefore, this query measures the completion rate month by month. As a result, you can identify in which periods or with which teams there is greater non-compliance with the data capture process.

SQL Server

-- Monthly completeness audit of the UDF U_SEGMENTO in invoices
SELECT
    YEAR(T0.DocDate)            AS [Year],
    MONTH(T0.DocDate)           AS [Month],
    COUNT(*)                    AS [Total_Invoices],
    SUM(CASE WHEN ISNULL(T0.U_SEGMENTO,'') = '' THEN 1 ELSE 0 END)
                                AS [Incomplete],
    SUM(CASE WHEN ISNULL(T0.U_SEGMENTO, '')  '' THEN 1 ELSE 0 END)
                                AS [Completed],
    CAST(
        100.0 * SUM(CASE WHEN ISNULL(T0.U_SEGMENTO,'')  '' THEN 1 ELSE 0 END)
        / NULLIF(COUNT(*), 0) AS DECIMAL(5,2)
    )                           AS [Completion_Percentage]
FROM OINV T0
WHERE T0.CANCELED = 'N'
  AND T0.DocDate >= DATEADD(YEAR, -1, GETDATE())
GROUP BY YEAR(T0.DocDate), MONTH(T0.DocDate)
ORDER BY [Year] DESC, [Month] DESC

SAP HANA

-- Monthly completeness audit of the UDF U_SEGMENTO in invoices
SELECT
    YEAR(T0."DocDate")          AS "Year",
    MONTH(T0."DocDate")         AS "Month",
    COUNT(*)                    AS "Total_Invoices",
    SUM(CASE WHEN IFNULL(T0."U_SEGMENTO",'') = '' THEN 1 ELSE 0 END)
                                AS "Incomplete",
    SUM(CASE WHEN IFNULL(T0."U_SEGMENTO",'')  '' THEN 1 ELSE 0 END)
                                AS "Completed",
    CAST(
        100.0 * SUM(CASE WHEN IFNULL(T0."U_SEGMENTO",'')  '' THEN 1 ELSE 0 END)
        / NULLIF(COUNT(*), 0) AS DECIMAL(5,2)
    )                           AS "Completion_Percent"
FROM OINV T0
WHERE T0."CANCELED" = 'N'
  AND T0."DocDate" >= ADD_YEARS(CURRENT_DATE, -1)
GROUP BY YEAR(T0."DocDate"), MONTH(T0."DocDate")
ORDER BY "Year" DESC, "Month" DESC

Query 4: Analysis of UDFs in Document Lines

In addition to the UDFs in the header, you can have custom fields in the document lines. For example, the field U_MOTIVO_DESC in the invoice lines (INV1 table) record the reason for each discount applied per line. Below is a query to audit and quantify this commercial behavior:

SQL Server

-- Analysis of Discounts by Reason (UDF in Invoice Lines - INV1)
SELECT
    ISNULL(T1.U_MOTIVO_DESC, 'No reason recorded')  AS [Discount_Reason],
    COUNT(*)                                            AS [Lines_with_Discount],
    SUM(T1.Quantity * T1.Price * T1.DiscPrcnt / 100)   AS [Total_Discount_Amount],
    AVG(T1.DiscPrcnt)                                  AS [Average_Discount_Percentage]
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.CANCELED = 'N'
  AND T1.DiscPrcnt > 0
  AND T0.DocDate >= DATEADD(MONTH, -6, GETDATE())
GROUP BY ISNULL(T1.U_MOTIVO_DESC, 'No reason recorded')
ORDER BY SUM(T1.Quantity * T1.Price * T1.DiscPrcnt / 100) DESC

SAP HANA

-- Analysis of Discounts by Reason (UDF in Invoice Lines - INV1)
SELECT
    IFNULL(T1."U_MOTIVO_DESC", 'No reason recorded') AS "Discount_Reason",
    COUNT(*)                                             AS "Lines_with_Discount",
    SUM(T1."Quantity" * T1."Price" * T1."DiscPrcnt" / 100) AS "Total_Discount_Amount",
    AVG(T1."DiscPrcnt")                                  AS "Average_Discount_Percentage"
FROM OINV T0
INNER JOIN INV1 T1 ON T0."DocEntry" = T1."DocEntry"
WHERE T0."CANCELED" = 'N'
  AND T1."DiscPrcnt" > 0
  AND T0."DocDate" >= ADD_MONTHS(CURRENT_DATE, -6)
GROUP BY IFNULL(T1."U_MOTIVO_DESC", 'No reason recorded')
ORDER BY SUM(T1."Quantity" * T1."Price" * T1."DiscPrcnt" / 100) DESC

Real Use Cases by Module

User-defined fields (UDFs) have applications in practically all SAP Business One modules. For example, these are the most impactful use cases in manufacturing and industrial companies:

  • Business Partner Master Data (OCRD)Market segment, Industry, Assigned account executive, Date of last commercial visit, NPS score, Internal credit rating.
  • Item Master Data (OITM)Internal category, Private label vs. distribution, Storage temperature, Family code for management reporting.
  • Sales Orders (ORDR)Sales channel (web / in-person / telephone), Origin marketing campaign, Associated tender or project number.
  • Production Orders (OWOR)Responsible operator, Work shift, Internal production batch number, Approved recipe code.
  • Deliveries (ODLN)Waybill number, Third-party carrier, Dispatch temperature for the food industry, Committed delivery time.

This way, each critical process is tracked with the information you actually need to make decisions, not with what SAP considers standard for any company in the world.

SAP Business One user fields - best practices and UDF configuration
Standard nomenclature and UDF documentation prevent long-term technical chaos

Best Practices and Mistakes to Avoid

Best Practices

  • Standard nomenclature from the beginningDefine a convention before creating the first UDF. For example: U_[MODULE]_[CONCEPT] → U_VTA_SEGMENTO, U_PRO_TURNO. This way, in your queries you will always know which table to look for and what the field means.
  • Document every UDF you createTechnical name, target table, operational purpose, who created it, and when. Without documentation, in 18 months no one will know why it exists U_XREF2.
  • Use Valid Values in classificatory fieldsFree text will inevitably generate «Retail», «retail», «RETAIL» and «Ret ail» as four distinct values in your reports. Valid Values eliminate that problem at the source.
  • Do not abuse the required fieldsA mandatory UDF that blocks saving creates operational friction. Use it only when the data is truly critical and there is a real process feeding it.
  • Always test in the development environmentThe ALTER TABLE that SAP executes on very large tables can take time. Validate the impact before executing it in production during business hours.

Common Mistakes to Avoid

  • Create a UDF without an operational process behind itA field without a clear capture procedure is an empty field. Before creating it, define who fills it out, when, and what business decision depends on that data.
  • Confusing UDF with UDTUDFs add columns to existing SAP tables. UDTs (User Defined Tables) create completely new tables. They are complementary tools, not equivalents. Using a UDT when you only need a UDF is unnecessary overengineering.
  • Names with special charactersThe UDF AliasID only accepts letters and numbers. No spaces, no accents, no hyphens. The user-visible description can have any format.
  • Do not verify the impact on Crystal ReportsIf you have Crystal Reports that query the tables where you add UDFs, verify that the dataset is not affected by the ALTER TABLE before executing it.

Official SAP Resources

Conclusion: Your ERP Must Speak the Language of Your Business

User-defined fields (UDFs) in SAP Business One are one of the system's most powerful and underutilized capabilities. However, unlike other advanced customizations, they require no programming, do not depend on external consultants, and are available from day one of your license.

Consequently, if you have data that currently lives outside the ERP —in Excel, in emails, in a salesperson's memory— a well-configured UDF is likely the fastest, most economical, and most durable solution you can implement this week.

The complete tutorial with the four queries ready to run in your Query Manager, the naming templates, and the industry-applied examples are available to members of the Strategic Circle at hectorpincheira.com. If you are already a member, go to the article and start customizing your SAP Business One today.

What data do you have in an Excel file today that should be in your SAP B1? Let me know in the comments.

Most Read

Ballena jorobada bajo el agua con su aleta pectoral extendida: la esperanza en la tecnología y la biomimética
La ballena que volvió: la esperanza en la tecnología y la que no cabe en un tablero
SAP data in ChatGPT: an open door at the far end of a dark room
The Tab Next Door: The SAP Data in ChatGPT That Nobody Authorized
SAP Business One Purchase Price Variance - featured image of the tutorial
SAP Business One Purchase Price Variance: Detect the Inflation in Your Buying Costs
QlikSense format changeovers: actual minutes against the standard
QlikSense Format Changeovers: the Minutes Nobody Bills
QlikSense buttons and actions: executive dashboard with indicators
QlikSense Buttons and Actions: the Dashboard that Runs the Meeting
SAP Business One Internal Reconciliation - featured image of the tutorial
SAP Business One Internal Reconciliation: Clear False Open Items

RELATED ARTICLES