Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

FAB's primary container for the field values are stored in the Fields Area Section of the application definition. For every Bound Field, this assignment should be reflected in the Fields area. FAB provides an automated way of creating the Field Name when it is assigned to the Bound Field of the element.
Image Removed
The Fields can be accessed in Javascript using the FAB delivered functions:
getField("fieldName")
setField("fieldName", value)

Additionally the Fields are passed to the ABAP methods in a form of [Field Name / Field Value] pair. The sample below shows the Field "BUKRS" having a value of "1000" in the method ENHANCE_DATA_BEFORE_SAVE. The rest of the fields are System fields provided by FAB.
Image Removed

...

titleRecommended Setting

It is highly recommended to mark the Use Data Model from the Properties sections and use the FAB Data Model Node in building up the fields, structures and tables list. The fields from the FAB Data Model Node will still have to be assigned to the Bound Field of the relevant control element. This will in turn create the same field list in the Fields Area Section like what has been exhibited in the above example.

Image Removed

Info

Synchronize the fields in the Data Model Node from the fields in the Fields Area Section by using the option Adopt from Fields and Tables as shown below
Image Removed

...

The Data Model of your application is shown in the Data Structure panel of the development workbench.  It shows a hierarchical structure of the fields you need your application to read and write.  It's hierarchical structure allows for the creation of structures and tables that help to both categorize and store complex data structures.

When you add a UI control to your form (e.g. Input), you can set the Bound Field property to an existing field in the data mode by either typing in the name or using the search help.  If a field does not exist in the data model, you can simply enter in a name in the Bound Field property.  This will automatically create a new field in your data model under the root node.

The Data Model has the following characteristics:

  1. Allows hierarchical/nested data model that provides a more logical definition.

    Image Modified
    Root Node
    1. Customer - Individual field of type string
    2. Orders - Table for Order header
      1. OrdersStruct - Structure holding the Order header fields
      2. OrderItems - Table for Order items
        1. OrderItemsStruct - Structure holding the Order items fields

  2. Fields can be referenced to SAP Data Elements

    Image Modified

  3. More fine-grained definition of model field properties (example field OrderDate is a Date in one part of the model, but String in another part).

    Image Modified

...


Accessing and Manipulating Data in the Data Model

...

through ABAP

  • A variable CR_DATA

...

  • is passed into most FAB user-exits in your implementation class that allow much easier interrogation and setting of data in the app at run-time.

...

  •  

    Image Modified

  • FAB auto-generates a nested structure GS_DATA into the definition of the Implementation Class defined in the properties. This can be used for simpler use of the CR_DATA (Type ANY) by simply performing MOVE-CORRESPONDING CR_DATA TO GS_DATA in your implementations. If changing the data use MOVE-CORRESPONDING GS_DATA TO CR_DATA

    Image Modified
  • FAB User exits can directly modify the data upon an Action at run-time and reflect this in the front-end app immediately. Use the structure and technique mentioned in the previous point.


Accessing and Manipulating the Data Model in JavaScript

Fields in the Data Model can be accessed in Javascript using the FAB delivered functions:


Code Block
languagejs
titleRetrieving the value of a field in the Data Model
// Set the value of the variable value to the value stored in the field 'fieldName'
var value = getField('fieldName');


Code Block
languagejs
titleSetting the value of a field in the Data Model
// Set the field with name 'fieldName' to the value 'Value'
setField('fieldName', 'Value');

// Set the field with name 'fieldName' to the data contained in the variable value
var value = 'New Value';
setField('fieldName', value);


  • Within JavaScript too it is easier to get/set data in the model. The data in the app at run-time has the same structure as represented in the FAB/ABAP Data Model Note only that it is in JSON format. Here we know of it more as the ‘Model’, and we can access it via standard JavaScript Code or more efficiently use the FAB delivered functions.

    For example: getField(“Orders”) will retrieve the array of Orders
    Image Modified

    Here the first Order contains 2 OrderItems and the second as 3.
    Image Modified

    You can access the OrderItems of the a particular index using the syntax getField("Orders/0/OrderItems")

    Image Modified

...

How to use the FAB Data Model Node.

  1. Mark the Use Data Model in the properties of the application
  2. Right click on the Project and select Add Data Model
    Image Removed
  3. Right click on the Root Node and select either of the following:
    -Add Field - to add individual fields

    -Add Structure Type Node - to add structures
    -Add Table Type Node - to add table types
    -Adopt from Fields - choose this option to copy the Fields into the Data Model Root Node
    Image Removed
  4. Assign the Data Model field into the Bound Field of the control
    Image Removed
  5. Access the fields in Javascript using the FAB delivered functions and in FAB User Exits by referring to the variable CR_DATA

Note: If the Data Model is not selected in an app, and the option 'DoNotSave' is checked in the bound field of an input field, the data entered onto that particular field doesn't get saved in the backend table /IQX/FORMS_INST.

...

Sample FAB Application

Upload this XML file in the FAB Workbench (TCODE /IQX/FAB)

View file
nameADAM_DEMO_DATA_MODEL_000001.xml
height250

Create a class in SE24 with the name YCL_ADAM_DEMO_DATA_MODEL. Once created, switch the Class in Source Code-Based mode by clicking on  then copy and paste the code from the file below. Activate the class
View file
nameYCL_ADAM_DEMO_DATA_MODEL
height250

...