Sub topic 6
Creating a custom field step by step
This chapter walks through creating a custom field in the Custom Fields and Logic app, from the first click to a saved draft that is ready for publication. It assumes you can navigate the SAP Fiori launchpad. It also assumes you know the business objects you want to extend, such as products, business partners and sales orders. You should know the basic data types (text, number, date, amount) and have the key user role from the earlier chapter on authorizations. Publishing and using the field are covered in the next chapter.
What you are building
A custom field is an extra attribute that a key user adds to a standard business object without changing standard code. The system stores the field in an extension include of the underlying structure. It then makes the field available where you choose. Because the field lives in an extension area, it survives upgrades.
Creating a field has four decisions:
- Which business context the field belongs to.
- Which label and field ID the field gets.
- Which data type, length and properties it has.
- Where the field should appear after publication.
The first three are set at creation. The fourth can be adjusted until you publish.
Step 1: Open the app and review the list
Start the Custom Fields and Logic app from the launchpad. If you do not see the tile, your user lacks the key user extensibility business role. Ask an administrator to assign it before you continue.
The app opens on the Custom Fields tab. It lists existing fields with these columns:
- Label, the name users see.
- Field ID, the technical name.
- Business context, the object the field extends.
- Type, such as text or date.
- Status, which tells you whether the field is a draft, published, or in error.
Read this list before you create anything. Duplicate fields are common in teams where several key users work independently. Filter by business context to check whether a field with a similar purpose already exists.
Step 2: Start a new field and choose a context
Choose New. The first required input is the business context. A business context groups the fields that belong to one business object and defines which UIs, reports, forms and APIs can pick up the field. It also determines the suffix of the field ID.
Pick the context that matches where the data is entered, not where you want to read it. For example, a note about a product belongs in the product context even if you mainly want to see it in a sales document. You can often show a product field in related documents by other means. The reverse is harder, because you cannot move a field to another context afterwards.
Step 3: Define label, ID and type
After choosing a context, you fill in the main properties.
Label
The label is the text users see on screens and reports. Write it as you would write a standard field label: short, in title case, and without abbreviations that only your team understands. The field ID is derived from this label, so choose it carefully.
Field ID
The system builds the ID from the label. It adds the YY1_ prefix, removes spaces and special characters, and appends a context suffix.
Custom field ID pattern: YY1_<FieldName>_<suffix>
Example: YY1_CostCenterNote_PRD
The YY1_ prefix marks key user extensions. The suffix is generated by the system from the business context.The YY1_ prefix lets you tell custom fields from standard ones in field lists, reports and API responses. Treat the ID as permanent. You can rename the label later, but the ID stays as generated. If your label contained a typo, the typo stays in the ID.
Field type
The type controls which values the field accepts and how it is displayed. The available types depend on your release, but you will usually see these:
| Type | Use it for | Notes |
|---|---|---|
| Text | Free text such as notes or references | Set a maximum length |
| Number | Whole numbers or decimals such as counters | Define the number of digits and decimals |
| Amount | Money values | Requires a currency |
| Date | Calendar dates | No time of day |
| Checkbox | Yes or no flags | Stored as a Boolean |
| Code List | A fixed set of allowed values | Each value has a code and a description |
Choose the type carefully. Once you publish the field, you cannot change its type, and you usually cannot shorten its length. If you are unsure between text and number, ask whether you will calculate with the values or only display them. Order numbers and phone numbers are text, even though they contain digits. Storing them as numbers drops leading zeros.
Code lists
If the field must accept only certain values, use a code list. You define the values as pairs of a code and a description. Users see the description in a dropdown, and the system stores the code. Codes should be short and stable, for example A, B, C, or STD, EXP. Descriptions can be translated and changed later, but a code that has already been saved in documents should not be removed.
Step 4: Set properties and usage
Below the type settings you usually find the options that control behavior:
- Mandatory or optional. Mandatory fields block saving a document when empty. Use this sparingly. A mandatory custom field on a business object that is also created by APIs and integrations can break those integrations, because they do not know the field.
- Default value. The system fills this value in on new documents.
- Field usage. Select where the field should be available. Typical choices are the user interface, reports, forms and email templates, and APIs.
The usage options are one reason to plan ahead. Enabling a field for a report or an API adds it to a generated structure, and that structure is rebuilt when you publish. A field that you enable for many scenarios takes longer to publish than a plain one, and a problem in one scenario can delay the others.
Step 5: Save as a draft
Choose Save to store your work as a draft. The field now exists in the app, but it does not exist on any screen or API. The status shows that the field is not yet published.
This is the right moment to check:
- The label is spelled correctly and matches your naming convention.
- The context and type are right.
- The length is large enough for real data. Ask a business user for the longest realistic value.
- Mandatory is off unless you have verified that all creating processes can supply a value.
A draft is safe to edit freely. Open it again from the list and change any property that is not locked. Once you are confident, continue to publication in the next chapter.
Worked example: a note on the product
Suppose purchasing wants a short note on each product that explains how costs are assigned. Follow these actions:
- Open Custom Fields and Logic and choose New.
- For the business context, select the product context.
- Enter the label
Cost Center Note. The system proposes the IDYY1_CostCenterNote_PRD. - Choose the type Text and set the length to 100.
- Leave the field optional.
- Under usage, select the user interface and reports.
- Save the draft and check the entries.
When you later read the field in custom logic, you will refer to it by its generated ID, not by its label. The ID is what appears in the field list of a report and in the JSON of an API response. For the product, an API payload would contain a property named YY1_CostCenterNote_PRD. You can search for it in your system documentation by that exact name.
Common errors
| Symptom | Likely cause | What to do |
|---|---|---|
| The New button is missing | The user lacks the key user extensibility authorization | Ask an administrator for the correct business role |
| The business context you need is not in the list | The context is not released for key user extensibility in your release | Check the extensibility options for that object, or consider developer extensibility |
| The system rejects the label | It contains only special characters, or the ID is already in use | Use a different label that yields a unique ID |
| A text field turns out too short | The length was chosen too small before publication | Edit the draft before publishing. After publishing, create a new field |
| A mandatory field breaks an integration | An API or import does not fill the field | Make the field optional, or add a default value |
Practices that save time
- Agree on a naming convention before the team starts. For example, put the business meaning first and avoid the words "New" or "Custom".
- Create fields in a development system and move them through the transport path. Do not create them directly in production unless your landscape has only one system.
- Document each field's purpose in a shared list. The app shows the label and ID, but not why the field exists.
- Delete unused drafts. Drafts that no one finishes make the list harder to read.
Exercise
You created a draft custom field in the product context with the label "Cost Centre Note" and then noticed the spelling should be "Cost Center Note". The field has not been published. Which parts can you still fix, and which cannot be changed?
Show answer
You can change the label, because it is only display text, and you can adjust the type and length while the field is still a draft. The generated field ID, which would be YY1CostCentreNotePRD, stays as it was created, and the business context cannot be changed either. If the ID spelling matters, delete the draft and create a new field with the correct label.
Exercise
A colleague wants to add a "Customs Tariff Code" to products. The values look like 0101 and 9999, and users must keep leading zeros. Which field type should they choose, and why?
Show answer
Text. The code is an identifier, not a quantity. A number type would drop leading zeros and would allow decimals. A text field with a suitable maximum length keeps the value exactly as entered.