Author: Rudramani Pandey

  • Operations on Services in SAP CAP

    Preface – This post is part of the SAP CAPM series.

    Introduction

    In previous article we have explored the ways to define services in SAP CAP. In this article we will learn about the operations on Services in SAP CAP.

    Operations on Services in SAP CAP

    1. Ignoring fields from Services: We can ignore fields using annotation @cds.api.ignore
    2. Adding Action and Functions: We can directly call a function/action, like we have used cancelLeave above, by mentioning it in node.js while calling the service. This can be done in two ways:
      1. Unbound action: For this type of actions, we mention the action in the service itself
    srv.on('cancelLeave', (req) => {
    
    // do something ...
    
    })

     

    1. Bound action: For this type of actions, we mention the action at entity level. It means, we will have to mention the name of the entity during the call
    srv.on('getEmployeeCount', 'Employees', (req) => {
    
    // do something ...
    
    })

     

     

  • Defining Services in SAP CAP

    Preface – This post is part of the SAP CAPM series.

    Introduction

    A service or a metadata service is used to define the data and its structure. It includes all the data models with annotation as well as associations and navigations. In this article we will explore more about Defining Services in SAP CAP.

    Defining Services in SAP CAP

    In CAP, we have already defined multiple entities with association. Later we have added annotations too using Aspects. In service definition, we write all the entities within another entity and give it the name of a service. Here we have created a service in file “service.cd”.

    entity EmployeeService {
    
    enity Employee {
    
    key ID : UUID;
    
    name  : String;
    
    Role : Association to Manager;
    
    }
    
    entity Manager {
    
    key ID : UUID;
    
    name   : String;
    
    Role  : Association to many Role on Employee.Manager = $self;
    
    }
    
    }

     

    To separate the entity sets from the service, unlike the example mentioned above, we will call the domain modals in our services. Hence, all the models will be as usual defined within a model cds e.g.  schema.cds and then it would be called from a Service using CQL (CAP Query Language).

    Example:

    using { empInfo as info } from 'db/schema';
    
    
    
    
    entity EmployeeService{
    
    
    
    
    entity Employee as SELECT from info.Employees{ *,
    
    Employees.firstname ||' '|| Employees.lastname as name : String,
    
    manager.name as manager,
    
    } excluding { salary, currency};
    
    entity Manager as projection on empInfo.Manager
    
    where Manager.Department = 'IT'
    
    order by name;
    
    }

     

    It is recommended to use one service per use case. It helps us to maintain proper authentication and checks.

    Example:

    using { empInfo as info } from './db/schema';
    
    /** Serves end users browsing Employee and Insert Employee Details */ 
    
    service EmployeeService{
    
    @readonly  entity Employee as SELECT from info.Employees{ *,
    
    firstName, lastname
    
    };
    
    @requires: 'authenticated-user'@insertonly entity Salary as projection on info.Salary;
    
    
    
    
    }
    
    /** Serves registered users managing their salary and leave */
    
    service UsersService {
    
    @readonly entity Salary as projection on info.Salary
    
    where EmployeeID = $user; // limit to own ones
    
    action cancelLeave ( ID: Salary.ID, reason:String );
    
    }
    
    
    
    
    /** Serves administrators managing everything */
    
    @requires: 'authenticated-user'
    
    service AdminService {  entity Employee   as projection on info.Employees;
    
    entity Salary as projection info.Salary;
    
    }

     

  • Domain Modelling in SAP CAP

    Preface – This post is part of the SAP CAPM series.

    Introduction

    A Domain Model in SAP CAP is a model which describes the static, data-related aspects of a problem domain in terms of entity-relationship models. In this article we will study the Domain Modelling in SAP CAP in detail.

    Domain Modelling

    In simple words, a CDS in SAP CAP produces domain model in such a way that it defines the business problem in terms of keys, fields and annotations. The code to generate a domain model is written in a CDS schema (db/schema.cds). These domain models can be used in Service Definitions, Persistence Models, Databases or even reused within another domain model.

    Sample Example:

    Namespace empInfo;
    
    using {Currency, managed} from '@sap/cds/common';
    
    
    
    
    entity Employees: managed {
    
    key ID: Integer;
    
    firstName: localized String (111);
    
    lastName: localized String (1111);
    
    manager: Association to Managers;
    
    dateofJoining: Integer;
    
    salary: Decimal (9,2);
    
    currency: Currency;
    
    }

     

    In this example we have created a file schema.cds where we have created an entity Employees which includes basic details of an Employee

    This whole schema has been given a namespace i.e. empInfo

    This schema uses a standard data type i.e. Currency. Using the standard data type like this helps us to bring all the predefined value helps related to it.

    We use CDS to create a Model. In that CDS, we use

    1. Entities to represent set of unique objects e.g.:
      1. Employee Basic Information
      2. Employee Communication Information
      3. Employee Salary Information
    2. Associations to define relationships
      1. Manager association to another entity Manager which will have all the Managers list

    Naming Convention & Recommendations

    1. The name of entity should start with a capital letter and it should be human readable and self-explanatory – for example, Employees
    2. Start elements with a lowercase letter – for example, firstName
    3. It is recommended to use plural form of entities – for example, Employees
    4. It is recommended to use singular form of types – for example, Currency
    5. don’t repeat contexts – for example, Employees.name instead of Employees.EmployeeName
    6. prefer one-word names – for example, salary instead of salaryAmount
    7. use ID for technical primary keys – for example, ID for Employee ID
    8. You can use Namespace to make your entities unique. It is like client concept in SAP where you can have duplicate schemas (cds files) with unique Namespace to differentiate them. Namespaces are optional, use namespaces if your models might be reused in other projects. At the end of the day they’re just prefixes, which are automatically applied to all relevant names in a file. – for example,

    namespace laptop;entity Dell {}

    ..… is equivalent to:

    entity laptop.Dell {}

    1. You can use contexts for nested namespace sections. – for example,

    namespace laptop;entity Dell {}           //> laptop.Dellcontext Apple {      entity MacBookPro {}       //> laptop.Apple.MacBookPro     entity MacBookAir {}         }

     

    Entities

    Entities are like tables with primary keys. We can perform CRUD operation using these Entities. Keep it as flat as possible. Do not over Normalize it. Do not use non-reusable types. This section is only for modelling, only annotation related to individual fields should be added and no technical details (logics) should be added.

    Types

    Types are like Domain in SAP ABAP, it used to define the typed of Data elements.

    Aspects

    Aspects are the extensions of the Models and are mainly used to extend the existing definitions and annotations. Once a model is defined, we can use different cds files (Aspect) to add annotations on top of them for specific task.

    For example-

    • cds– your core domain model, kept clean, simple and understandable
    • audit-model.cds– adds additional fields required for auditing in a file
    • auth-model.cds– adds annotations for authorization.

    Primary Keys

    Like tables & CDS in SAP ABAP, we maintain Primary keys for Entity using keyword key.

    A primary key can be reused across the model by using the methodology of common definitions.

    We can create a common.cds Model where all the common definitions can be stored.

    // common definitions

    entity StandardEntity {
    
    key ID : UUID;
    
    }
    
    Now these  common definitions can be reused as below:
    
    using { StandardEntity } from './common';
    
    entity Employee : StandardEntity {
    
    name : String;
    
    ...
    
    }
    
    entity Manager : StandardEntity {
    
    name : String;
    
    ...
    
    }

     

    The common file is already created by default with a predefined entity named cuid.

    Mapping UUIDs to OData

    CDS maps UUIDs to Edm.Guid, by default, in all of the OData models. However, the OData standard puts up restrictive rules for Edm.Guid values – for example, only hyphenated strings are allowed – which may conflict with existing data. Therefore, we allow the default mapping to be overridden as follows:

    entity Books {

    key ID : UUID @odata.Type:’Edm.String’;

    }

    If necessary, you can also add the annotation @odata.MaxLength to override the corresponding property, too.

    Association

    It is used to define relationship between two entities. Like ABAP CDS, here too we use the word Association. Here, the keyword many indicates a 0..* cardinality. The restrictions for cardinality can be added as a constraint (where condition) – for example, using not null.

    Compositions

    Unlike Association where we associate a field of entity with the objects of an entire entity, the compositions just refer to specific field of another entity. It has extra advantage of self-managed deep operations(Insert/Update) and cascaded deletion(Multi Dependent table deletion).

    // Define Orders with contained OrderItemsentity Orders {  key ID   : UUID;  Items    : Composition of many Order_Items on Items.parent=$self;}entity Order_Items { // shall be accessed through Orders only  key parent : Association to Orders;  key book   : Association to Books;  quantity   : Integer;}

    Best Practises

    1. Don’t add technical details in Models, we use Aspectsfor that
    2. Use short names and simple flat models
    3. Don’t over Normalize the entities in Models
    4. Use local integer sequences if you really deal with high loads and volumes. Otherwise, prefer UUIDs

    Till now what we have learned: Creation of Model and Aspects on top of it .

    Domain Modelling in SAP CAP

  • Difference between SAP MTA and SAP CAP

    Preface – This post is part of the SAP Multi-Target Application (MTA) and SAP CAPM series.

    Introduction

    SAP has recently introduced two different package based development modules: SAP MTA and SAP CAP (or CAPM). It is getting tough for developers and architects to choose the best among them. In this article we will try to explain the difference between SAP MTA and SAP CAP.

    SAP MTA

    A Multi-Target Application (SAP MTA) is a package comprised of multiple libraries, application and resource modules. These have been created using different technologies and deployed to different runtimes but have a common life-cycle. You can bundle different modules together, describe them along with their inter-dependencies to other modules, services, and interfaces, and package them in a Multi-Target Application(MTA) .

    SAP CAP

    SAP Cloud Application Programming Model, also known as SAP CAP is a framework of tools, languages and libraries (both open source and SAP tools and technologies) designed efficiently with SAP best practices to help developers to minimize coding efforts, develop reusable peace of codes in form of micro services and to focus on designing and implementing business/enterprise specific logic.

    Difference between SAP MTA and SAP CAP

    Following are the differences between SAP MTA and SAP CAP:

    SAP MTA SAP CAP
    All the UI5/Fiori Apps are deployed now as MTA Even CAP is deployed as MTA
    MTA includes given modules:

    ·         HTML5(UI5/Fiori)

    ·         Node.js

    ·         Java

    ·         SAP Hana DB Module

    ·         SAP Cloud Platform Service

    CAP includes given modules:

    ·         HTML5(UI5/Fiori)

    ·         Node.js

    ·         Java

    ·         SAP Hana DB Module

    ·         SAP Cloud Platform Service

    ·         CDS Modelling

    MTA doesn’t support CDS Modelling CAP supports CDS Modelling
    MTA is good for creating cloud applications with DB already in place either at ABAP or HANA XS CAP is a single bundle to write data modelling, maintain Authorization, interact with various internal, external and DB services
    MTA is a subset of CAP CAP is an extension of MTA
    SAP MTA is older and more stable. SAP CAP is new, only CAP Cookbook is there for reference
    With only MTA, we will miss CAP capabilities With only CAP, we will have MTA as well as other extended capabilities
  • SAP MTA Project Layout & Best Practices

    Preface – This post is part of the SAP Multi-Target Application (MTA)  series.

    Introduction

    A Multi-Target Application (SAP MTA) is a package comprised of multiple libraries, application and resource modules. These have been created using different technologies and deployed to different runtimes but have a common life-cycle. You can bundle different modules together, describe them along with their inter-dependencies to other modules, services, and interfaces, and package them in a Multi-Target Application(MTA) .

    Technologies and Tools Involved in SAP MTA

    Tool/Technology Purpose Description
    Hana Data Base Store Business Data This can be any database
    Java/ Node.js Add Business logic In place of ABAP, business logic will be written here
    UI5/Fiori UI Design Like convention Fiori Application, the UI will be developed in same uniform manner
    SAP Cloud Foundry MTA Deployment The MTA application is deployed in to SAP Cloud Foundry as a mta.yaml file

    Default Project Layouts

    Files/Folders Description
    app/ all your UI apps go in here; one or more of such in subfolders
    srv/ all your service definitions and implementations go in here
    src/ The default location in which you store your design-time database artifacts. If needed, you can create additional subfolders for the same purpose.
    /package.json your project descriptor, for example, listing dependencies
    /mta.yaml All the relevant dependencies of the module are defined in the MTA descriptor
    srv/cat-service.js A root file for all your custom event handlers
    node_modules/ All node modules sit here
    node_modules/server.js the main .js file (A root file for all your node calls under the Node Module folder)
    node_modules/package.json Add your corresponding description and dependencies of Node.js modules
    node_modules/index.js To maintain a catalogue of all the Node script files and share the same with one place for reference
    lib/ Created only if XSJS support is enabled for the module. Contains .xsjs (SAP HANA XS JavaScript) source files.
    test/ Created only if XSJS support is enabled for the module. Contains XSUnit test (.xsjslib) files.
    tests/ This folder is created for modules without XSJS support. It contains .js test files.

    Note: */ denotes a folder and /* signifies a file

     

    Prerequisites and Restrictions

    We need to consider the following limits for the SAP MTA deployment on SAP Cloud Foundry deploy service:

    • Maximum size of the MTA archive: 4 GB
    • Maximum size of MTA module content: 4 GB
    • Maximum size of MTA resource content: 1 GB
    • Maximum size of MTA descriptors (mtad.yaml and MANIFEST.MF): 1 MB

    Best Practises related to SAP MTA:

    • The MTA descriptor is built in the YAML format and has strict syntax requirements. You can edit the descriptor in the text-based code editor, but it is recommend to use the visual MTA editor because it provides input validation.
    • Use the HTML5 Application Repository in a Multitarget Application as it enables to update the HTML5 applications without restarting the application router in the Cloud Foundry environment.
  • What is SAP Cloud Application Programming Model

    Preface – This post is part of the SAP CAPM series.

    Introduction

    We have been writing codes in different languages (such as ABAP, CDS, UI5/FIori and OData) at different platform (SAP NetWeaver, SAP Editor, HANA Studio, and SAP Web IDE) to achieve CRUD operation on business data. These all have their own limitation such as source independent development, platform independent development, etc. To remove dependency on multiple platforms and to combine SAP and open-source tools at a single platform, SAP came with Cloud Application Programming Model. In this article we will explore it in detail.

    SAP Cloud Application Programming Model

    SAP Cloud Application Programming Model, also known as SAP CAP is a frameworks of tools, languages and libraries (both open source and SAP tools and technologies) designed efficiently with SAP best practices to help developers to minimize coding efforts, develop reusable peace of codes in form of micro services and to focus on designing and implementing business/enterprise specific logic.

    Architecture of SAP Cloud Application Programming Model

    In this section we will talk about two different architectures. The first one will be the high level architecture provided by SAP. The other one will emphasize more on the flow of development.

    SAP Cloud Application Programming Model

    According to the architecture attached above, we can conclude that in this programming model we will be using:

    1. Web IDE and other development tools such as Visual Studio Code.
    2. To model our data we will be using the annotation power of HANA CDS.
    3. To write business logic we will be using Service SDKs such as Node.js or Java
    4. To deploy our node module, java module, UI5 Module we will have Cloud Foundry as Paas.
    5. To save our business data we will be using HANA or other database
    6. To develop our user Interface we will be using SAP Fiori and other UI tools
    7. The whole tool and framework will be utilizing on SAP Cloud Platform Infrastructure

    Now to understand the architecture in a better way, we can redesign it as below:

    SAP CAP Architecture

    In the architecture shown above we have illustrated the flow of development in terms of CAP development.

     

    Technologies and Tools Involved in SAP Cloud Application Programming Model

    Tool/Technology Purpose Description
    Hana Data Base Store Business Data This can be any database
    Core Data Services Model Data Service It mainly uses HANA CDS Artifacts
    Java/ Node.js Add Business logic In place of ABAP, business logic will be written here
    UI5/Fiori UI Design Like convention Fiori Application, the UI will be developed in same uniform manner
    SAP Cloud Foundry CAP Deployment The CAP application is deployed in to SAP Cloud Foundry as a MTA application

     

    Why and When to choose SAP Cloud Application Programming Model

    Everyone after looking the CAP framework wonders about its implementation in real life business use case. This framework is best suited for the development of applications for the enterprise having Cloud Infrastructure. Since this Application framework can consume both Hana Database as well on premise based OData exposed database, thus it is suitable for all types of enterprises.

    Even implementation of SAP Cloud Platform Integration is best supported by SAP CAP framework.

  • Function Imports in SAP OData

    Preface – This post is part of the ABAP Programs series.

    DATA: ls_parameter TYPE /iwbep/s_mgw_name_value_pair,
          lv_custid    TYPE kunnr,
          lv_flag      TYPE char1,
          lt_custinfo  TYPE TABLE OF ztest_gw_srv,
          ls_custinfo  TYPE ztest_gw_srv,
          ls_entity    TYPE zcl_ztest_gw_srv_mpc=>ts_msg_return.
    
    
        IF iv_action_name = 'demoFuncImport'. " Check what action is being requested
          IF it_parameter IS NOT INITIAL.
    
    * Read Function import parameter value
            READ TABLE it_parameter INTO ls_parameter WITH KEY name = 'CustId'.
            IF sy-subrc = 0.
              lv_custid = ls_parameter-value.
            ENDIF.
    
            READ TABLE it_parameter INTO ls_parameter WITH KEY name = 'Approved_Flag'.
            IF sy-subrc = 0.
              lv_flag = ls_parameter-value.
            ENDIF.
    
            IF  lv_custid IS NOT INITIAL.
              UPDATE ztest_gw_srv SET approved = lv_flag WHERE cust_id = lv_custid.
              IF sy-subrc = 0.
                ls_entity-type   = 'S'.
                ls_entity-message = 'Customer info successfully approved'.
              ELSE.
                ls_entity-type   = 'E'.
                ls_entity-message = 'Error'.
              ENDIF.
    
    
    * Call method copy_data_to_ref and export entity set data
              copy_data_to_ref( EXPORTING is_data = ls_entity
                      CHANGING cr_data = er_data ).
    
            ENDIF.
          ENDIF.
        ENDIF.

     

  • Convert JSON to ABAP Internal Table

    Preface – This post is part of the ABAP Programs series.

     TYPES:
            BEGIN OF t_entry,
              access_token TYPE string,
              token_type   TYPE string,
              expires_in   TYPE n LENGTH 8,
              scope        TYPE string,
              jti          TYPE string,
            END OF t_entry .
          TYPES:
            t_entry_map TYPE SORTED TABLE OF t_entry WITH UNIQUE KEY access_token.
          DATA: m_entries TYPE t_entry.
    
          DATA: lr_instance  TYPE REF TO  /ui5/cl_json_parser.
          CREATE OBJECT lr_instance.
          CALL METHOD me->get_token.
          IF gv_token IS NOT INITIAL.
    
    *        data: itab TYPE TABLE OF string.
    *        data: access_tok type string.
    *        SPLIT gv_token at '"' INTO TABLE itab.
    *        try.
    *            lv_auth2 = itab[ 4 ].
    *          catch cx_sy_itab_line_not_found.
    *        ENDTRY.
    
            /ui2/cl_json=>deserialize(
            EXPORTING json = gv_token pretty_name = /ui2/cl_json=>pretty_mode-camel_case CHANGING data = m_entries ).
            lv_auth2 = m_entries-access_token.
            gv_token = gv_token+17.

     

  • Create Object History in SAP Blockchain

    Preface – This post is part of the Blockchain on SAP Cloud Platform and ABAP Programs series.

    In this article, we will learn how to create a block in Blockchain on the SAP Cloud Platform.

     METHOD create_object_history.
        DATA: lo_http_client TYPE REF TO if_http_client.
        DATA: response TYPE string,
              lv_url   TYPE string,
              lv_auth  TYPE string.
        CONSTANTS : lv_initial_url TYPE string VALUE '<Your_Service>'.
    
        IF iv_object_id IS NOT INITIAL.
    *** Getting Token
          TYPES:
            BEGIN OF t_entry,
              access_token TYPE string,
              token_type   TYPE string,
              expires_in   TYPE n LENGTH 8,
              scope        TYPE string,
              jti          TYPE string,
            END OF t_entry .
          TYPES:
            t_entry_map TYPE SORTED TABLE OF t_entry WITH UNIQUE KEY access_token.
          DATA: m_entries TYPE t_entry.
    
          DATA: lr_instance  TYPE REF TO  /ui5/cl_json_parser.
          CREATE OBJECT lr_instance.
          CALL METHOD me->get_token.
          IF gv_token IS NOT INITIAL.
    
            /ui2/cl_json=>deserialize(
            EXPORTING json = gv_token pretty_name = /ui2/cl_json=>pretty_mode-camel_case CHANGING data = m_entries ).
            DATA lv_auth2 TYPE string.
            lv_auth2 = m_entries-access_token.
    *        gv_token = gv_token+17.
    
            CONCATENATE 'Bearer' lv_auth2 INTO lv_auth SEPARATED BY space.
    
          ENDIF.
          DATA lv_object_id TYPE string.
          lv_object_id = iv_object_id.
          TRANSLATE lv_object_id TO LOWER CASE.
    
          CONCATENATE lv_initial_url lv_object_id INTO lv_url. "Appending Fix URL and the Object ID to get the Request URL
    
          "create HTTP client by url
          CALL METHOD cl_http_client=>create_by_url
            EXPORTING
              url                = lv_url
            IMPORTING
              client             = lo_http_client
            EXCEPTIONS
              argument_not_found = 1
              plugin_not_active  = 2
              internal_error     = 3
              OTHERS             = 4.
    
          "Available API Endpoints
          "https://blockchain-service.cfapps.sap.hana.ondemand.com/blockchain/proofOfHistory/api/v1
          "https://blockchain-service.cfapps.eu10.hana.ondemand.com/blockchain/proofOfHistory/api/v1
          "https://blockchain-service.cfapps.us10.hana.ondemand.com/blockchain/proofOfHistory/api/v1
    
          IF sy-subrc <> 0.
            "error handling
          ENDIF.
    
          "setting request method
          lo_http_client->request->set_method('POST').
    
          "adding headers
          lo_http_client->request->set_header_field( name = 'Content-Type' value = 'application/x-www-form-urlencoded' ).
          lo_http_client->request->set_header_field( name = 'Accept' value = 'application/json' ).
          lo_http_client->request->set_header_field( name = 'Authorization' value = lv_auth ).
    
          "Available Security Schemes for productive API Endpoints
          "OAuth 2.0
    
          CALL METHOD lo_http_client->send
            EXCEPTIONS
              http_communication_failure = 1
              http_invalid_state         = 2
              http_processing_failed     = 3
              http_invalid_timeout       = 4
              OTHERS                     = 5.
    
          IF sy-subrc = 0.
            CALL METHOD lo_http_client->receive
              EXCEPTIONS
                http_communication_failure = 1
                http_invalid_state         = 2
                http_processing_failed     = 3
                OTHERS                     = 5.
          ENDIF.
    
          IF sy-subrc <> 0.
            "error handling
            response = lo_http_client->response->get_cdata( ).
            ev_response = response.
          ELSE.
            response = lo_http_client->response->get_cdata( ).
            IF response IS NOT INITIAL.
              ev_response = response.
            ELSE.
              ev_response = 'Block created successfully'.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDMETHOD.
    

     

  • Get Proof history from the Blockchain Service using SAP ABAP

    Preface – This post is part of the Blockchain on SAP Cloud Platform and ABAP Programs series.

    In this step, we will call the blockchain service again using the token that we have stored in above step. And then we will receive the history of transactions from blockchain.

    METHOD get_proof_history.
        DATA: lo_http_client TYPE REF TO if_http_client.
        DATA: response TYPE string,
              lv_url   TYPE string,
              lv_auth  TYPE string,
              lv_auth2 TYPE string.
        CONSTANTS : lv_initial_url TYPE string VALUE '<Your Service>'.
        IF iv_object_id IS NOT INITIAL.
    *** Getting Token
          TYPES:
            BEGIN OF t_entry,
              access_token TYPE string,
              token_type   TYPE string,
              expires_in   TYPE n LENGTH 8,
              scope        TYPE string,
              jti          TYPE string,
            END OF t_entry .
          TYPES:
            t_entry_map TYPE SORTED TABLE OF t_entry WITH UNIQUE KEY access_token.
          DATA: m_entries TYPE t_entry.
          DATA: lr_instance  TYPE REF TO  /ui5/cl_json_parser.
          CREATE OBJECT lr_instance.
          CALL METHOD me->get_token.
          IF gv_token IS NOT INITIAL.
    *        data: itab TYPE TABLE OF string.
    *        data: access_tok type string.
    *        SPLIT gv_token at '"' INTO TABLE itab.
    *        try.
    *            lv_auth2 = itab[ 4 ].
    *          catch cx_sy_itab_line_not_found.
    *        ENDTRY.
            /ui2/cl_json=>deserialize(
            EXPORTING json = gv_token pretty_name = /ui2/cl_json=>pretty_mode-camel_case CHANGING data = m_entries ).
            lv_auth2 = m_entries-access_token.
            gv_token = gv_token+17.
            CONCATENATE 'Bearer' lv_auth2 INTO lv_auth SEPARATED BY space.
          ENDIF.
          DATA lv_object_id TYPE string.
          lv_object_id = iv_object_id.
          TRANSLATE lv_object_id TO LOWER CASE.
          CONCATENATE lv_initial_url lv_object_id INTO lv_url. "Appending Fix URL and the Object ID to get the Request URL
          "create HTTP client by url
          CALL METHOD cl_http_client=>create_by_url
            EXPORTING
              url                = lv_url
            IMPORTING
              client             = lo_http_client
            EXCEPTIONS
              argument_not_found = 1
              plugin_not_active  = 2
              internal_error     = 3
              OTHERS             = 4.
          "Available API Endpoints
          "https://blockchain-service.cfapps.sap.hana.ondemand.com/blockchain/proofOfHistory/api/v1
          "https://blockchain-service.cfapps.eu10.hana.ondemand.com/blockchain/proofOfHistory/api/v1
          "https://blockchain-service.cfapps.us10.hana.ondemand.com/blockchain/proofOfHistory/api/v1
          IF sy-subrc <> 0.
            "error handling
          ENDIF.
          "setting request method
          lo_http_client->request->set_method('GET').
          "creatung Auth value
    *       lv_auth2 = 'Basic <Your Login Credentials>'.
          "adding headers
    *      lo_http_client->request->set_header_field( name = 'Content-Type' value = 'application/x-www-form-urlencoded' ).
          lo_http_client->request->set_header_field( name = 'Accept' value = 'application/json' ).
          lo_http_client->request->set_header_field( name = 'Authorization' value = lv_auth ).
    *      lo_http_client->request->set_header_field( name = 'APIKey' value = 'zBoCpDtkaT9jexRjtMk0J98Rs8izmQi1' ).
          "Available Security Schemes for productive API Endpoints
          "OAuth 2.0
          CALL METHOD lo_http_client->send
            EXCEPTIONS
              http_communication_failure = 1
              http_invalid_state         = 2
              http_processing_failed     = 3
              http_invalid_timeout       = 4
              OTHERS                     = 5.
          IF sy-subrc = 0.
            CALL METHOD lo_http_client->receive
              EXCEPTIONS
                http_communication_failure = 1
                http_invalid_state         = 2
                http_processing_failed     = 3
                OTHERS                     = 5.
          ENDIF.
          IF sy-subrc = 1.
            "error handling
            ev_response = 'http_communication_failure'.
          ELSEIF sy-subrc = 2.
            ev_response = 'http_invalid_state'.
          ELSEIF sy-subrc = 3.
            ev_response = 'http_processing_failed'.
          ELSEIF sy-subrc = 0.
            response = lo_http_client->response->get_cdata( ).
    *WRITE: 'response: ', response.
            ev_response = response.
          ELSE.
            ev_response = 'Unknown Error'.
          ENDIF.
        ENDIF.
      ENDMETHOD.