Building an ABAP RESTful Application

Objectives

After completing this lesson, you will be able to:
  • Understand the components of a ABAP RESTful Application
  • Create the sustainable groceries application

Understanding RESTful Application Programming Components

The ABAP RESTful Application Programming Model defines the architecture for end-to-end development of OData services (such as SAP Fiori apps) in the ABAP environment. It supports the development of all types of Fiori applications and the publishing of Web APIs. It is based on technologies and frameworks such as Core Data Services (CDS) for defining semantically rich data models and a service model infrastructure for creating OData services with bindings to an OData protocol and ABAP-based application services for custom logic and SAPUI5-based user interfaces.

In this unit, you will create a Sustainable Grocery Application using an ABAP RESTful Application. The required objects for an ABAP RESTful Application include:

  • Database Tables
  • Core Data Service (CDS) Entities
  • Core Data Service (CDS) Behavior Definitions
  • Core Data Service (CDS) Metadata Extensions
  • A Service Definition
  • A Service Binding
Basic architecture of an ABAP RESTful application

Developing a RAP application consists of the following main steps:

Provide the Database Tables
Developing a RESTful Application starts with providing the database tables. Depending on the development scenario, these can be existing tables, legacy tables, or tables created specifically for this application.
Define the Data Model.
The data model of the Business Object is defined with Core Data Service (CDS) Views. Depending on whether it is a simple or a composite Business Object, one or more CDS Views are required. In the case of a composite Business Object, this is also the place where you define the entity hierarchy.
Define and Implement the Behavior (Transactional apps only)
The behavior of a RESTful Application Business Object is defined in a repository object called Core Data Service (CDS) Behavior Definition. Usually, the behavior of a RESTful Application Programming Business Object also requires some additional logic implemented in a certain type of global ABAP class called a Behavior Pool. For a non-transactional application, for example, a list report, the behavior definition or implementation can be omitted.
Project the RESTful Application Programming Business Object and provide service-specific Metadata
The RESTful Application Programming Business Object projection consists of a data model projection and, if a behavior has been defined, a behavior projection. To define a projection, you create one or more Core Data Service (CDS) projection views, which is a type of CDS View, and a Behavior Projection, which is a type of behavior definition. For User Interface (UI) services, the projection view(s) should be enriched with UI-specific metadata. To support the future extensibility of the application, we recommend placing the service-specific annotations in metadata extensions.
Define the Service
In RESTful Applications, a service is defined by creating a Service Definition. The service definition references the projection views and specifies what should be exposed, that is, what is visible to the service consumer.
Bind the Service and Test the Service
A service binding is needed to specify how the service should be consumed (UI or Web API) and via which protocol (OData V2 or OData V4). For UI services, a Preview is available.

Creation of the Sustainable Grocery Application

Graph showing the flow of creating an ABAP RESTful application

To create the RESTful Application Program, the following object needs to be created or generated:

A Database Table
A database table will permanently store the data in the database. We will create a simple database table to store information on your purchased groceries.
Additional Objects
A number of objects required by the RESTful Application Program will be generated through the Generate ABAP Repository Objects... feature of ABAP Development Tools (ADT).
Behavior
The behavior of a RESTful Application Program Business Object is defined in a repository object called a Core Data Service (CDS) Behavior Definition. Usually, the behavior also requires additional logic, which is implemented in a certain type of global ABAP class called a Behavior Pool. For a non-transactional application, for example, a list report, the behavior definition or implementation can be omitted. The behavior we will add is an action to check if the grocery items selected have expired. This will set the expired flag in the database table.
Metadata Extension
The metadata extension file allows customization of the user interface.

Create a Database Table

Database Table for Sustainable Grocery App

A database table is required to store our grocery data. We will create a database table to use in our Sustainable Grocery Application.

Note

In this exercise, XX refers to your number.

Steps

  1. Create a database table named ZXX_GROCERY.

    1. Right-click on your package ZS4D100_XX in the Project Explorer and choose NewOther ABAP Repository Object. Type table in the filter and choose Database Table. Press Next.

    2. Enter ZXX_GROCERY as the name and Groceries as the description. Press Next to continue.

    3. Choose your existing transport request and press Finish.

  2. Adjust the ZXX_GROCERY file by copying the template code and replacing all occurrences of XX with your number.

    1. Replace the generated code in ZXX_GROCERY with the following code:

      Code Snippet
      1234567891011121314151617181920212223242526272829
      @EndUserText.label : 'Groceries' @AbapCatalog.enhancement.category : #NOT_EXTENSIBLE @AbapCatalog.tableCategory : #TRANSPARENT @AbapCatalog.deliveryClass : #A @AbapCatalog.dataMaintenance : #RESTRICTED define table zXX_grocery { key client : abap.clnt not null; key id : sysuuid_x16 not null; product : abap.char(40); category : abap.char(40); brand : abap.char(40); @Semantics.amount.currencyCode : 'zXX_grocery.currency' price : abap.curr(10,2); currency : abap.cuky; quantity : abap.int2; purchasedate : abap.dats; expirationdate : abap.dats; expired : abap_boolean; rating : abap.fltp; note : abap.char(255); createdby : abp_creation_user; createdat : tzntstmpl; lastchangedby : abp_lastchange_user; lastchangedat : abp_lastchange_tstmpl; locallastchanged : abp_locinst_lastchange_tstmpl; }
    2. Copy the code in the exercise by pressing Copy To Clipboard.

    3. In Eclipse select EditSelect All.

    4. Select EditDelete.

    5. Select EditPaste.

    6. Select EditFind/Replace.

    7. Enter XX in the Find field and your number in the Replace with field.

    8. Press Replace All.

    9. Press Close.

    10. Press Activate (Ctrl-F3).

    Practice

Result

You now have a database table to store your grocery information.

Generating Additional Objects

Generating Additional Objects

We have just defined a database table to hold our data, but the app we will create needs more objects than just this table. We can generate these objects using a wizard in ABAP Development Tools (ADT).

Extended architecture of an ABAP RESTful application

The generated objects contain all the information necessary to provide a working app with create, read, update, and delete capabilities. Later on, we will also adjust and extend some of these objects to change the appearance of the user interface and to implement a check for expired groceries.

To start the object generator, right-click the table name in the Project Explorer and choose Generate ABAP Repository Objects. The wizard starts, and you must enter a package to which all of the new objects will be assigned. You then select the generator, for this example, we use the ABAP RESTful Application Programming Model UI Service.

Screenshot of the initial page of the ABAP RESTful application programming model generator window

To start the object generator, right-click the table name in the Project Explorer and choose Generate ABAP Repository Objects.... The wizard starts and you must enter a package to which all of the new objects will be assigned. You then select the generator; for this example, we are using the ABAP RESTful Application Programming Model UI Service.

Screenshot of the Data Model tab in the generator window

In the RESTful Application Programming Model, you do not access database tables directly. Instead, you use a Core Data Service (CDS) view entity to define the data model. At this stage, in the generator, you enter the name of a data definition. Since you are working in the customer namespace, the name must begin with Z or Y.

You also have to enter an alias name used inside the generated application to identify the entity that the data definition represents.

Screenshot of the Behavior tab in the generator window

With the data mode view that you create, you can read data from the database. However, our app should also be able to create, modify, and delete data. In order to make this possible, you must define a behavior definition. This is linked to the data mode view and specifies which of the create, update, and delete actions are allowed.

As well as specifying which of the create, update, and delete actions should be available, the behavior definition can also contain the following kinds of definitions:

  • Draft enabling
  • Automatic numbering
  • Validations: These are checks that are carried out when the user enters data in the app
  • Determinations: A determination performs a calculation to fill fields in the data record.

The generator creates the behavior definition and switches on automatic numbering for the UUID field. If you need to use validations and determinations, you must add them by hand.

The behavior definition declares which validations and determinations exist. However, they also need an ABAP implementation. The implementations are methods, so you therefore need an implementation class. The naming convention for this class is to use the prefix Z or Y for the customer namespace, followed by BP_R. BP stands for behavior pool and R stands for restricted.

The behavior definition also defines the draft enabling for the entity. Based on the definition of the data model view, the generator creates a corresponding table that will contain the draft data. You therefore need to specify the name of the draft table at this point. The naming convention is that for a basic table Z<table>, the draft table should be called Z<table>_D.

Screenshot of the Service Projection tab in the generator window

The data model and its behavior definition are a reusable implementation of a particular business entity. The next step in the object generation is to specify the name of the service projection. The projection contains a view with precisely the fields required for a particular app, a behavior definition specifying which of the defined behaviors should be available in the app, and a metadata extension. The metadata extension contains Core Data Service (CDS) annotations that define how the UI of the app should look.

The naming convention for the projection layer is ZC_<name>. The projection view, behavior projection, and metadata extension will all have the same name.

Screenshot of the Service Binding tab in the generator window

In order to expose the app, you need to create a service definition and a service binding. the service definition specifies the projection view to be exposed in this service, the service binding specifies the protocol to be used. In our example define an OData UI service based on version 4 of the OData protocol.

The naming convention for the service definition is Z<name>. The naming convention for the service binding is ZUI_<name>_O4. This indicates that the binding is for a Fiori Elements app and that it uses version 4 of the OData protocol.

Screenshot of the Preview Generator Output page in the generator window

At the end of the wizard, the system displays a list of all the objects it will generate. You can check your entries against the naming conventions, look out for typing errors, and, if necessary, go back and change any that are incorrect.

Generate Additional Objects

Generate Additional Objects

We need to generate the additional objects needed for the RESTful Application Program Sustainable Grocery App.

Note

In this exercise XX refers to your number.

Steps

  1. Generate the additional objects for the RESTful Application Program Sustainable Grocery App.

    1. In the Project Explorer right-click on your database table ZXX_GROCERY and choose Generate ABAP Repository Objects....

    2. Choose ABAP RESTful Application Programming ModelOData UI Service. Press Next.

    3. Enter your package name (ZS4D100_XX) and Press Next.

    4. Select Business ObjectData Model. Check Data Definition Name is ZR_XX_GROCERY and enter the CDS Alias Name: Grocery.

    5. Select Business ObjectBehavior and check the default generated names for the Implementation Class is ZBP_R_XX_GROCERY and Draft Table Name is ZXX_GROCERY_D.

    6. Select Service Projection and check the default name is ZC_XX_GROCERY.

    7. Select Business ServiceService Definition. Check the default name is ZUI_XX_GROCERY_O4.

    8. Select Business ServiceService Binding. Check the default name is ZUI_XX_GROCERY_O4 and the binding type is OData V4 - UI.

    9. Press Next.

    10. View the Preview Generator Output and press Finish to generate the objects.

    Practice

Modifying Generated Objects

Several objects need to be modified to customize our application

Screenshot of a Projection View with annotations

In the data definition file, ZC_XX_GROCERY annotations can be added to enable the search capabilities of the application. Annotations begin with an @ symbol. Here, we are adding annotations to allow the search capabilities of specific fields in the application. The annotation is placed before the field name.

Screenshot of a Behavior Definition

In the Behavior Definition ZR_XX_GROCERY, the fields CreatedBy and CreatedAt will be read-only. We are also creating an instance action CheckExpirationDate.

Screenshot of the code completion popup suggesting a fix for a code warning

In the Behavior Definition ZR_XX_GROCERY, you can have Eclipse generate the method checkExpirationDate by clicking on the warning in the margin of the action statement. You then double-click on the Add method ... statement to have the method generated in the local classes of the implementation class ZBP_R_XX_GROCERY.

Screenshot of a Behavior Projection

In the behavior definition ZR_XX_GROCERY , the use action checkExpirationDate; is added to enable the action. .

Screenshot of a Behavior Implementation class

In the implementation class ZBP_R_XX_GROCERY under the tab Local Types will be the method for the action checkExpirationDate. Here, code is needed to check the expirationDate of a selected grocery item and set the flag expired to true or false. The required code is contained in the exercise.

Screenshot of a Metadata Extension

The metadata extension allows for the adjustment of the user interface. @UI.lineItem refers to the initial list, while @UI.identification refers to the detail list on a second screen. In this example, the ID is hidden from the application display. The position is left to right from low to high values. Importance: #HIGH indicates the field should be displayed on all device sizes, while importance: #MEDIUM has the field listed on large (desktop) screens and medium (tablet) screens but not on small (smartphone) screens.

Screenshot of an unpublished Service Binding with the “Publish” button

To publish the service, open the service binding ZUI_XX_GROCERY_O4, select the service, and press the Publish button.

Screenshot of a published Service Binding with the enabled “Preview…” button

To test the application, choose Grocery under Entity Set and Association of the service binding ZUI_XX_GROCERY_04. Press Preview... to launch the application.

Screenshot of the preview of the application

Once in the Sustainable Grocery App, you can press Go to populate the grocery list from existing data. You can also use the Search field to search for grocery items. Press Create to add a new grocery item. Press Delete to remove a grocery item. Select items with a check box and press Check for expiration to check the Expiration Date and set the Expired flag.

If you click on a grocery item, you will be taken to a detail page for that item. From the detail page, you can press Edit to change the item values, press Delete to remove the item, and press Check for expiration to set the expired flag.

Enable Search Capabilities

Enable Search Capabilities of Sustainable Grocery App

You need to turn on the search capabilities of the Sustainable Grocery App. The search capabilities are enabled in the Data Definition file ZC_XX_GROCERY.

Note

In this exercise, XX refers to your number.

Objects to adjust:

Object TypeObject NameDescription of Change
Data DefinitionZC_XX_GROCERYEnable search capabilities

Steps

  1. Enable the search capabilities in the Data Definition file ZC_XX_GROCERY for fields Product, Category, Brand, ExpirationDate, Expired , and Rating. Replace the code in the data definition file by copying and pasting the solution code below.

    1. Double-click on the data definition file ZC_XX_GROCERY in the Project Explorer to open the file.

    2. Replace the code in the data definition file by copying the following code:

      Code Snippet
      12345678910111213141516171819202122232425262728293031
      @AccessControl.authorizationCheck: #CHECK @Metadata.allowExtensions: true @Search: { searchable: true } @EndUserText.label: 'Projection View for ZR_XX_GROCERY' define root view entity ZC_XX_GROCERY provider contract transactional_query as projection on ZR_XX_GROCERY { key ID, @Search.defaultSearchElement: true Product, @Search.defaultSearchElement: true Category, @Search.defaultSearchElement: true Brand, Price, Currency, Quantity, PurchaseDate, @Search.defaultSearchElement: true ExpirationDate, @Search.defaultSearchElement: true Expired, @Search.defaultSearchElement: true Rating, Note, CreatedBy, CreatedAt, LastChangedBy, LocalLastChanged }
    3. In the data definition file ZC_XX_GROCERY, press Ctrl-A to select all the contents and then press the Delete key. Press Ctrl-V to paste the contents previously copied.

    4. Press Ctrl-F. Enter XX in the Find field and your number in the Replace with field. Press Replace All. Press Close.

    5. Press Activate (Ctrl+F3).

    Practice

Result

The fields Product, Category, Brand, ExpirationDate, and Rating are now search enabled.

Modify Behavior

Modify Behavior of Sustainable Grocery App

The behavior of the Sustainable Grocery App needs to be modified. Some fields should be read-only and an action needs to be added to check the product's expiration date.

Note

In this exercise, XX refers to your number.

Objects to adjust:

Object TypeObject NameDescription of Change
Behavior DefinitionZR_XX_GROCERYSpecify, any read-only fields, create an action to check item expiration and generate the action method
Behavior DefinitionZC_XX_GROCERYEnable action to check expiration date

Steps

  1. In the behavior definition file ZR_XX_GROCERY create the action checkExpirationDate and make fields CreatedBy, and CreatedAt read-only.

    1. Double-click on the behavior definition file ZR_XX_GROCERY in the Project Explorer to open the file.

    2. Replace the code in the behavior definition file by copying the following code:

      Code Snippet
      1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
      managed implementation in class ZBP_R_XX_GROCERY unique; strict ( 2 ); with draft; define behavior for ZR_XX_GROCERY alias Grocery persistent table zXX_grocery draft table ZXX_GROCERY_D etag master LocalLastChanged lock master total etag LastChangeDat authorization master( global ) { field ( readonly ) ID, field ( numbering : managed ) ID; create; update; delete; draft action Edit; draft action Activate optimized; draft action Discard; draft action Resume; draft determine action Prepare; mapping for ZXX_GROCERY { ID = id; Product = product; Category = category; Brand = brand; Price = price; Currency = currency; Quantity = quantity; PurchaseDate = purchasedate; ExpirationDate = expirationdate; Expired = expired; Rating = rating; Note = note; CreatedBy = createdby; CreatedAt = createdat; LastChangedBy = lastchangedby; LastChangeDat = lastchangedat; LocalLastChanged = locallastchanged; } }
    3. In the behavior definition file ZR_XX_GROCERY, press Ctrl-A to select all the contents and then press the Delete key. Press Ctrl-V to paste the contents previously copied.

    4. Press Ctrl-F. Enter XX in the Find field and your number in the Replace with field. Press Replace All. Press Close.

    5. Press Activate (Ctrl+F3).

  2. Generate the action method checkExpirationDate.

    1. In the behavior definition file ZR_XX_GROCERY, find the line that defines the action checkExpiratonDate. It will have a warning that the implementation is missing. Click on the warning in the margin to see a pop-up that states: Add method for action checkExpirationDate.... Double-click this line to generate the method in the implementation class ZBP_R_XX_GROCERY.

    2. The implementation class ZBP_R_XX_GROCERY will open in the editor. Press Activate (Ctrl-F3).

  3. To enable the action, add a use action checkExpirationDate; statement to behavior definition file ZC_XX_GROCERY.

    1. Double-click on the behavior definition file ZC_XX_GROCERY in the Project Explorer to open the file.

    2. Replace the code in the behavior definition file by copying the following code:

      Code Snippet
      123456789101112131415161718192021
      projection; strict ( 2 ); use draft; define behavior for ZC_XX_GROCERY alias Grocery use etag { use create; use update; use delete; use action Edit; use action Activate; use action Discard; use action Resume; use action Prepare; }
    3. In the behavior definition file ZR_XX_GROCERY, press Ctrl-A to select all the contents and then press the Delete key. Press Ctrl-V to paste the contents previously copied.

    4. Press Ctrl-F. Enter XX in the Find field and your number in the Replace with field. Press Replace All. Press Close.

    5. Press Activate (Ctrl+F3).

    Practice

Result

The fields Createdby, CreatedAt, LastChangeDat, and LocalLastChanged are now read-only. The action checkExpirationDate has been declared.

Check Product Expiration

Implement ABAP Code for Check Product Expiration Date

In the Sustainable Grocery App an action has been defined to check the expiration date of a product. You need to add ABAP code to check the expiration date and if the expiration date is in the past, the flag Expired needs to be set.

Note

In this exercise, XX refers to your number.

Objects to adjust:

Object TypeObject NameDescription of Change
Implementation ClassZBP_R_XX_GROCERYAdd action code to check for selected item expiration

Steps

  1. Implement the local method checkExpirationDate in the implementation class ZBP_R_XX_GROCERY.

    1. Double-click on the class file ZBP_R_XX_GROCERY in the Project Explorer to open the file.

    2. Click on the Local Types tab bottom of the editor window.

    3. Replace the code in the behavior definition file by copying the following code:

      Code Snippet
      12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
      CLASS lhc_grocery DEFINITION INHERITING FROM cl_abap_behavior_handler. PRIVATE SECTION. METHODS: get_global_authorizations FOR GLOBAL AUTHORIZATION IMPORTING REQUEST requested_authorizations FOR Grocery RESULT result, checkExpirationDate FOR MODIFY IMPORTING keys FOR ACTION Grocery~checkExpirationDate RESULT result. ENDCLASS. CLASS lhc_grocery IMPLEMENTATION. METHOD get_global_authorizations. ENDMETHOD. METHOD checkExpirationDate. DATA: lt_groceries TYPE TABLE FOR READ RESULT zr_xx_grocery, ls_grocery TYPE STRUCTURE FOR READ RESULT zr_xx_grocery, lv_expiration TYPE d, lv_current_date TYPE d, lv_expired TYPE abap_boolean, lt_update_groceries TYPE TABLE FOR UPDATE zr_xx_grocery. READ ENTITIES OF zr_xx_grocery IN LOCAL MODE ENTITY Grocery ALL FIELDS WITH CORRESPONDING #( keys ) RESULT lt_groceries. LOOP AT lt_groceries INTO ls_grocery. lv_expiration = ls_grocery-Expirationdate. lv_current_date = cl_abap_context_info=>get_system_date( ). IF lv_expiration < lv_current_date. lv_expired = abap_true. ELSE. lv_expired = abap_false. ENDIF. APPEND VALUE #( id = ls_grocery-Id expired = lv_expired ) TO lt_update_groceries. MODIFY ENTITIES OF zr_xx_grocery IN LOCAL MODE ENTITY Grocery UPDATE FIELDS ( expired ) WITH lt_update_groceries. ENDLOOP. result = VALUE #( FOR groceries IN lt_groceries ( id = groceries-id %param = groceries ) ). ENDMETHOD. ENDCLASS.
    4. In the class file ZBP_XX_GROCERY, press Ctrl-A to select all the contents and then press the Delete key. Press Ctrl-V to paste the contents previously copied.

    5. Press Ctrl-F. Enter XX in the Find field and your number in the Replace with field. Press Replace All. Press Close.

    6. Press Activate (Ctrl+F3).

    Practice

Result

The ABAP code to check the expirationDate and set the expired field has been implemented.

Enhance User Interface

Customize the User Interface of the Sustainable Grocery App

The user interface of the Sustainable Grocery App needs to be customized to specify which data to display and in what way.

Note

In this exercise, XX refers to your number.

Objects to adjust:

Object TypeObject NameDescription of Change
Metadata ExtensionZC_XX_GROCERYSpecify user interface information such as which data to display, how to display the data and enable the action functionality

Steps

  1. Customize the user interface (UI) by adding @UI annotations to the metadata extension file ZC_XX_GROCERY. @UI.lineITem refers to the initial list, while @UI.identification refers to the detail list on a second screen. The annotations are placed before the field name. Here are some sample @UI commands:

    @UI.hidden: true
    Hides the field from display
    @UI.lineItem.position
    Order the fields from left to right with lower numbers to the right and higher numbers to the left
    @UI.lineItem.importance
    Which devices should display item:
    #HIGH - all screen sizes (desktops, tablets, and smartphones)
    #MEDIUM - large (desktops) and medium (tablet) screens
    #LOW - large screens (Desktops)
    @UI.lineItem.label
    Label of field
    1. Double-click on the metadata extension file ZC_XX_GROCERY in the Project Explorer to open the file.

    2. Replace the code in the behavior definition file by copying the following code:

      Code Snippet
      123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
      @Metadata.layer: #CORE @UI: { headerInfo: { typeName: 'Sustainable Grocery App', typeNamePlural: 'Sustainable Groceries App' } } annotate view ZC_XX_GROCERY with { @UI.facet: [ { id: 'idIdentification', type: #IDENTIFICATION_REFERENCE, label: 'Sustainable Groceries App', position: 10 } ] @UI: { lineItem: [ { exclude: true } , { type: #FOR_ACTION, dataAction: 'checkExpirationDate' , label: 'Check for expiration' } ] , identification: [ { position: 1, label: 'ID' } , { type: #FOR_ACTION, dataAction: 'checkExpirationDate', label: 'Check for expiration' } ] } @UI.hidden: true ID; @UI.lineItem: [ { position: 10 , importance: #HIGH, label: 'Product' } ] @UI.identification: [ { position: 10 , label: 'Product' } ] Product; @UI.lineItem: [ { position: 20 , importance: #MEDIUM, label: 'Category' } ] @UI.identification: [ { position: 20 , label: 'Category' } ] Category; @UI.lineItem: [ { position: 30 , importance: #MEDIUM, label: 'Brand' } ] @UI.identification: [ { position: 30 , label: 'Brand' } ] Brand; @UI.lineItem: [ { position: 40 , importance: #MEDIUM, label: 'Price/Currency' } ] @UI.identification: [ { position: 40 , label: 'Price/Currency' } ] Price; @UI.hidden: true Currency; @UI.lineItem: [ { position: 60 , importance: #MEDIUM, label: 'Quantity' } ] @UI.identification: [ { position: 60 , label: 'Quantity' } ] Quantity; @UI.lineItem: [ { position: 70 , importance: #MEDIUM, label: 'Purchase Date' } ] @UI.identification: [ { position: 70 , label: 'Purchase Date' } ] PurchaseDate; @UI.lineItem: [ { position: 80 , importance: #MEDIUM, label: 'Expiration Date' } ] @UI.identification: [ { position: 80 , label: 'Expiration Date' } ] ExpirationDate; @UI.lineItem: [ { position: 90 , importance: #MEDIUM, label: 'Expired' } ] @UI.identification: [ { position: 90, label: 'Expired' } ] Expired; @UI.lineItem: [ { position: 100 , importance: #MEDIUM, label: 'Rating' } ] @UI.identification: [ { position: 100 , label: 'Rating' } ] Rating; @UI.lineItem: [ { position: 110 , importance: #MEDIUM, label: 'Note' } ] @UI.identification: [ { position: 110 , label: 'Note' } ] Note; @UI.hidden: true CreatedBy; @UI.hidden: true CreatedAt; @UI.hidden: true LastChangedBy; @UI.hidden: true LocalLastChanged; }
    3. In the metadata extension file ZC_XX_GROCERY, press Ctrl-A to select all the contents and then press the Delete key. Press Ctrl-V to paste the contents previously copied.

    4. Press Ctrl-F. Enter XX in the Find field and your number in the Replace with field. Press Replace All. Press Close.

    5. Press Activate (Ctrl+F3).

    Practice

Result

Which fields to display and in which order as well as what to display on the detail page has been defined for the Sustainable Grocery App.

Publish the Sustainable Grocery App

Publish the Sustainable Grocery App

It is time to publish the Sustainable Grocery App.

Note

In this exercise, XX refers to your number.

Objects to adjust:

Object TypeObject NameDescription of Change
Service BindingZUI_XX_GROCERY_04Publish service and test application.

Steps

  1. Publish and test the service.

    1. Double-click on the service bindings file ZUI_XX_GROCERY_04 in the Project Explorer to open the file.

    2. Expand the service ZUI_XX_GROCERY_04 in the services table and select the line below with Version entry 1.0.0. Press the Publish button. The publishing will take a few minutes.

    Practice

Result

The Sustainable Grocery App has been published.

Test the Sustainable Grocery App

Test the Sustainable Grocery App

It is time to test the Sustainable Grocery App.

Note

In this exercise, XX refers to your number.

Objects to adjust:

Object TypeObject NameDescription of Change
Service BindingZUI_XX_GROCERY_04Test application.

Steps

  1. Preview the Sustainable Grocery App service.

    1. Double-click on the service bindings file ZUI_XX_GROCERY_04 in the Project Explorer to open the file.

    2. In the Service Version Details section, select Grocery in the Entity Set and Association list.

    3. Press Preview... to launch the application.

  2. Create a new product entry

    1. Choose Create in the application.

    2. Enter product Details:

      ProductOatmeal
      CategoryBreakfast
      BrandOrganics
      Price5.00
      CurrencyUSD
      Quantity1
      Purchase DateChoose 3 weeks ago from today
      Expiration DateChoose 3 days from today
      ExpiredUnchecked
      Rating5
      NoteYummy
    3. Press Create.

    4. Press the Alt+Left arrow to go back to the previous screen.

    5. Press GO to view your new product.

  3. Check expiration processing.

    1. Select the check box to the right of your product.

    2. Press Check for Expiration. Note field Expired with a value of No.

    3. Click on the product line to go to the detail page.

    4. Choose Edit to change the product.

    5. Change the Expiration Date to 1 day ago.

    6. Press Save.

    7. Press Check for expiration. Notice fields Expired now with a value of Yes.

    8. Press the Alt+Left arrow to go back to the first page.

    Practice

Result

The Sustainable Grocery App has now been tested.

Log in to track your progress & complete quizzes