ABAP RAP

UIs and Services

Scope

This slide deck covers the design of UIs for RAP-based applications.

  • What is possible with Fiori Elements, and where are the limits?

Layouts and Floorplans

Fiori Elements supports multiple floorplans. See the Fiori Design Guidelines for details: https://experience.sap.com/fiori-design-web/floorplan-overview/.

The most relevant floorplans for RAP are:

  • Overview Page
  • List Report
  • Worklist
  • Analytical List Page
  • Object Page

Without Fiori Tools the two bolded floorplans (List Report and Object Page) are the ones you can use with RAP.

Example and demo for the UI5 documentation

https://sapui5.hana.ondemand.com/sdk/#/topic/214dc25fb47f42c6a0091dfe71e87950

Header Annotations

Header annotations let you define the header information that appears in an Object Page or List header.

@UI: {
	headerInfo: {
		typeName: 'Kommentar',
		typeNamePlural: 'Kommentare',
		typeImageUrl: 'sap-icon://comment',
		description.value: 'CommentText',
		title.value: 'TaskKey'
	}
}
...
define root view entity zbc_c_tasks 
	as select from zbc_tasks {
...

Value Helps

Every input field can have a value help (also for search fields). A value help is usually based on a CDS view that provides the lookup data.

You connect the field to the value help using the field annotation:

@Consumption.valueHelpDefinition.entity: { Name : <CDS View>, 
																					 Element: <FieldName> }

The value-help CDS view can read from any table and can be implemented as a CDS Table Function using SQLScript if needed.

A frequent scenario is using the table DD07T (domain fixed values). You can reference it directly.

More complex value helps are implemented with the additionalBinding where you can bind multiple fields so the UI values restrict the value help.

Texts for keys

If you want a human-readable or language-dependent text for a key (for example the GENDER field), use a text association.

Text view

@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Gender Value Help'
define view entity zi_jb1c_gender
	as select from dd07t
{
	key valpos     as value_position,
  
			@Semantics.language: true
	key ddlanguage as language,
			domvalue_l as value,
      
			@Semantics.text: true
			ddtext     as text
}
where
	domname = 'ZBC_GENDER'

Integration in RAP


define view entity ZI_JB2_USERS
	as select from zbc_users
  
	association [0..1] to zi_jb1c_gender as _GenderText 
	on $projection.Gender = _GenderText.value
        
{
	key user_id       as UserId,
			...
			@ObjectModel.text.association: '_GenderText'
			gender        as Gender,
			...
			_GenderText
}

Multi-line long text fields

Use @UI.multiLineText: true for long text areas.

@UI.multiLineText: true

TextArea

More info

List Report

List Report Features

  • Search fields for individual columns and a fuzzy search field for multiple columns
  • Column personalization
  • Header area

List Report Annotations

The annotation @UI.lineItem defines that a field is displayed as a column in a table. Usually position is provided.

@UI.lineItem: [ { position: 30 ,         
									label: 'Bearbeiter' ,
									importance: #HIGH
									} ]  
Assignee,

@ObjectModel.text.element connects an identifier element with its language-independent descriptive texts.

@ObjectModel.text.element: [ 'Name' ]
key user_id       as UserId,

Annotations for list presentation

Whether a field appears in a List Report or as a child list is controlled by annotations:

  • UI.lineItem.position - Position that determines display order.
  • UI.lineItem.importance - Importance (used when columns are hidden due to limited space).
  • UI.lineItem.label - Column title.

Annotations for selection fields (Filters)

Filter

Users can personalize filter fields in a List Report. If you use the annotation @UI.selectionField you can define default filter fields. Again, position must be provided.

@UI.selectionField: [ { position: 10, 
												label: 'Aufgabenstatus',
												exclude: true } ]
Status,

Annotations for search (fuzzy search)

For a fuzzy search across multiple fields you can use @Search at the view level and mark the view as searchable.
@Search.searchable: true

For each field that should be searchable add the following annotation:

@Search:{ defaultSearchElement: true,
					fuzzinessThreshold: 0.7 }  

The fuzzinessThreshold (interval 0..1) controls how fuzzy the search is. SAP recommends 0.7 as a starting value.

Object Page Layout

Object Pages - Field Groups (Facets)

Groups of fields with a heading:

Facets display

Object Pages - Facet example

Define a facet group:

@UI.facet: [ { label: 'Task Info', 
							 purpose: #STANDARD, 
							 type: #FIELDGROUP_REFERENCE,
							 targetQualifier: 'TaskInfo' }]

Assign fields to the group


@UI.fieldGroup: [ { importance: #HIGH, 
										position: 10, 
										qualifier: 'TaskInfo' } ]                    
@UI.lineItem: [{ position: 10 }]
@UI.identification: [{ position: 10 }]
		TaskKey;

Collapsible areas - Show More / Show Less

Using the annotation

isPartOfPreview: false

in a facet allows the area to be collapsed on first load. The UI then shows a "Show More" / "Show Less" toggle to expand or collapse the section.

Example

	@UI.facet: [  { label: 'Task Info',
									 purpose: #HEADER,
									 type: #FIELDGROUP_REFERENCE,
									 targetQualifier: 'TaskInfo',
									 isPartOfPreview: false }]

Preview example

Groups on the Object Page

Define groups

	@UI.facet: [ {    id: 'Details',
										purpose: #STANDARD ,
										type:     #FIELDGROUP_REFERENCE,
										label: 'Details',
										position: 20 ,
										targetQualifier: 'Details'}  ]

Assign fields


	@UI.fieldGroup: [ { qualifier: 'Details' ,
											position: 20 }]
	Name;

Services

The services used so far are local development bindings. This means transports to downstream systems are not available. For production-ready applications you must add a service for publishing. Use transaction /IWFND/MAINT_SERVICE or the publish button in the Service Binding.

Service Definitions

  • Service Definitions determine which Business Objects are exposed by the service. With aliases you can present nicer external names for technical objects.
@EndUserText.label: 'Task Management'
DEFINE SERVICE zbc_tm {
	EXPOSE zc_users AS Users;
	EXPOSE zc_tasks AS Tasks;
}

Service Bindings

Service Bindings assign a protocol to previously defined services. Available binding types include:

  • OData 2.0 (V2) or 4.0 (V4)
    • UI - transfers UI annotations
    • Web API - without UI annotations
  • InA - UI - for analytical models (e.g. live access)
  • SQL - Web API - access via Open SQL

SAP recommends using V4. V4 supports Fiori Elements with Draft fully. V2 still works but transfers more data volume.

/n/IWFND/MAINT_SERVICE (1)

Add a service:

Search for the binding:

/n/IWFND/MAINT_SERVICE (2)

The transaction SEGW is not required.