Skip to content

Entity

An entity data source that connects to a regular entity model.


@Override  
entity IsoUnit {  
   crud = Read;  
   exclude attributes = Description;  
}  

A projection entity can also be derived from a model with a different name. This is typically the case when several slightly different types of data is stored within the same database entity.


@Override  
entity ActiveIsoUnit using IsoUnit {  
   where = "used_in_appl = TRUE";  
}  

Note! This is typically generated for all referenced entity models and need not be specified, unless some properties or attributes need to be changed.

Example 1 (Entity with attributes, arrays and references):


@Override  
entity FlexibleBreakRule {  

   attribute MaximumBreakLimit Number;  
   attribute MinimumBreakLimit Number;  

   array FlexibleBreakRuleDetailArray(CompanyId, WageClass, FlexibleBreakRuleId) to FlexibleBreakRuleDetail(CompanyId, WageClass, FlexibleBreakRuleId);  

   reference PersonCompanyRef(CompanyId) to PersonCompany(CompanyId);  
   reference WageClassRef(CompanyId, WageClass) to WageClass(CompanyId, WageClass);  
   reference NormalWageCodeRef(CompanyId, WageClass, WageCodeNormal) to WageCode(CompanyId, WageClass, WageCode);  
   reference OutsideWageCodeRef(CompanyId, WageClass, WageCodeOutside) to WageCode(CompanyId, WageClass, WageCode);  
   reference BreakWageCodeRef(CompanyId, WageClass, WageCodeBreakhours) to WageCode(CompanyId, WageClass, WageCode);  
}  

Attribute

A data item that represents one field/column/attribute of the data source.


attribute RunwayLength Integer;  

All attribute properties get default values. They can be changed individually when necessary.


attribute RunwayLength Integer {  
   label     = "Runway Limit";  
   fetch     = "length";  
   type      = Number;  
   required  = [false];  
   editable  = [false];  
}  

Default

PL/SQL code to fetch default data for this attribute.

Either a constant:


default = "trunc(sysdate)";  

Or a PL/SQL enumeration constant (must be DB value):


default = "Some_Enum_API.DB_SOME_NAME";  

Or a PL/SQL function call, optionally with bind variables using other attributes:


default = "Some_API.Get_Some_Value(:MyKey)";  

Editable

This evaluates as a boolean expression to determine if the item is editable or not.


attribute FlightNo Text {  
   editable = [false];  
}  

Note! Editable flag is default set to [true].

The following example allows a value to be entered to this field, when inserting a new record, but prevents any updating after that.


editable = [ETag = null];  

Exec

The PL/SQL package that serves up the db actions for this entity.


entity Flight {  
   exec = "Flight_Registry_API";  
   ...  
}  

Fetch

SQL select part to fetch this attribute.

Either a column name, such as:


fetch = "flight_no";  

Or any other valid SQL that can be used in the SELECT part of an SQL statement.


fetch = "Flight_API.Get_Actual_Carrier_Name(flight_no)";  

Fileinfo


Stream file details  

Format

Formatting for field:


attribute RoleName Text {  
   format = uppercase;  
}  

The following formatting options are available:

  • decimal
  • ifscurrency
  • lowercase
  • percentage
  • uppercase

Number of decimal and use of grouping (thousands separator) are currently hardcoded as below:

IFSCURRENCY: 2 decimals without grouping (Default settings in IEE)

DECIMAL: 2 decimals with grouping (Default for most regional setting on windows.)

Implementation

Use this to change the implementation handling of this item (typically attribute or action) to marble, instead of the default which is PL/SQL

Note! This should only be used when a custom implementation is necessary, where the default PL/SQL implementation is not sufficient.

Implementationtype

Use this to specify Odata type of the column.


implementationtype = "VARCHAR2(20)";  

Label

Field label text, excluding any trailing ':' character.


attribute FlightNo Text{  
   label = "Flight Number";  
}  

Note! Default label text is the same as the name, but with spaces between words. For example, 'FlightNo' has 'Flight No' as the default label.


attribute ThirdAmountDebit Number {  
   label = "Years of Experience - Person(${PersonId})";  
}  

attribute ThirdAmountDebit Number {  
   label = "Debit Amount in ${CompanyFinanceRef.ParallelAccCurrency}";  
}  

Maxlength

Maximum field length.


attribute FlightNo Text {  
   maxlength = 10;  
}  

Regexp

Regular expression that the field content needs to match.


attribute FlightNo Text {  
   regexp = "[A-Z]{2}[0-9]+";  
}  

Required

This evaluates as a boolean expression to determine if the item is required or not.


attribute FlightNo Text {  
   required = [PlannedDate != null];  
}  

Note! Required flag is by default set to true.

Validate

Use this to validate the content of an attribute.


attribute FlightNo Text {  
   validate [ObjState != "InProcess"] message "Flight no can only be set when not used.";  
}  

attribute MinimumValue Number {  
   default = "0";  
   validate [MinimumValue <= MaximumValue] message "Maximum value should be greater than Minimum value";  
}  

Crud

This setting is optional. The default setting is Create, Read, Update, Delete for entities and Read for query/summary.

A typical example is when you want to have a read-only entity:


@Override  
entity Flight {  
   crud = Read;  
   ...  
}  
crud = Read, Update, Create;  

The last line allows Read, Edit and Create, but not Delete.

When crud = Read, it disables all the crud operations, and make an entity read-only. But there can be necessary to perform state changing actions even though the entity is read-only:

Syntax:


crud = <Action value/values>  

None has been added as a possible value for crud, in case the entity should be hidden in the metadata. This is mainly targeted for integration development, where a clean integration api is desired.

Action values are Create, Update, Delete, Read, StateChange.

In order to perform a state change even though the entity is read-only, the CRUD action needs to be specified as the example below:


crud = Read, StateChange;  

@Override  
entity CustomerAgreement {  
   crud = Read, StateChange;  
}  

StateChange CRUD action allows the user to perform state changes, and it can be used with other CRUD actions as well.

Note! If crud = Update, then StateChange is enabled by default.

From

The FROM part of the SQL SELECT statement that fetches data for this entity.

Example 1:


entity Flight {  
   from = "flight_registry";  
   ...  
}  

Note! If no table/view name is set, then the entity is non-persistent.

Example 2:


query ProjectMilestoneOrder {  
   from = "project_milestone_order";  
}  

Example 3:


query FinNoteTxt {  
   from = "fin_note_text a, invoice_note b";  
   where = "a.note_id = b.note_id";  
   keys = Company, InvoiceId, NoteId, RowNo;  
   ludependencies = FinNoteTxt;  
}  

References

Data from referenced data sources can be included as follows.


reference MainContactRef(MainContactId) to PersonInfo(PersonId);  
reference ManagerRef(MainContactId) to PersonInfo(PersonId);  

Example 1 (All connected code related to references to an entity and a query):

Entity model


entityname IsoLanguage;  
component  APPSRV;  

codegenproperties {  
   DbObjversionStyle "rtrim(rpad(description||chr(31)||used_in_appl,2000))";<br/>   TitleText         "ISO Language Code";<br/>}<br/><br/>attributes {<br/>   key          LanguageCode TEXT(2)              KMI-L;<br/>   private      Description  TEXT(740)            AMIUL {<br/>      DbBasicDataTranslation "true";<br/>   }<br/>   private      UsedInAppl   TEXT(5)              AMIU- {<br/>      LabelText "Used in Application";<br/>   }<br/>}<br/>

Projection model


@Override  
entity BasicDataTranslation {  
   ludependencies = LanguageSysImp;  
   attribute Module Text {  
      editable = [false];  
      format = uppercase;  
   }  
   attribute MainType Text {  
      required = [false];  
   }  
   attribute Type Text {  
      required = [false];  
   }  
   attribute Path Text {  
      required = [false];  
   }  
   attribute Attribute Text {  
      required = [false];  
   }  
   attribute InstallationText Text {  
      editable = [false];  
   }  
   attribute SystemDefined Boolean("TRUE", "FALSE") {  
      editable = [false];  
   }  
   reference AttributeKeyRef(Module, Lu, AttributeKey) to BasicDataTranslationLov(Module, Lu, AttributeKey) {  
      label = "Attribute Key";  
   }  
   @DynamicComponentDependency APPSRV  
   reference IsoLanguageRef(LangCode) to IsoLanguage(LanguageCode) {  
      label = "Language Code";  
   }  
}  

query BasicDataTranslationLov {  
   from = "BASIC_DATA_TRANSLATION_LOV";  
   keys = Module, Lu;  
   attribute Module Text;  
   attribute Lu Text;  
   attribute AttributeKey Text;  
   attribute Text Text;  
}  

Client model


list BasicDataTranslationList for BasicDataTranslation {  
   label = "Translations";  
   lov AttributeKeyRef with AttributeKeyRefSelector {  
      editable = [ETag = null];  
   }  
   field IsoLanguageRef {  
      size = Small;  
   }  
   field Text {  
      size = Large;  
   }  
   field InstallationText {  
      size = Large;  
   }  
   field SystemDefined {  
      size = Small;  
      truelabel = "Yes";  
      falselabel = "No";  
   }  

   commandgroup CommandGroup {  
      label = "Command Group";  
      command CmdCopyInstTextTable;  
   }  
}  

@Override  
selector AttributeKeyRefSelector for BasicDataTranslationLov {  
   static AttributeKey;  
   static Text;  
}  

Using references to replace Get methods and Prefetch

There are many projections where fetch attributes are created using the API Get methods.

The usage of Get methods has performance related concerns, such as that the context switch between PL/SQL and SQL occurs when using get methods, which is a costly operation.

Therefore it is necessary to implement the Odata feature called “\$expand”, to enable the use of references instead of fetch attributes (which use the get methods).

In addition to the replacement of the get methods, the same feature is proposed to be used instead of the prefetch attributes, which are created in the projection model.

When fetch or prefetch is used, these attributes are created in the main entity which is unnecessary in many cases. With the "\$expand"-implementation, no more attributes are created in the main entity, instead the reference is used with a special syntax in the client model to get the values from the referenced entity.

Syntax

New syntax that needs to be used in the client is as follows:


<ReferenceName>.<AttributeName>  

Example:


field CustomerRef.Name;  

Get methods vs References ($expand)

New syntax can be used instead of fetch attributes that uses API Get methods in the following manner. It is required to create a reference before using the new syntax in the client model.

Old syntax:


@Override  
entity MovieActor {  
   attribute FirstName Text {  
      fetch = "Actor_API.Get_First_Name(Actor_Id)";   
   }  
   attribute LastName Text {  
      fetch = "Actor_API.Get_Last_Name(Actor_Id)";  
   }  
}  

list MovieCast for MovieActor {  
   field FirstName;  
   field LastName;  
   field CharacterName;  
}  

New syntax:


@Override  
entity MovieActor {  
  reference ActorRef(ActorId) to Actor(ActorId);  
}  
list MovieCast for MovieActor {  
   field ActorRef.FirstName;  
   field ActorRef.LastName;  
   field CharacterName;  
}  

There can be places where it is not possible to clearly define a reference like the example above. In those places, it is acceptable to use the fetch attributes. But it is a requirement to create references in all the possible places instead of using the Get methods.

Prefetch vs References (\$expand)

When prefetchis used, new attributes are created in the main entity. But with the new implementation it is possible to get values using the reference without adding new attributes to the main entity.


@Override  
entity MovieActor {  
 reference ActorRef(ActorId) to Actor(ActorId) {  
      prefetch FirstName as ActorFirstName;  
      prefetch LastName as ActorLastName;  
  }  
}  
list MovieCast for MovieActor {  
   field ActorFirstName;  
   field ActorLastName;  
   field CharacterName;  
}  

The new client syntax can be used instead of the one above in the following way:


@Override  
entity MovieActor {  
  reference ActorRef(ActorId) to Actor(ActorId);  
}  

list MovieCast for MovieActor {  
   field ActorRef.FirstName;  
   field ActorRef.LastName;  
   field CharacterName;  
}  

How does this work?

When the above syntax is used in the client model, the Odata \$expand feature is used to expand the referenced entity and return the values together with the main entityset as inline data in a single response.

Example

If the reference name is CustomerRef, which is created using the CustOrdCustomer entity and referenced from the CustomerOrder entity, then the URL can be defined as:


CustomerOrder?$expand=CustomerRef  

The server response contains a structure with inline data as described below:


CustomerOrder  
 - OrderNo  
 - Objstate  
 ...  
 - WantedDeliveryDate  
 - CustomerRef (CustOrdCustomer)  
 - Name  
 - CurrencyCode  
 - NoteId  

Where can I use the new syntax?

The new syntax can be used in the places where the regular attributes are used.

  • fields and attributes used in components (Eg - Key of Person Widget)
  • LOV description
  • Commands
  • Expressions/Conditions
  • Labels
  • Etc

Example


entity CustomerOrder {  
   reference CustomerRef(CustomerNo) to CustOrdCustomer(CustomerNo)  
}  

list OrderList for CustomerOrder {  
   label = "Customer Orders List - ${CustomerRef.Name}";  
   field OrderNo;  
   field Objstate {  
      label = "Status";  
   }  
   lov CustomerRef with CustomerSelector using Customers {  
      label = "Customer";  
      description = CustomerRef.Name;  
   }  
   field CustomerRef.Name {  
      label = "Customer Name";  
   }  
   field CustomerRef.CurrencyCode {  
      visible = [CustomerRef.CurrencyCode != null]  
   }  
}  

maphomekeys

maphomekeys syntax is used to get the correct mapping of these keys between referenced entity/query and home entity


reference AccountRef(Company, AccountNo, TaxCode) to PsCodeAccount(Company, Value, TaxNo) {
    maphomekeys {
      Value to Account;
      TaxNo to TariffNo;   
   }
} 

contextenabled

In a reference, when entity/query that the reference goes to has an attribute name of a context parameter ie Company, WageClass, Ledger, Site, then context filtering is applied when opening the lov in search/filter panel, regardless of the page or list is using a context or not, either page context or the global context. For example

reference EmpNoRef(Company, EmpNo) to CompanyEmp(Company, EmployeeId);

This was a hidden feature introduced for search and filter and there are many places using this hidden feature.

By defualt framework will enable contextual filtering regardless of page or list is using contextual settings or not.

'contextenabled' allow developers to decide whether to use context settings or not in search/filter in LOV when page does not use contextual settings. If contextual filtering needs to be disabled for LOVs in search/filter when context settings are not used by the page or list following marble syntax needs to be used.


reference OrgCodeRef(Company, OrgCode) to CompanyOrg(Company, OrgCode) {
   contextenabled = [false];
}

Use

Uses only a named set of attributes, instead of the full inherited set.


use attributes Description, DueDate;  

Note that the keys are always included.

Where

The WHERE part of the SQL SELECT statement that fetches data for this entity.


entity Flight {  
   from = "flight_registry";  
   where = "plane_in_service > 0 AND plane_location IS NOT NULL";  
   ...  
}  

Functions can use the parameters in where-clauses, as described in the following example:


function Compatriots <>ListEntity(PersonInfo) {  
   parameter   MyCountry Enumeration(IsoCountry);  
   where = "country = :MyCountry";  
}