Binding
Binds a form to a structure with INCLUDEs, so the included components are reachable under their own names on one flat level.
Z2UI5_CL_SMP_APP_166
Learn
Binding
UI5 1.71
The facts
- Repository
- abap2UI5/samples
- Class
Z2UI5_CL_SMP_APP_166- Source file
z2ui5_cl_smp_app_166.clas.abap↗- Category
- Binding
- Learning path
- Get your data on screen
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
- Documentation
- abap2ui5.github.io/docs/cookbook/model/binding ↗
Keywords: structure, component, include, flat, form, level
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_smp_app_166.clas.abap — 113 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords structure component include flat form level
" @summary Binds a form to a structure with INCLUDEs, so the included components are reachable under their own names on one flat level.
" @docs https://abap2ui5.github.io/docs/cookbook/model/binding
CLASS z2ui5_cl_smp_app_166 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_struc_incl,
incl_title TYPE string,
incl_value TYPE string,
incl_value2 TYPE string,
END OF ty_s_struc_incl.
TYPES:
BEGIN OF ty_s_struc,
title TYPE string,
value TYPE string,
value2 TYPE string,
END OF ty_s_struc.
DATA ms_struc TYPE ty_s_struc.
DATA
BEGIN OF ms_struc2.
INCLUDE TYPE ty_s_struc.
INCLUDE TYPE ty_s_struc_incl.
DATA END OF ms_struc2.
METHODS set_view.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smp_app_166 IMPLEMENTATION.
METHOD set_view.
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` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Binding - Structure Fields and INCLUDEs`
)->a( n = `showNavButton` b = client->check_app_prev_stack( )
)->a( n = `navButtonPress` v = client->_event_nav_app_leave( ) ).
page->tag( `MessageStrip`
)->a( n = `text` v = `This sample demonstrates structure-level binding: each input is bound to a ` &&
`field of a flat structure, including fields pulled in via INCLUDE.`
)->a( n = `type` v = `Information`
)->a( n = `showIcon` b = abap_true
)->a( n = `class` v = `sapUiSmallMargin` ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc-title ) ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc-value ) ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc-value2 ) ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc2-title ) ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc2-value ) ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc2-value2 ) ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc2-incl_title ) ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc2-incl_value ) ).
page->tag( `Input`
)->a( n = `value` v = client->_bind( val = ms_struc2-incl_value2 ) ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
ms_struc-title = `title`.
ms_struc-value = `val01`.
ms_struc-value2 = `val02`.
ms_struc2-title = `title`.
ms_struc2-value = `val01`.
ms_struc2-value2 = `val02`.
ms_struc2-incl_title = `title_incl`.
ms_struc2-incl_value = `val01_incl`.
ms_struc2-incl_value2 = `val02_incl`.
set_view( ).
ELSEIF client->check_on_navigated( ).
set_view( ).
ENDIF.
ENDMETHOD.
ENDCLASS.
More in Binding
- Binding — A View Built From RTTI, No Field Named
- Binding — Currency Amounts (sap.ui.model.type.Currency)
- Binding — Dynamic Table Typed at Runtime (RTTI)
- Binding — Expression Binding, Types and Composite Parts
- Binding — Model setSizeLimit for Large Tables (A)
- Binding — Single Table Cell (tab_index)
- Binding — Types for Integer, Decimal, Date and Time
On this page