92 Impl 14 CustomTools UserDefinedFields
92 Impl 14 CustomTools UserDefinedFields
1
On completion of this topic, you will be able to add your own fields to objects in the SAP Business
One database. You will be able to defined fields with different types and structure, including
mandatory fields, and set validation rules, default values, and lists of values to assist users in data
entry.
2
Additional fields are often added to master data and documents to implement a customer’s
business process. Here are two business requirements that can be implemented with user-defined
fields.
There is a need to track a status level for each customer – gold, silver, and bronze. You can
add a user-defined field to the customer master data to hold and track the status value.
Additionally, the salesperson needs to record the customer’s preferred delivery instructions
when processing a sales order. You can add a user-defined field to the sales order document,
and record the delivery instructions in this field.
3
In the first part of this topic, we cover how to add user-defined fields.
4
You can add new fields to most business objects, including business partner and item master data,
and marketing documents. These fields are stored in the database and table of the business
object.
Only authorized users can add user-defined fields. The general authorization is Customization
Tools > User-Defined Fields – Management.
5
You can add fields to both the header area and to the rows of marketing documents.
When you add a user-defined field to the marketing documents object, the new field is added to all
logistics document types, including all sales and purchasing document types, and some inventory
documents such as Goods Receipt and Goods Issue.
6
When you add user-defined fields (UDFs) at the header level, the new fields appear in a separate
window positioned by default to the right of the existing document window.
This window is not visible immediately. To open this window, choose View > User-Defined Fields
from the top menu bar, or use the key sequence Ctrl+Shift+U. You can reposition this window to
the left or bottom of the existing window.
If the user-defined fields are not used in a marketing document type, the new window can remain
closed.
7
Authorized users can use the Tools > Edit Form UI function to drag relevant user-defined fields
from the side window to the main form area, thus dispensing with the side window.
Authorized users can make this change just for their own use or for other users by creating a UI
Configuration template. In the UI configuration template, select the form that has the UDFs added,
then drag the fields into position. The template can then be assigned to users. For more
information on UI configuration templates, see the UI Configuration Templates course in the
System Setup and Administration unit.
8
If you decide to keep user-defined fields in the side window, you can manage them using the
settings window. The settings window is different to the standard form settings window, but works
in a similar way. To open the settings window for user-defined fields, press Ctrl+Shift+B, or
choose Tools > Customization Tools > Settings. The menu only shows active when you select a
form with user-defined fields.
The user can make the user-defined fields visible or invisible, and active or inactive, in the user-
defined fields side window. For example, you can make all the fields relevant for a sales order
invisible in a purchase order.
There is also the option to define new categories to group related fields and only display the fields
for a category.
9
When using the Copy To/ Copy From function to generate a new document from a base document,
the value of a user-defined field is transferred to the target document. This also applies to
documents generated through the Document Generation Wizard.
If multiple base documents are copied to a target document, and the user-defined field has different
values in these base documents, the field value is not copied.
10
When you add a field at the row level, the system adds this field as an additional column in the row.
The field is visible and active by default.
You can change these settings or move the field to a new position on the row using standard form
settings.
11
In the first part of this topic, we cover the properties, structure and validation options of user-
defined fields.
12
User-defined fields are added to the respective database table for the object. They can be quickly
identified in the table, since they have the prefix “U_”. In the slide example you can see two new
fields added to the order row table RDR1.
User-defined fields are retained during an upgrade to a new release. When you create a new
company, you have the option to copy user-defined fields from the current company to the new
company.
An important point about user-defined fields is that when you add a new field to an object, the new
field is added to all instances of the object, including records already saved in the database.
UDFs function as normal fields and can therefore be used in queries and reports.
You can also import data into user-defined fields using the Data Transfer Workbench. In the DTW
template, simply add these fields at the end of the spreadsheet. Enter the name of the field in the
header row and enter the value as you would for a standard field.
13
It is important to remember that, when you add a user-defined field, the database structure is
updated. Therefore you should only add new fields when no other users are logged in.
If you try to add a new field, the system will warn you if there are logged in users. You have the
option to:
Try Again – you can notify the users close their work and wait until they have logged out of the
system
Ignore - the system will force close all open documents for all connected users
14
When you create a user-defined field you can select a Type and optionally a Structure for each
user-defined field.
The Structure is dependent on the Type and influences the format of the field.
Be aware that you cannot change the type and structure after you have added the field to the
database. If you mistakenly choose the wrong type or structure, you can remove the field and start
again.
15
Fields with Alphanumeric type can have one of the structures shown here. A Regular structure can
hold up to a maximum of 254 characters. A Text structure can accommodate 2 GB of text in
header fields and 255 KB of text in row fields.
16
Fields with Numeric type can only hold integers, therefore there is no structure.
17
Fields selected with the Date/Time type can have Date or Hour as the structure.
These fields behave in exactly the same way as other date and time fields in the system; for
example, the calendar icon is available in a field with the date structure.
18
To enter fractions as well as integer numbers in the new field, use the Units and Totals type and
select one of the structures shown here.
Decimal places will display in the new field according to the initialization settings on the Display tab
of the General Settings.
19
If you select the General type, the new field can hold links or graphics.
Fields with the Link structure can link to a file or to a web address. You must first define the
default path to the Attachments folder. This is done in the General Settings. This default path is
opened when the user double-clicks the new field. The user can either select a file from the
default folder, or enter a web address in place of the file name.
Fields with the Image structure can accommodate pictures. You must first define the default
path to the Pictures folder, in the General Settings. If this default path is not defined, an error
will occur when the image field is used. When the user double-clicks the image field, the default
folder opens, enabling them to select an image file. The user can then change to a different
folder to locate the image.
The user can, at any time, change an image or web address by pressing the Ctrl key and double-
clicking the image or web address.
20
In addition to the type and structure for a user-defined field, you have the option of specifying
validation options.
21
The option Linked to Entities allows you to set up a direct link between a user-defined field in a
form and a system object, a user-defined table, or a user-defined object. In the example we have
linked a user-defined field in the service contract form with the A/R invoice object.
The link is actually established by the user who creates the form. In the user-defined field the user
will be shown all the instances of the chosen object and can select one to create the direct link. For
example, when creating a service contract for customer C40000 the user can select the invoice
paid by this customer for the service item. After the link is established the user can open the A/R
invoice directly from the user-defined field.
Be aware that the user must select the correct instance, since the system shows all rows stored in
the database for the chosen object.
22
If valid values is chosen, you can define a list of possible values for the user-defined field. This
definition is made when you add the user-defined field.
In the example, you can see that there are three possible values for the field - silver, gold and
platinum.
This list is available in the document as a dropdown list, allowing the user to select one of the
values.
The user cannot update the values in the list. The list values can only be updated by the authorized
user from the User-Defined Fields – Management window.
23
If the Advanced option is selected the system lets you set some simple validation rules for when
the user enters data in the user-defined field.
The validation rules apply to all UDF types with the exception of General type.
The validation controls vary according to the type and structure of the user-defined fields. For
example, for alphanumeric type the rules can check which characters the user can enter in the
field, and how many characters. For units and totals the rules can check that the amount entered
falls in a certain range.
Other rules allow you to validate that the value entered is equal to, less than, or greater than a
value entered when you add the user-defined field.
24
A flexible way of using a user-defined field is to link a query to the field using user-defined values.
The query can automatically populate the field value based on the result of the query.
In the example shown, a query is added to a user-defined field in the header of a sales order. The
query fetches the customer’s account balance from the business partner master data table OCRD.
The query runs automatically when the user selects the customer code when they first create the
sales order.
User-defined values functionality is covered in the companion course User-Defined Values.
25
You can optionally set a default value for any user-defined field.
In the example, we have selected a default time from the list of valid values.
The default value set for a field will appear in all new instances of the object.
You can optionally set the user-defined field as mandatory. The user will not be able to add a new
record without entering data into the mandatory field.
When you set a user-defined field as mandatory, you need to initially supply a default value, to
maintain the integrity of the database. After you have added the user-defined field you can remove
the default value.
If you update a user-defined field to make it mandatory, and the field already has a default value,
the system will prompt you to choose if the default value should be inserted into all existing
instances of the object, or whether to only insert the default value into new instances.
26
Here are some points to take away regarding user-defined fields and tables:
You can add user-defined fields to most objects.
User-defined fields are added to the table for the selected object in the database, and have
prefix “U_”.
For marketing documents, you can add fields to the header (title) area or to the rows.
User-defined fields added at the header level of a marketing document initially appear in a
separate window to the side. You can use the View menu to open this window.
You can move user-defined fields from the side window to the main area of the document using
the Edit Form UI function. You can then make the edited document available to users in a UI
Configuration template.
A value entered into a user-defined fields is transferred to a target document using the Copy
to/Copy from function.
User-defined fields can have various types and structures, such as alphanumeric and regular.
The choice of structure affects the maximum field length and the type of data you can enter in
the field.
You can optionally add a list of valid values to a UDF, link it to a system object, define rules for
validating data entry in the field, set a default value, or make it mandatory. You can also link the
user-defined field to a user-defined table or user-defined object.
27
29