SmartChart with NavPopover
an analytical service - you supply the path
Z2UI5_CL_SMPS_APP_479
Stack
Smart Controls
UI5 1.71
needs a system
needs a system. This sample is listed here because a sample somebody cannot find is worse than one they cannot run: SAPUI5 + an activated Gateway service. The ABAP is below; installed on a system that has what it needs, it runs there.
The facts
- Repository
- abap2UI5/samples-stack
- Class
Z2UI5_CL_SMPS_APP_479- Source file
z2ui5_cl_smps_app_479.clas.abap↗- Category
- Smart Controls
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- needs a system — it opens for reading instead
- Runs on
- Cloud + Standard ≥ 7.40 SP08
Keywords: smartchart, navpopover, semanticobjectcontroller, chart, semantic, object, navigation
Controls it builds
- sap.m.Page
- sap.m.Shell
- sap.ui.comp.navpopover.SemanticObjectController
- sap.ui.comp.smartchart.SmartChart
- sap.ui.core.mvc.View
Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.
Libraries
The ABAP
z2ui5_cl_smps_app_479.clas.abap — 86 lines, on branch 02-smart-controls
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords smartchart navpopover semanticobjectcontroller chart semantic object navigation
" @summary an analytical service - you supply the path
CLASS z2ui5_cl_smps_app_479 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
PROTECTED SECTION.
" THIS PATH IS A PLACEHOLDER AND MUST BE REPLACED - the app shows an empty
" chart until it points at a real service.
" Unlike the other smart control demos, a SmartChart cannot fall back to the
" Gateway demo service GWSAMPLE_BASIC: it needs an ANALYTICAL OData V2
" service - properties marked sap:aggregation-role dimension/measure plus the
" UI.Chart annotation the chart layout comes from. No such service is part of
" any standard system, so there is no honest default to ship here; enter the
" analytical service of your system, with an entity set carrying the
" dimensions and measures the view expects.
CONSTANTS c_odata_service TYPE string VALUE `/sap/opu/odata/sap/<YOUR_ANALYTICAL_SERVICE>/`.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smps_app_479 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
IF client->check_on_navigated( ).
DATA(view) = z2ui5_cl_ui5_view_builder=>factory(
)->ele( n = `View` ns = `mvc`
)->a( n = `displayBlock` v = `true`
)->a( n = `height` v = `100%`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->a( n = `xmlns:navpopover` v = `sap.ui.comp.navpopover`
)->a( n = `xmlns:smartChart` v = `sap.ui.comp.smartchart` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Smart Controls - SmartChart`
)->a( n = `showNavButton` b = client->check_app_prev_stack( )
)->a( n = `navButtonPress` v = client->_event_nav_app_leave( ) ).
" The chart, its dimensions/measures and the personalization dialog are all
" metadata-driven; the SemanticObjectController turns the annotated Category
" dimension into a navigation popover and reports its two events back here.
page->ele( n = `SmartChart` ns = `smartChart`
)->a( n = `enableAutoBinding` v = `true`
)->a( n = `entitySet` v = `Products`
)->a( n = `useVariantManagement` v = `true`
)->a( n = `persistencyKey` v = `SmartChart_Explored`
)->a( n = `useChartPersonalisation` v = `true`
)->a( n = `header` v = `Products`
)->ele( n = `semanticObjectController` ns = `smartChart`
)->ele( n = `SemanticObjectController` ns = `navpopover`
)->a( n = `navigationTargetsObtained` v = client->_event( `NAV_TARGETS_OBTAINED` )
)->a( n = `navigate` v = client->_event( val = `NAVIGATE`
t_arg = VALUE #( ( `${$parameters>/text}` ) ) ) ).
client->view_display( val = view->stringify( ) switch_default_model_path = c_odata_service ).
ELSEIF client->check_on_event( `NAV_TARGETS_OBTAINED` ).
" The tutorial answers this event by composing the navigation popover
" imperatively (oParameters.show( ) with LinkData entries and a SimpleForm of
" Title/Image/Text). That is frontend construction of controls, which a thin
" frontend does not express - the wire stays, and the popover keeps the
" content the SemanticObjectController derives from the annotations itself.
client->message_toast_display( `Navigation targets obtained` ).
ELSEIF client->check_on_event( `NAVIGATE` ).
DATA(text) = client->get_event_arg( ).
IF text <> `Homepage`.
client->message_box_display( text = |{ text } has been pressed|
type = `information`
title = `SmartChart demo` ).
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
More in Smart Controls
- Smart Table and Variants — with variant management - UI_PRODUCTLIST
- Switch Default Model — device, HTTP and OData model side by side - GWSAMPLE_BASIC
- Smart Multi Input — UI conditions mapped 1:1 onto an ABAP range table
- SmartField in a SmartForm — needs the GWSAMPLE_BASIC OData service
- SmartForm, editable toggle — needs the GWSAMPLE_BASIC OData service
- SmartFilterBar and SmartTable — needs the GWSAMPLE_BASIC OData service
- Page Variant Management — needs the GWSAMPLE_BASIC OData service
- classic FilterBar variants — no service needed - the data is ABAP
On this page