
Access your BTP ABAP environment from ABAP Development Tools (ADT onwards) and create Ztable of your choice. Next, populate the table with data by creating a program(class or function module). In this blog, I created table ZUSER_DATA which stores sample user information.
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'User info'
define root view entity ZUSER as select from zuser_data as user
{
key user.bname as userID,
concat(
concat(substring( cast(user.date_from as abap.char(10)), 7, 2 ), '.'),
concat(substring( cast(user.date_from as abap.char(10)), 5, 2 ),
concat('.', substring( cast(user.date_from as abap.char(10)), 1, 4 )))
) as date_from,
concat(
concat(substring( cast(user.date_to as abap.char(10)), 7, 2 ), '.'),
concat(substring( cast(user.date_to as abap.char(10)), 5, 2 ),
concat('.', substring( cast(user.date_to as abap.char(10)), 1, 4 )))
) as date_to,
user.name_first as name_first,
user.name_last as name_last,
/*-- Admin data --*/
@Semantics.user.createdBy: true
created_by,
@Semantics.systemDateTime.createdAt: true
created_at,
@Semantics.user.lastChangedBy: true
last_changed_by,
@Semantics.systemDateTime.lastChangedAt: true
last_changed_at
}
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Projection view for user info'
@UI: {
headerInfo: { typeName: 'User', typeNamePlural: 'Users', title: { type: #STANDARD, value: 'userID' } } }
@Search.searchable: true
define root view entity ZC_USER
provider contract transactional_query
as projection on ZUSER
{
@UI.facet: [ { id: 'User',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'User info',
position: 10 } ]
@UI: {
lineItem: [ { position: 10, importance: #HIGH } ],
identification: [ { position: 10, label: 'User ID'} ],
selectionField: [ { position: 10 } ] }
key userID as userID,
@UI: {
lineItem: [ { position: 20, importance: #HIGH } ],
identification: [ { position: 20, label: 'Valid From' } ],
selectionField: [ { position: 20 } ] }
date_from as date_from,
@UI: {
lineItem: [ { position: 30, importance: #HIGH } ],
identification: [ { position: 30, label: 'Valid to' } ],
selectionField: [ { position: 30 } ] }
@Search.defaultSearchElement: true
date_to as date_to,
@UI: {
lineItem: [ { position: 40, importance: #HIGH } ],
identification: [ { position: 40, label: 'First name' } ],
selectionField: [ { position: 40 } ] }
name_first as name_first,
@UI: {
lineItem: [ { position: 50, importance: #HIGH } ],
identification: [ { position: 50, label: 'Last name' } ],
selectionField: [ { position: 50 } ] }
name_last as name_last,
@UI.hidden: true
last_changed_at as LastChangedAt
}
@EndUserText.label: 'Service definition for ZC_USER'
define service ZSRVDEF_USER {
expose ZC_USER as C_USER;
}
managed implementation in class zbp_user unique;
strict;
define behavior for ZUSER alias USER
persistent table ZUSER_DATA
lock master
authorization master ( instance )
etag master last_changed_at
//late numbering
{
// administrative fields (read only)
field ( numbering : managed, readonly ) userID;
// administrative fields (read only)
field ( readonly ) last_changed_at, last_changed_by, created_at, created_by;
// mandatory fields
field ( mandatory : create ) date_from, date_to, name_first, name_last;
create;
update;
delete;
mapping for ZUSER_DATA
{
userID = bname;
date_from = date_from;
date_to = date_to;
name_first = name_first;
name_last = name_last;
}
}
projection;
strict;
define behavior for ZC_USER alias C_USER
use etag
{
use create;
use update;
use delete;
}
Right click your package and choose New > Other ABAP Repository Object > Communication Management > Communication Scenario. I named mine ZCOMMU_USER. Go to the Inbound tab and add inbound service, which is in the format of "your_service_binding_IWSG".
Finally, publish the scenario locally.
Navigate to "Maintain Communication User" under "Communication Management" tab and create a user with strong password. "Propose password" can be used for this purpose. Save the user.
Navigate back to the dashboard and go to Communication System under the same tab. Give a system ID name for the BTP ABAP Environment. Copy the system URL from ADT, remove "https://" and set it in the host name.
Last step is to add the user created in the previous step as the communication user for this system ID. Finally, we can save this communication system.
Navigate to "Maintain Communication Arrangement" under the same tab and click New. Choose the communication Scenario created in the step 2. Enter the communication system and user created in the previous steps and save. The Service URL at the bottom will be used later in BTP destination.
Create a new project in AppGyver and go to AUTH tab and set as BTP authentication.
Go to DATA tab and Click "ADD INTEGRATION". Click "BTP DESTINATION" and all available services configured in BTP destination are displayed. Choose the one configured in step 3.3 and the screen should change and display Data entities. If it does not, most likely the service is not reachable or AppGyver could not comprehend the service URL as service metadata(if you followed the steps so far, your AppGyver should proceed and display the data entities).
Click "Install integration" button on the top right and "Enable Data Entity" button below it. You can view the data you've set in the source table in step 1.1 by clicking "Browse Data" button.
Good job! Now we can use the OData on AppGyver and it's time to be creative 🙂
Go to the first page of the app(Empty page by default) and switch to variable screen. Add your OData entity as data variable. When you click the + button, it is already on the dropdown list added for you. The fetched data is stored in data variable "your entity name1". In my case, it's "C_USER1".
Switch back to canvas view and drop down the UI component of your choice. For example, with "Line item" component it will look something like this. Make sure to set data variable C_USER1 in Repeat with property. In the primary label, I combined first and last name and valid dates.
Alternatively you could use other components such as "Card" from the marketplace.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 | |
4 |