Sub topic 5
Choosing the right business context
This chapter assumes you can open the Custom Fields and Logic app in the SAP Fiori launchpad. It also assumes you know the business objects involved, such as sales orders, products and business partners. You need no ABAP knowledge here.
What a business context is
An extensibility business context is a group of related extensible objects. SAP defines it for a business area, for example a sales document header, a sales document item, a product or a purchase order item. Each context stands for the places in the system where a field of that kind belongs.
When you create a custom field, you assign it to a context. The system then adds the field to everything that context covers. Depending on the context, this can include:
- the database table that stores the data
- the CDS views and service entities that expose the data
- the UI, search, report and form entities of the context
- the released APIs of the business object
Because of this, the context decides where your field can appear. It also decides what the field can be used for later. You are not choosing a folder. You are choosing which business object stores the value.
Header, item and other levels
Many business objects have several levels, and each level usually has its own context. A field on a sales order header holds one value per order. A field on an item holds one value per line.
| Need | Typical level | Reason |
|---|---|---|
| A reference number for the whole order | Header | One value per document |
| A packaging note per material line | Item | Different value on each line |
| A customer classification | Business partner | The value belongs to the partner, not the order |
| An internal product grade | Product | The value belongs to the product master data |
If you pick the wrong level, users cannot find the field where they expect it. A header field cannot hold different values for different items.
How the context shows up in the field ID
The system builds the technical field ID from your field name and the context. Key user fields always start with YY1_. The generated suffix depends on the business context.
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 ID is how you recognize the field in field lists, reports and API responses. Two fields with the same label can belong to different contexts. Their IDs will differ.
A decision path
Ask these questions in order before you create the field.
- Name the business object that owns the value. Ask where the data belongs in business terms, not where users will look at it.
- Decide how often the value changes. One value per document points to a header context. One value per line points to an item context. A value that stays the same across documents belongs to master data.
- Check what the context offers. Open the context in the app and look at the usages it supports, such as UIs, reports, forms and APIs. Not every context supports every usage.
- Create the field only after these checks pass.
Common mistakes
- Choosing by screen, not by data. A user sees a value on an order screen, so you pick the order context. The value actually belongs to the product, so you now copy it into every order by hand.
- Expecting a field to follow data to another object. A field in one context does not appear in another context automatically. If the order should show a product field, plan a way to read it, for example through a released CDS view.
- Changing your mind late. Treat the context as fixed once you publish the field. Changing it afterward is limited or impossible, and you may have to create a new field and move the data. Decide before publication.
- Ignoring the transport target. Contexts must exist in the target system. If your quality system is missing a context, the transport can fail.
Check your understanding
Exercise
A team wants to record a "Customs tariff note" that differs for each line of a sales order. Which kind of business context should they choose, and what happens if they choose the header context instead?
Show answer
They should choose the sales document item context, because the value is different for each line. With the header context, the field would store only one value per order, so lines could not carry different notes.
Exercise
You find the field YY1CostCenterNotePRD in an API response. What do the prefix and the suffix tell you?
Show answer
The YY1_ prefix shows that a key user created the field as an extension. The suffix is generated from the business context, so it tells you which context the field belongs to (here, a product-related one).