abap2UI5

Object Number

The object number is a small building block representing an important, numerical attribute of an object together with it's unit. Often it is used in the last column of a table.

Z2UI5_CL_SMPC_APP_072

Controls sap.m UI5 1.86

The facts

Repository
abap2UI5/samples-controls
Class
Z2UI5_CL_SMPC_APP_072
Source file
z2ui5_cl_smpc_app_072.clas.abap
Library
sap.m
UI5 entity
sap.m.ObjectNumber
Demo kit sample
sap.m.sample.ObjectNumber
SAP's own sample
running at sdk.openui5.org ↗
Minimum UI5
1.86
In the playground
runs in the browser, with no system and nothing installed

Keywords: objectnumber, object, number, sap.m, states, inverted, interactive, styles, verticallayout, label, horizontallayout, panel

Controls it builds

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

Run it here

The sample running, in this page — the app on its own, with no editor over it. Switch to Playground with this code

Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.

The ABAP

z2ui5_cl_smpc_app_072.clas.abap — 334 lines Read it on GitHub ↗
" @keywords objectnumber object number sap.m states inverted interactive styles verticallayout label horizontallayout panel
" @summary The object number is a small building block representing an important, numerical attribute of an object together with it's unit. Often it is used in the last column of a table.
CLASS z2ui5_cl_smpc_app_072 DEFINITION PUBLIC.

  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.

    TYPES:
      BEGIN OF ty_s_product,
        price         TYPE p LENGTH 8 DECIMALS 2,
        currency_code TYPE string,
      END OF ty_s_product.
    DATA t_products TYPE STANDARD TABLE OF ty_s_product WITH EMPTY KEY.

  PROTECTED SECTION.
    DATA client TYPE REF TO z2ui5_if_client.

    METHODS view_display.
    METHODS model_init.

  PRIVATE SECTION.
ENDCLASS.


CLASS z2ui5_cl_smpc_app_072 IMPLEMENTATION.

  METHOD z2ui5_if_app~main.

    me->client = client.
    IF client->check_on_init( ).
      model_init( ).
      view_display( ).
    ELSEIF client->check_on_navigated( ).
      view_display( ).
    ENDIF.

  ENDMETHOD.


  METHOD view_display.

    DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).

    " the shared Currency number binding (parts Price + CurrencyCode, showMeasure off), reused on every ObjectNumber
    DATA(num) = |\{ parts:[\{path:'PRICE'\},\{path:'CURRENCY_CODE'\}], type: 'sap.ui.model.type.Currency', formatOptions: \{showMeasure: false\} \}|.

    view->ele( n = `View` ns = `mvc`
        )->a( n = `xmlns:l`   v = `sap.ui.layout`
        )->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
        )->a( n = `xmlns`     v = `sap.m`

        )->ele( n = `VerticalLayout` ns = `l`
            )->a( n = `class` v = `sapUiContentPadding`
            )->a( n = `width` v = `100%`
            )->tag( `Label`
                )->a( n = `text`   v = `ObjectNumber`
                )->a( n = `class`  v = `sapUiSmallMarginTop`
                )->a( n = `design` v = `Bold`
            )->ele( n = `HorizontalLayout` ns = `l`
                )->a( n = `class` v = `sapUiContentPadding`
                " element binding kept 1:1 - each ObjectNumber index-binds a record of the default-model table T_PRODUCTS (see sidecar)
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/0\}|
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/1\}|
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                    )->a( n = `state`   v = `Error`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/2\}|
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                    )->a( n = `state`   v = `Warning`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/3\}|
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                    )->a( n = `state`   v = `Success`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/4\}|
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                    )->a( n = `state`   v = `Information`

            )->end(
        )->end(

        )->ele( n = `VerticalLayout` ns = `l`
            )->a( n = `class` v = `sapUiContentPadding`
            )->a( n = `width` v = `100%`
            )->tag( `Label`
                )->a( n = `text`   v = `Inverted ObjectNumber`
                )->a( n = `class`  v = `sapUiSmallMarginTop`
                )->a( n = `design` v = `Bold`
            )->ele( n = `HorizontalLayout` ns = `l`
                )->a( n = `class` v = `sapUiContentPadding`
                " POST-1.71: inverted, active and press (since UI5 1.86) kept 1:1
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/0\}|
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/1\}|
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                    )->a( n = `state`    v = `Error`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/2\}|
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                    )->a( n = `state`    v = `Warning`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/3\}|
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                    )->a( n = `state`    v = `Success`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/4\}|
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                    )->a( n = `state`    v = `Information`

            )->end(
        )->end(

        )->ele( n = `VerticalLayout` ns = `l`
            )->a( n = `class` v = `sapUiContentPadding`
            )->a( n = `width` v = `100%`
            )->tag( `Label`
                )->a( n = `text`   v = `Interactive ObjectNumber`
                )->a( n = `class`  v = `sapUiSmallMarginTop`
                )->a( n = `design` v = `Bold`
            )->ele( n = `HorizontalLayout` ns = `l`
                )->a( n = `class` v = `sapUiContentPadding`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `active`  v = `true`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/0\}|
                    )->a( n = `press`   v = client->follow_up_action( val   = client->cs_event-control_global
                                                                      t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `active`  v = `true`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/1\}|
                    )->a( n = `press`   v = client->follow_up_action( val   = client->cs_event-control_global
                                                                      t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                    )->a( n = `state`   v = `Error`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `active`  v = `true`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/2\}|
                    )->a( n = `press`   v = client->follow_up_action( val   = client->cs_event-control_global
                                                                      t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                    )->a( n = `state`   v = `Warning`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `active`  v = `true`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/3\}|
                    )->a( n = `press`   v = client->follow_up_action( val   = client->cs_event-control_global
                                                                      t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                    )->a( n = `state`   v = `Success`
                )->tag( `ObjectNumber`
                    )->a( n = `class`   v = `sapUiSmallMarginBottom`
                    )->a( n = `active`  v = `true`
                    )->a( n = `binding` v = |\{{ client->_bind_path( t_products ) }/4\}|
                    )->a( n = `press`   v = client->follow_up_action( val   = client->cs_event-control_global
                                                                      t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`  v = num
                    )->a( n = `unit`    v = `{CURRENCY_CODE}`
                    )->a( n = `state`   v = `Information`

            )->end(
        )->end(

        )->ele( n = `VerticalLayout` ns = `l`
            )->a( n = `class` v = `sapUiContentPadding`
            )->a( n = `width` v = `100%`
            )->tag( `Label`
                )->a( n = `text`   v = `Inverted Interactive ObjectNumber`
                )->a( n = `class`  v = `sapUiSmallMarginTop`
                )->a( n = `design` v = `Bold`
            )->ele( n = `HorizontalLayout` ns = `l`
                )->a( n = `class` v = `sapUiContentPadding`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `active`   v = `true`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/0\}|
                    )->a( n = `press`    v = client->follow_up_action( val   = client->cs_event-control_global
                                                                       t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `active`   v = `true`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/1\}|
                    )->a( n = `press`    v = client->follow_up_action( val   = client->cs_event-control_global
                                                                       t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                    )->a( n = `state`    v = `Error`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `active`   v = `true`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/2\}|
                    )->a( n = `press`    v = client->follow_up_action( val   = client->cs_event-control_global
                                                                       t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                    )->a( n = `state`    v = `Warning`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `active`   v = `true`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/3\}|
                    )->a( n = `press`    v = client->follow_up_action( val   = client->cs_event-control_global
                                                                       t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                    )->a( n = `state`    v = `Success`
                )->tag( `ObjectNumber`
                    )->a( n = `class`    v = `sapUiSmallMarginBottom`
                    )->a( n = `active`   v = `true`
                    )->a( n = `inverted` v = `true`
                    )->a( n = `binding`  v = |\{{ client->_bind_path( t_products ) }/4\}|
                    )->a( n = `press`    v = client->follow_up_action( val   = client->cs_event-control_global
                                                                       t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                    )->a( n = `number`   v = num
                    )->a( n = `unit`     v = `{CURRENCY_CODE}`
                    )->a( n = `state`    v = `Information`

            )->end(
        )->end(

        )->ele( n = `VerticalLayout` ns = `l`
            )->a( n = `class` v = `sapUiContentPadding`
            )->a( n = `width` v = `100%`

            )->tag( `Label`
                )->a( n = `text`   v = `ObjectNumber with style sapMObjectNumberLarge applied`
                )->a( n = `class`  v = `sapUiSmallMarginTop`
                )->a( n = `design` v = `Bold`
            )->tag( `ObjectNumber`
                )->a( n = `class`      v = `sapMObjectNumberLarge`
                )->a( n = `binding`    v = |\{{ client->_bind_path( t_products ) }/5\}|
                )->a( n = `number`     v = num
                )->a( n = `unit`       v = `{CURRENCY_CODE}`
                )->a( n = `emphasized` v = `false`
                )->a( n = `state`      v = `None`

            )->tag( `Label`
                )->a( n = `text`   v = `Interactive ObjectNumber with style sapMObjectNumberLarge applied`
                )->a( n = `class`  v = `sapUiSmallMarginTop`
                )->a( n = `design` v = `Bold`
            )->tag( `ObjectNumber`
                )->a( n = `class`      v = `sapMObjectNumberLarge`
                )->a( n = `active`     v = `true`
                )->a( n = `binding`    v = |\{{ client->_bind_path( t_products ) }/5\}|
                )->a( n = `press`      v = client->follow_up_action( val   = client->cs_event-control_global
                                                                     t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                )->a( n = `number`     v = num
                )->a( n = `unit`       v = `{CURRENCY_CODE}`
                )->a( n = `emphasized` v = `false`
                )->a( n = `state`      v = `None`

            )->tag( `Label`
                )->a( n = `text`   v = `ObjectNumber wrapped via sapMObjectNumberLongText`
                )->a( n = `class`  v = `sapUiSmallMarginTop`
                )->a( n = `design` v = `Bold`
            )->ele( `Panel`
                )->a( n = `backgroundDesign` v = `Transparent`
                )->a( n = `width`            v = `100px`
                )->ele( `content`
                    )->tag( `ObjectNumber`
                        )->a( n = `class`      v = `sapMObjectNumberLongText`
                        )->a( n = `active`     v = `true`
                        )->a( n = `binding`    v = |\{{ client->_bind_path( t_products ) }/5\}|
                        )->a( n = `press`      v = client->follow_up_action( val   = client->cs_event-control_global
                                                                             t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `PRESS fired!` ) ) )
                        )->a( n = `number`     v = `12345678901234567890`
                        )->a( n = `unit`       v = `{CURRENCY_CODE}`
                        )->a( n = `emphasized` v = `false`
                        )->a( n = `state`      v = `None`

                )->end(
            )->end(
        )->end( ).

    client->view_display( view->stringify( ) ).

  ENDMETHOD.


  METHOD model_init.

    " records /ProductCollection/0..5 of ui5/mock/products.json, verbatim (Price + CurrencyCode)
    t_products = VALUE #(
      ( price = '956.00'  currency_code = `EUR` )
      ( price = '1249.00' currency_code = `EUR` )
      ( price = '1570.00' currency_code = `EUR` )
      ( price = '1650.00' currency_code = `EUR` )
      ( price = '299.00'  currency_code = `EUR` )
      ( price = '1999.00' currency_code = `EUR` ) ).

  ENDMETHOD.

ENDCLASS.

More in sap.m

Search every abap2UI5 sample · the full list on one page

On this page