Skip to Content

Part 3 : Explore the Annotation Model

 

 


Advertisement:
—  — No ABAP development skills required — —

Over-View

Part 1: Preparation
    * 360°-View
    * Pre-View
    * Quick-View on Prerequisites
    * Service-Oriented View
Part 2: Create the Annotation Model
    * Background
    * Create Project
    * Reference the Gateway Service
    * Reference the vocabulary
    * Create the Annotation Model
    * Runtime Artifacts

Part 3: Explore the Annotation Model (this blog)
* ABAP-View
* Model-View
* XML-View
* Post-View

Part 4: Connect the Cloud
    * Intro
    * Prerequisites
    * SAP HANA Cloud Connector
          ** Download
          ** Install
          ** Start
          ** Configure 1
          ** Configure 2
          ** Verify
    * Appendix
          ** Access HCP trial
          ** Tip: Avoid SSO
Part 5:  OData provisioning
    * Find it
    * Configure it
          ** Assign Roles
          ** Create Destination
    * Register Service
    * Summary
Part 6: The Fiori Application
    * Intro
    * Create destination pointing to OData provisioning in HCP
    * Generate application
    * Run the application
    * Summary
Part 7: Trouble-Tips


 

This is the third part of our tutorial. After having created the annotation model, we’ll be now going a little bit deeper in this blog.

ABAP-View

To see the mystic ABAP, expand the node “Runtime Artifacts” in your project, open the context menu on the  <xxx>APC entry and … no, no, don’t choose “Display” (this switches the project to read-only mode). The correct entry is

“Go to ABAP Workbench”

The form-based view on the ABAP class is displayed.

Do a double-click on the method “DEFINE_VOCAB_ANNOTATIONS” to finally see the code:

In the screenshot above, I’ve pointed out some interesting parts to remember.

Now it is up to you: in future, you candecide to define your annotation models completely via code instead of clicking in Service Builder…

To leave the good old ABAP Workbench (really old, but good), click the “Back” button on the very top most toolbar.

Two clicks and you’re back in Service Builder.

Model-View

From the main menu, choose System -> Create Session to open a new window.

In the transaction field, type /n/IWBEP/REG_VOCAN and press “Enter”

This opens the “Maintain Annotation Models” tool.

Now you have to find your annotation model. For this you need the “Technical name” … remember, you’ve seen it above, after pressing the “Generate”-ball …ehm… sorry, I mean the “Generate”-button.

After you’ve found it, you might think you have to select the entire row… but no, no, this time you have to click on the Technical model name.

(Our adventure continues…)

Only then, the section underneath will display the services that are assigned to our annotation model.

No surprise here: it is the GWSAMPLE_BASIC service:

That’s all. Just view the assignment and close the window via x or via main menu:  System -> End Session.

In the next (last) step, we’ll briefly use the Service Builder one last time.

XML-View

After all that work, we want to get a result: the XML document representing the annotation model

So, what we’re going to do in this step is to view the annotations in their xml-dress.

Our annotation model is not a service, so we cannot invoke it. But there’s the CATALOGSERVICE, which is offered in the SAP Gateway (hub), and it contains a collection of annotation models, as the service document shows:

So let’s verify.

Go to the SAP Gateway Client (the window should still be open, otherwise open it with transaction /n/IWFND/GW_CLIENT) and open the following URL

/sap/opu/odata/IWFND/catalogservice;v=2/Annotations

The result:

disappointing…

We most probably don’t find our own annotation model in the list of all existing annotation models.

Reason is that it is not yet fully loaded.

In order to force a reload, there are a couple of possibilities, see below.

One way to achieve a reload: just invoke the Gateway service to which our annotation model is attached: the GWSAMPLE_BASIC

In the SAP Gateway Client, open the following URI

/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/$metadata

Don’t expect to see our annotations there.

Since we’re working with the so-called standalone annotations, the OData service itself does not know that it is annotated, so there’s no annotation section in the metadata.

(Only if the Gateway service itself defines annotations (i.e. not standalone), only then the annotation section is shown in the metadata document of the service.)

Then try again, open the Annotations collection of the CATALOGSERVICE:

/sap/opu/odata/IWFND/catalogservice;v=2/Annotations

If it still doesn’t help, try cleaning the metadata cache, to force the system to reload the metadata.

The SAP Gateway Client tool offers a main menu entry for that:

Metadata -> Cleanup Cache -> On both Systems

Another alternative (for the adventurous reader):

In the SAP Gateway Client, you can click on the button “Service Administration” which opens the “Activate and Maintain Services” tool in a new window, with the GWSAMPLE_BASIC entry pre-selected.

There you can press the “Load Metadata” button.

Note:

The “Activate and Maintain Services” tool can also be reached via transaction /IWFND/MAINT_SERVICE

And it can also be reached from Service Builder: double-click “Service Maintenance” node in the tree, then there’s the “Maintain” button on the right side.

Now open the Annotations collection again. Our new annotation model should now be listed.

Now that our annotation model can be accessed via the CATALOGSERVICE, we can explore the information that we get there.

Perform a READ of the entry:

/sap/opu/odata/IWFND/catalogservice;v=2/Annotations(TechnicalName=’ZGWSAMPLE_ANNOTATIONS_ANNO_MDL’,Version=’0001′)

Follow the /Services link, it should display the GWSAMPLE_BASIC service, to which our annotation model is attached.

/sap/opu/odata/IWFND/catalogservice;v=2/Annotations(TechnicalName=’ZGWSAMPLE_ANNOTATIONS_ANNO_MDL’,Version=’0001′)/Services

Now we can follow the /$value  link.

/sap/opu/odata/IWFND/catalogservice;v=2/Annotations(TechnicalName=’ZGWSAMPLE_ANNOTATIONS_ANNO_MDL’,Version=’0001′)/$value

It displays the actual, the real raw value of the annotation model, presented in xml format:

This is what we wanted to achieve.

Post-View

Finally, we’re done with the annotation part of our tutorial.

With the help of Service Builder, we’ve created an annotation model that declares how the referenced OData service is to be displayed in an application.

All this work was not just for fun: in the last step of this E2E tutorial, this xml will serve as descriptor for a UI5 application.

The good thing: that application is fully generated out of this xml, nothing else needs to be done

… that’s no fantasy… you’ll see!

The promised browser-based application will run in the cloud and we’ll use a browser-based IDE that runs in the cloud to create it.

So the next step we have to do is to make our annotation model available in the cloud.

But first we have to connect the cloud to the backend onPremise system.

Be sure not to miss it!

The fun part will then be in the last part.


Advertisement

— — Stay tuned and you’ll connect the cloud — —


 

 

 

 

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Thomas Nelissen

    Hi Carlos,

    Great Blog! I have worked with annotations before but never with the annotations builder in SEGW.

    I am facing the following issue when trying to complete your tutorial:

    When I generate my model in SEGW I only get the following as the generated code in method DEFINE_VOCAB_ANNOTATIONS

    When I open the generated XML file, only the references to the annotation libraries are visible

    A possible cause could be that I get the following warnings when I import the vocubalary references into my project. I already implemented note 2323443, which solved the problem that attribute “Value” was not available for com.sap.vocabularies.UI.v1.DataField

    Do you have any idea or suggestion on how to solve this issue?

    Thanks a lot,
    Thomas

    (0) 

Leave a Reply