Author: Rudramani Pandey

  • Difference between Static Method and Instance Method

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Introduction

    Before discussing the differences between an Instance method and Static method, let’ have a quick introduction.

    A method is a block of codes that defines behaviour of an object of the class.  The method can access all the attributes of the class and can change the object data content.

    Instance Method

    Instance methods are defined using the METHODS statement. They get reinitialized every time an instance is created.  They can access all the attributes of the class and can trigger all its events. Instance methods have the flexibility to be inherited and can be redefined in subclasses.

    Syntax to call an instance method: 

    DATA instance_name TYPE REF TO class_name.
    
    CREATE OBJECT instance_name.
    
    CALL METHOD instance_name->instance_method(…).

     

    Static Method

    Static methods are defined using the CLASS-METHODS statement. They are called only once, when the program is started, irrespective to the class instance, and don’t get reinitialized throughout the execution of the program. They can access only static attributes and can trigger only static events of the class. They can be directly accessed by the class name itself.

    Syntax to call a static method:

    CALL METHOD class_name => static_method(..).

    Now, let’s have a look at their difference.

    Difference between Static Method and Instance Method

    Instance Method Static Method
    It requires instance. It doesn’t require instance.
    It is an example of pass by value. It is an example of pass by reference.
    It is defined using “METHODS”. It is defined using “CLASS-METHODS”.
    Involves declaration of reference variable, instantiating the class and then calling the class. Can be directly accesses by the class name.
    It can access all attributes of a class. It can access only static attribute of a class.
    Can be redefined in sub classes. Cannot be redefined in sub classes.

    Instance method over Static method

    It sounds simpler to use Static methods as it does not involve long steps such as the declaration of a reference variable, instantiating the object and then calling the method. Static methods can be directly accessed by the class name.

    But the question arises is that why instance methods are preferred over Static methods.

    One of the important concepts of OOABAP is Polymorphism i.e. replacing the default implementation of the method with a specific implementation. Polymorphism is achieved by Method Redefinition. Since Static methods are operable on their own and are independent of the instances of the class, they cannot be overridden. Whereas Instance methods can be inherited to sub classes, they can be redefined with the specific implementation.

  • Difference between SELECT-OPTIONS and PARAMETERS

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Before discussing the differences between SELECT-OPTIONS and PARAMETERS, let’s have a quick introduction of the two.

    Introduction

    SELECT-OPTIONS and PARAMETERS are components of the selection screen. SELECT-OPTIONS are assigned a selection table in the ABAP program as well as two input fields along with a push button for multiple selection.  Parameters are assigned a global elementary data object in the ABAP program as well as an input field. The name of the SELECT-OPTIONS and PARAMETERS is limited to a maximum of 8 characters whereas the length of the input field is restricted to a maximum of 255 characters.

    SELECT-OPTIONS and PARAMETERS statements are allowed in the global declaration part of executable programs, function groups, and module pools. In function groups and module pools, these statements are only allowed within the definition of a standalone selection screen. In executable programs, these statements are automatically assigned to the standard selection screen.

    Now, let’s have a look at their difference.

    Difference between SELECT-OPTIONS and PARAMETERS in SAP ABAP

    SELECT-OPTIONS PARAMETERS
    It stores value in an Internal table with a predefined structure. It stores value in a variable.
    It can accept multiple single values, multiple ranges, exclusion of values and ranges. It accepts only a single value.
    It creates a Selection table having 4 columns SIGN, OPTION, LOW and HIGH. It does not create a selection table
    If left blank, then all the data is selected from the database. If left blank, then no data is selected from the database.
    For value checking, IN operator is used in WHERE condition. For value checking, operators like =, >, <, <> are used in WHERE condition.
    Value check cannot be forced through Foreign key or domain values. Value check can be forced through Foreign key or domain values.
    Radio buttons or checkbox cannot be created using it. Radio buttons and checkbox can be created using it.

     

  • Difference Between Abstract Class and Interface

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Before jumping to the Difference between Abstract Class and Interface, let us have a short introduction of the two.

    Introduction

    Classes, their instances/objects, and access to objects using reference variables forms the basics of ABAP Objects.  A class represents a set of properties or methods that are common to all the objects of one type. However, it is necessary for similar classes to have similar functions that behave differently in each class and having a uniform point of contact.

    ABAP objects make it possible by using Interface and abstract class.

    Like Classes, interface acts as a data type for the objects. The components of interface are the same as of classes. Interface is used when similar classes have same method with the same name but different functionalities. Interface along with inheritance provides a base for polymorphism because methods of the interface can behave differently in different classes.

    Abstract class is a class that contains one or more abstract methods i.e. methods without implementation. This class cannot be instantiated, as the abstract methods have to be implemented in a subclass of the inheritance tree. It can inherit only one class and multiple interfaces. You can explore more about Abstract class in SAP ABAP here.

    Now, let us have a look at their difference.

    Difference between Abstract Class and Interface

    Interface Abstract Class
    It is not a class. It is an independent structure that is used in a class to extend the functionality of a class. It is a special class which can’t be instantiated.
    It is an entity that doesn’t have an implementation. It can contain methods with implementation as well as without implementation.
    No common behaviour is implemented via Interface. For non-abstract methods, common behaviour can be implemented.
    It can inherit multiple interfaces but cannot inherit a class. It can inherit a class and multiple interfaces.
    Multiple inheritance can be achieved. There is only one abstract class as Super Class.
    For new methods, all the implementing classes must implement the new methods. For new non-abstract methods, there is no need to redefine the method.
    All components are PUBLIC by default. The visibility of each component can be set.

     

  • Quorum on SAP Cloud Platform

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

    Introduction

    Smart contracts brought a new vision to improve for existing enterprise systems. These enterprises have multiple ledgers/data base with replicated data that is based upon duplicated business logics. The only problem with the smart contracts that was stopping their use in banking sectors were their data privacy. In July 2015, J.P. Morgan Chase & Co., an American multinational investment bank introduced an enterprise-ready distributed ledger and smart contract platform known as Quorum which processes private transactions within a permissioned group of known participants. In this article we will do implement Quorum on SAP Cloud Platform.

    In another article, we have discussed “Hyperledger Fabric on SAP Cloud Platform”. This article is similar to it. Here we will explore Quorum and discuss how SAP has integrated it in to its SAP Cloud Platform. Before we start with Quorum platform, it is recommended to read What is Blockchain?

     

    What is Quorum

    Quorum is a blockchain platform built upon Ethereum. It is a private/permissioned blockchain network. To achieve data privacy, Quorum utilizes cryptography and segmentation.

    As per Quorum whitepaper, A Quorum transaction contains the following:

    • The recipient: the one sending the money
    • Signature identifying the sender: to authenticate the sender
    • An amount of ether (although having an ether balance is not required within Quorum): This is the amount that gets transferred
    • An optional list of parties that the transaction should be private to: If the transaction is among multiple parties
    • An optional data field (containing hash in the case of private transaction): This makes the transaction private and secure

    Consensus in Quorum

    According to oxford dictionary, the meaning of consensus is “A general agreement”. A consensus in a Blockchain is a mechanism of validating a transaction based on general agreement i.e. an agreement of more than 51% voters in Quorum.

    In Quorum, consensus has been termed as Quorum Chain Consensus. Quorum Chain Consensus utilizes voting-based consensus mechanism.

    For example, Gargi sends $100 worth of Ether to Rudra, Gargi will lose 100$ worth of Ether from her wallet, and Rudra will gain 100$ worth of Ether in his wallet. It needs to be validated or verified that if Gargi had 100$ worth Ether in her wallet or not. This can be validated by the voters in the Quorum Blockchain and if more that 51% voters agreed upon this transaction, then only the transaction will be validated.

    Implementation of Quorum using SAP Cloud Platform

    Generic Architecture

    Architecture of Quorum on SAP Cloud Platform

    In the above diagram, it has been shown “how SAP Cloud Platform communicates with a Quorum Node”. To explore more about Quorum Architecture please refer here.

    Setup of Quorum on Cloud Platform

    To implement Quorum on SAP Cloud Platform, we need to setup our trial Global Account on SAP Cloud Platform and create a Quorum enabled sub-account. Then only we can proceed with the implementation.

    Follow the following steps to enable Quorum on your SAP Cloud Platform:

    Step 01: Go to your SAP cloud platform Cockpit and if you don’t have trial account, go here and click Free Trial and then select region as Europe (Rot) – US East(VA).

    Step 02: Create a sub account there by giving your desired display name and subdomain name.

    Step 03: Click Entitlements button from the left menu bar and it will display the list of entitlements.

    Step 04: Inside Entitlements menu we can see Edit button. Click it to change the mode to editable. Scroll down to Quorum as shown below:

    Add dev and channel nodes by clicking addition button icon ‘+’.

    Quorum Setup 01

    Step 05: Click your sub account to open it, as shown below. Click Spaces and create a new space to that space. Also give all the authorization as shown below:

    Quorum Setup

    Step 06: Click on the newly space created. Select Service Marketplace and scroll down to Quorum. Click to open it as shown below:

    Quorum Setup 03

    Once the initial setup of Quorum is achieved. Then you can create your own nodes and instances by following Hands on Exercise to create your own SAP Quorum service.

  • Hyperledger Fabric on SAP Cloud Platform

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

    Introduction

    Bitcoin was the first cryptocurrency launched in late 2008. Bitcoin is based on blockchain. Since then many techno players have launched multiple platforms based on Blockchain. In 2015, several companies interested in blockchain technology realized that they could achieve more by working together than by working separately. This marked the birth of Hyperledger Platform. SAP later introduced Hyperledger Fabric on SAP Cloud Platform.

    In this article, we will explore Hyperledger Fabric and how SAP has integrated the same in to its SAP Cloud Platform. Before we kick start with Hyperledger, it is recommended to read What is Blockchain?

     

    Types of Blockchain

    Blockchain classification is based upon restrictions on block or simply data accessibility. Following are the three types of Blockchain networks in the market:

    • Public Blockchains

    A public blockchain is a blockchain network which has absolutely no access restrictions and anyone on internet can become a user or validator/miner. These blockchains are widely used by crypto currencies. These blockchains utilizes a consensus mechanism to keep their transactions valid. Well known examples include Bitcoin and Ethereum.

    • Private Blockchains

    A Private Blockchain is just like a relatioal database i.e. fully centralized and owned by a single organization. All the participants are vetted before entering into this blockchain network. These types of blockchains are mainly used by banking organization, where data cannot be shared with and validated by anyone. Multichain is a tool to create private blockchains.

    • Consortium Blockchains

    The literal meaning of consortium is “an association of several companies”. As the name suggests, it is a blockchain that is jointly controlled by a group of organizations. It is best suited for business and ERP solutions. As of now, Hyperledger and R3Cev are leading blockchain networks in consortium area.

    What is Hyperledger

    In late 2008, Bitcoin was introduced in the market. Since then many companies started different platforms. However, in 2015, several companies decided to come together and create an open source Consortium blockchain platform under the guardianship of Linux Foundation and named it Hyperledger. Hyperledger, since then, has evolved a lot. It has launched multiple frameworks and tools for the same. Among them, Hyperledger Fabric is the most suited and stable framework for Enterprise.

    According to the Hyperledger whitepaper, “Hyperledger fabric is a platform for building distributed ledger solutions with a modular architecture that delivers a high degree of confidentiality, flexibility, resiliency, and scalability. This enables solutions developed with Fabric to be adapted for any industry”.

    To explore how Hyperledger Fabric works, watch this video.

    Consensus in Hyperledger

    According to oxford dictionary, the meaning of consensus is “A general agreement”. A consensus in a Blockchain is a mechanism of validating a transaction based on general agreement i.e. agreement of more than 51% miners in Bitcoin.
    For example, Gargi sends $100 worth of Bitcoin to Rudra, Gargi will lose 100$ worth of Bitcoin from her wallet, and Rudra will gain 100$ worth of Bitcoin in his wallet. But it needs to be validated and verified that if Gargi had 100$ worth Bitcoin in her wallet or not. This is validated by the miners in the Blockchain and if more that 51% miners agreed upon this transaction, then only the transaction will be validated.

    In Hyperledger fabric, consensus is the process by which block of transactions and their ordering are validated by the miners.

    According to Hyperledger Whitepaper, consensus must provide the following core functionality:

    • Confirms the correctness of all transactions in a proposed block, according to endorsement and consensus policies
    • Agrees on order and correctness and hence on results of execution which actually implies agreement on global state
    • Interfaces and depends on smart-contract layer. This layer verifies the correctness of an ordered set of transactions in a block

    Within Hyperledger, there are different types of consensus algorithms. These algorithms are used by different Hyperledger frameworks like Kafka, RBFT, Sumeragi and PoET. Hyperledger Fabric utilizes Kafka algorithm.

    Consensus in Hyperledger Fabric

    Consensus in Hyperledger Fabric consists of following three stages:

    1. Endorsement: To Endorse means “to approve”. In Hyperledger Fabric, predefined policies are defined under which it is stated that who will endorse whom. These policies of Endorsement are strictly followed and implemented during transaction validation.
    2. Ordering: This phase validates the order in which transaction are committed to the blockchain.
    3. Validation: At this phase, both endorsement and ordering are validated with double-spending.

    Implementation of Hyperledger Fabric using SAP Cloud Platform

    Generic Architecture

    Architecture of Hyperledger Fabric on SAP Cloud Platform

    Above a generic architecture is shown which defines how SAP Cloud Platform communicates with a Fabric Node. To explore more about Hyperledger Fabric Architecture refer here.

    Setup of Hyperledger Fabric on Cloud Platform

    To implement Hyperledger Fabric on SAP Cloud Platform we need to setup our Global Account on SAP Cloud Platform and create a Hyperledger Fabric enabled sub-account.

    Follow the following steps to enable Hyperledger Fabric on your Cloud Platform:

    Step 01: Go to your trial SAP cloud platform Cockpit [If you don’t have, go here and click Free Trial] and select region as Europe (Rot) – US East(VA).

    Step 02: Create a sub account there by giving your desired Display name and Subdomain name.

    Step 03: Click Entitlements button. You can find it in the left menu bar.

    Step 04: Inside Entitlements menu, you will see Edit button. Click it to change the mode to editable. Scroll down to Hyperledger Fabric as shown below:

    Hyperledger Setup 01

    Add dev and channel nodes by clicking ‘+’ button.

     

    Step 05: Click your sub account that you have just created to open it. Click Spaces and create a new space. Give all authorization to that space as shown below:

    Hyperledger Setup 02

    Step 06: Click on the newly space created and select Service Marketplace. Scroll down to Hyperledger Fabric and click to open it as shown below:

    Hyperledger Setup 03

    Once the initial setup of Hyperledger Fabric is done then you can proceed with creation of your own nodes and instances. Follow this Hands on Exercise and create your own SAP Hyperledger Fabric service.

  • MultiChain on SAP Cloud Platform

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

    Introduction

    Everybody is well aware with bitcoin. Bitcoin is the first cryptocurrency based on blockchain. Apart from cryptocurrency, this blockchain can be used as a platform for other data based sectors. Keeping this in mind, a private blockchain network was introduced by Multichain for Enterprises and finance sectors. In this article, we will explore basics of Multichain and how SAP has integrated it in to its SAP Cloud Platform. Before we start with Multichain, we recommend you to read What is Blockchain?

     

    What is Multichain

    According to the official Multichain whitepaper, Multichain is a platform which uses integrated management of user permissions to create private blockchains. Even, Multichain is derived from bitcoin. Multichain supports Windows, Linux and Mac servers. Multichain based blockchain network was developed to overcome shortcomings of Bitcoin such as generic mining, privacy and openness.

    Pros and Cons of Private Blockchains

    Multichain has both pros and cons. Private blockchains, such as Multichain, are the one that are controlled by single or multiple organizations that determines who can read it, submit transactions to it, and participate in the consensus or mining process. Thus, it brings both advantages and disadvantages with itself.

    One major disadvantage is that it does not support smart contracts [Although upcoming versions might have Smart contracts too]. According to official SAP website, “Since they are 100% centralized, private blockchains are useful as sandbox environments, but not for actual production.”

     

    Mining in Multichain

    Unlike Bitcoin, from which it is derived, Multichain does not depend only upon the concept of Proof of Work that can be owned by a single institute in some situation. It utilizes a round-robin schedule, in which the permitted/authorized miners have to create blocks in rotation to generate a valid blockchain. This scheme is implemented in Multichain using a parameter called Mining diversity.

    A mining diversity is a concept in which its values are defined value between 0(No restriction) and 1(Every permitted miner must be included into rotation). In actual scenario, mining diversity is kept 0.75 which means if some miners are inactive, still the mining and rotation is possible. Now, based upon mining diversity value fixed by the blockchain administrator or moderator, following are the steps for validations that are required to add a block in the blockchain:

    1. All the changes that a transaction defines should be applied successfully and in order (It means an incomplete and unordered transaction cannot be added into a block)
    2. Count the miners that are permitted to mine (suppose 10)
    3. Multiply the miner count to mining diversity (suppose 10 * .75 = 7.5), round it up to get spacing (here 8)
    4. If the miner of this block has already mined the previous spacing (spacing – 1, here 7) then the block is invalid

    Miners in Multichain neither charge transaction fees nor block rewards. Hence, transaction is free between two parties. However, a miner or an administrator can charge a fixed service fee from the blockchain network participants. SAP too applies this type of fees methodology and charges a fixed amount for a Block per hour.

    Configuration of Blockchain in Multichain

    In a configuration file, Multichain allows a user to set all the blockchain’s parameter that are mentioned below:

    • Type of chain protocol (Private Blockchain for Enterprises or Bitcoin like Public Blockchain)
    • Target time for each block (time taken to add block, e.g. 1 min)
    • Active permission types (e.g. Anyone can connect, only some can send/receive)
    • Mining diversity (as discussed above, it will be a value and it is mainly 0.75)
    • Level of consensus (authorization) required for creating/removing administrators, moderators and minors
    • Mining reward or fees (as discussed above, it can be zero too)
    • IP ports for peer-to-peer connection and the JSON-RPC API (will discuss later)
    • Permitted transaction type (e.g. pay-to-address, etc.)
    • Maximum block size (e.g. 1 MB)
    • Maximum metadata per transaction i.e. size of file that can be sent to the blockchain as transaction (termed as OP_RETURN; e.g. 4096 bytes)

    As discussed in the earlier blog, these configurations are maintained in the first node or Genesis block. To add a new node, Multichain requires to be run from another computer using a node address (e.g. chain1@12.34.56.78:8571) with three parameters:

    1. The destination blockchain name (here chain1)
    2. Its IP port number (here 12.34.56.78)
    3. The IP address of an existing node (here 8571)

    Implementation of MultiChain using SAP Cloud Platform

    Generic Architecture

    MultiChain on SAP Cloud Platform Architecture

    This is a generic architecture where it is shown how a MultiChain network is setup and how SAP Cloud Platform communicates with a MultiChain Node. If you want to explore more regarding Multichain Architecture, then refer here. We will be publishing individual courses of Multichain soon.

    Setup of MultiChain on Cloud Platform

    To Create a MultiChain on SAP Cloud Platform, initially we need to setup our Global Account on SAP Cloud Platform and create a MultiChain enabled sub-account. Then only we can proceed with development.

    Following the following steps to enable MultiChain on your Cloud Platform:

    Step 01: Go to your trial cloud platform and select region as Europe (Frankfurt) – Canary.

    Step 02: Create a sub account under your cloud platform space [Give your desired Display name and Subdomain name].

    Step 03: Click Entitlements button from the left menu bar as shown in image below.

    Step 04: Inside Entitlements menu, you will see Edit button, click it to change the mode to editable and scroll down to Multichain as shown in the image below:

    Multichain Setup 01

    Step 05: Click your sub account (the one you created above) to open it. Click Spaces and create a new space giving all authorization to that space as shown in the image below:

    Multichain Setup 02

    Step 06: Click on the space that you have just created above and select Service Marketplace. Scroll down to MultiChain and click to open it as shown in the image below:

    Multichain Setup

     

    Once the initial setup of MultiChain is done, you can create your own nodes and instances. Follow Hands on Exercise  created by a SAP developer to create your own SAP MultiChain service.

  • What is A Block in A Blockchain

    Preface – This post is part of the Blockchain Basics series.

    Introduction

    A block in a Blockchain is the smallest unit which contains list of records known as transaction data, a timestamp (i.e. a  UNIX time) and cryptographic hash (mainly SHA-256) of previous block (hash converts the previous block data into a fixed length of random data).

    The first block of a blockchain is known as Genesis block. This process of saving block is as shown below:

    blocks of blockchain

    Genesis Block

    The literal meaning of Genesis is origin. Hence, it is the origin block of any Blockchain. Since there is no previous block, hence the value is always hard coded. Since no previous block existed before it, hence the previous hash remains ‘0’ or null in this situation. All the transactions are maintained in the later blocks and the next block will store the Hash value of Genesis block in the “previous hash” section as shown in figure above.

    genesis block

    How a block is created in Blockchain

    The Genesis block, as discussed above, is created by default. All the records for given period are stored in the first block. Then Hash value of current block is created. This hash value is stored in a new block. In this these two blocks are connected. This new block saves hash of previous block, new records and hash of its own records.

    Important Topics associated with a block

    Hashing

    Hashing is a cryptographic process in which an algorithm converts a variable length string to a string of fixed length. Bitcoin uses SHA-256 algorithm to achieve the same.

    Transaction Data

    All the transaction records of a blockchain are stored as Transaction Data in a block.

    Merkle tree

    A Merkle tree represents data (in this case hash key of our transaction data) in a form of leaf and child node. Blockchains utilizes Merkle tree to store transactional data.

    Timestamp

    A timestamp in a blockchain is a converted value of GMT. Blockchain stores data with Unix Timestamp.

    Nonce

    According to oxford dictionary, the literal meaning of a nonce is “unique for particular occasion”. A nonce is a cryptographic term mainly discussed in terms of Bitcoin. It decides the difficulty level of blockchain’s block mining.

    Consensus Mechanisms

    A consensus in a Blockchain is a mechanism used by miners to validate a transaction based on general agreement (agreement of more than 51% miners in Bitcoin).

  • Differences between Web Dynpro ABAP and Web Dynpro Java

    Preface – This post is part of the SAP ABAP Web Dynpro series.

    Introduction

    Web Dynpro is a framework that is used to design web-based UI applications. We can utilize Web Dynpro in both JAVA and ABAP programming languages. Both of them are utilized in such a way that it incorporates the graphical environment comprising special UI elements which help in building an attractive UI and then resulting in minimization of coding effort.

    Web Dynpro ABAP

    As explained in last article, Web Dynpro ABAP incorporates the complete ABAP workbench in designing web based UI application. One must be having skill set in ABAP programming, ABAP Objects, Database concepts and Development tools to develop the application. ABAP based applications can be created in one system and can be transported to the destination server with the help of transport request like any other usual ABAP objects.

    Web Dynpro Java

    Web Dynpro JAVA attracted a bit less commercial success in comparison to web Dynpro for ABAP although it was introduced one year before that is in 2004. So as per SAP, this has been placed in the state of maintenance that means it will be supported till the time, any bugs will get fixed. Web Dynpro JAVA programs cab be executed by JAVA server which accesses remote system in order to obtain business functionality, while model objects are required in order to incorporate the communication functionality.

    Difference between web Dynpro ABAP and Web Dynpro Java

    1. WEB DYNPRO JAVA was introduced first by SAP that is in 2004 while WEB DYNPRO ABAP was introduced in 2005 due to very less popularity of WEB DYNPRO JAVA it is in the state of maintenance as per SAP rules.
    2. It is easier to transport WEB DYNPRO ABAP programs from one server to the destination server using transport request while WEB DYNPRO JAVA programs need to be transported by SAP Net Weaver Development Infrastructure (NWDI). It means if one wants to move the changes from one server to another they will have to additionally install NWDI.
    3. As WEB DYNPRO ABAP is incorporated into the ABAP workbench, database access is simple, just like in report programs and function module. One can access the database directly using the select statement. While in WEB DYNPRO JAVA, BAPIs (Business Application Programming Interfaces) are needed in order to eat up the business logic.
    4. WEB DYNPRO ABAP applications can be customized on both application level and component level. This configuration is done at design time which offers much flexibility and developers can change the look of the UI, quite easy to meet the business requirements. This is not the case for customization of WEB DYNPRO JAVA applications because for that custom development component (DC) needs to be created in Net Weaver developer studio.
    5. With all the points listed, we can easily summarize that Web Dynpro for ABAP is a better option with much more flexibilities in comparison to Web Dynpro for JAVA.
  • SAP Fiori Launchpad Tiles Setup

    Introduction

    SAP Fiori Launchpad is one stop to access all the SAP Fiori Applications. To make your Fiori Application visible on SAP Fiori Launchpad, you need to do Tiles setup. You need to create a tile and a catalogue and configure both of them with your application. In upcoming section we will teach you to do so step by step.

    Steps to do SAP Fiori Launchpad Tiles Setup

    1. Go to Given transaction in your backend system to open Fiori Launchpad: /n/ui2/flp – fiori launchpad. To Open Designer Link: /n/ui2/flpd_cust – designer. It will open a link on your browser. [Raise, if you don’t have]
    2. Go to settings and select customizing TR. Tiles settings
    3. Go to Catalogs, Click the button below:
      tiles tr addition
    • Enter Name [App Name]
    • ID [ZC_*].
    1. Click on tiles, Create tile -> Click on Static Tile
      SAP Fiori Launchpad Tiles Setup
    • Enter Title [App Name], Semantic Object [no special/ space character ( . and _ allowed) à Unique Name], Action[manage] and click on Save
    1. Click on Target Mapping à Create Target Mapping
      1. Enter Same Semantic Object, Action and Title
      2. Application Type à SAPUI5 FIORI APP
      3. ID à Component ID [ID in Manifest.json]
    2. Click Group, create group the way catalogue was created
      1. Name à same as catalogue / App Name/ etc [Visible on FLP]
      2. ID à ZG_*
    3. Click on + button, Give your catalogue name, your tiles under that catalogue will be visible.
    4. Click on + button under that tile, to add it in the group.
  • SAP MTA based UI5 Application

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

    Under UI5 App, we will be developing an MVC based app and will be calling the Node.js API, that we have just created. In this way we will be developing SAP MTA based UI5 Application.

    UI5 App Structure

    As it can be seen below, under our App folder Multichain_logon, we have many files and folders. In this section for  SAP MTA based UI5 Application, we will be mainly focusing upon Main.view.xml, Main.controller.js and model.js.

    SAP MTA based UI5 Application 01

    MODEL.JS

    Under this file, we have made a global model which will be used to call the Node.js API, as shown below:

    sap.ui.define([
      "sap/ui/model/json/JSONModel",
      "sap/ui/Device"
    ], function (JSONModel, Device) {
      "use strict";
    
      return {
        createDeviceModel: function () {
          var oModel = new JSONModel(Device);
          oModel.setDefaultBindingMode("OneWay");
          return oModel;
        },
        //UI5 Configuration model
        createAppConfigModel: function () {
          var appData = {
            "protocol": "https://",
            "apiUrl": "9t8mhv7z1qbwm2yjchain-logon-xs-js.cfapps.sap.hana.ondemand.com"
          };
          var oModel = new JSONModel(appData);
          return oModel;
        }
      };
    });
    

     

    To make this model global, we need to set it in the component.js file. Add given code under
    init: function () for the same:

    //set the app Config model
    this.setModel(models.createAppConfigModel(), "AppConfig");
    

    MAIN.VIEW.XML

    This is a sample project for which we have made a logon system. It takes Username, Password and UTC timestamp and saves it in the Multichain with a Multichain Timestamp. The updated data is then shown as a table under the logon controls. The xml view code is mentioned below:

    <mvc:View controllerName="Multichain_logon.Multichain_logon.controller.Main" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m">
      <Shell id="shell">
      <App id="app">
      <pages>
      <Page id="page" title="{i18n>title}">
      <content>
      <HBox>
      <VBox>
      <Text text="Enter your ID"/>
      <Input id="IdUsername" width="50%"/>
      <Text text="Enter your Password"/>
      <Input id="IdPassword" type="Password" width="50%"/>
      <HBox>
      <Button class="sapUiTinyMarginEnd" text="Create Account" enabled="false" press="onCreate"/>
      <Button class="sapUiTinyMarginEnd" text="Logon" press="onLogon"/>
      <Button class="sapUiTinyMarginEnd" text="Delete Logon" enabled="false" press="onDelete"/>
      <Button text="Check History" press="onHistory"/>
      </HBox>
      </VBox>
      <VBox>
      <Text text="Change the API Source Here"/>
      <RadioButtonGroup valueState="Warning">
      <buttons>
      <RadioButton id="RB4-1" text="OData Service Gateway"/>
      <RadioButton id="RB4-2" text="MTA"/>
      <RadioButton id="RB4-3" text="Cloud Foundry"/>
      </buttons>
      </RadioButtonGroup>
      </VBox>
      </HBox>
    
      <!--Table to show Block History-->
      <Table id="idTable" items="{loginData>/results}">
      <headerToolbar>
      <Toolbar>
      <content>
      <Title text="Proof of History" level="H2"/>
      <ToolbarSpacer/>
      </content>
      </Toolbar>
      </headerToolbar>
      <columns>
      <Column width="12em">
      <Text text="User ID"/>
      </Column>
      <Column width="12em">
      <Text text="Password"/>
      </Column>
      <Column width="12em">
      <Text text="Login Timestamp"/>
      </Column>
      <Column width="12em">
      <Text text="Multichain Timestamp"/>
      </Column>
      </columns>
      <items>
      <ColumnListItem>
      <cells>
      <Text text="{loginData>USERNAME}"/>
      <Text text="{loginData>PASSWORD}"/>
      <Text text="{loginData>TIMESTAMP}"/>
      <Text text="{loginData>BLOCKTIME}"/>
      </cells>
      </ColumnListItem>
      </items>
      </Table>
      </content>
      </Page>
      </pages>
      </App>
      </Shell>
    </mvc:View>
    

    MAIN.CONTROLLER.JS

    The view that we have defined earlier will use the given controller.js to implement the Node.js API calls

    sap.ui.define([
      "sap/ui/core/mvc/Controller"
    ], function (Controller) {
      "use strict";
    
      return Controller.extend("Multichain_logon.Multichain_logon.controller.Main", {
        onInit: function () {
          this.onHistory();
    
        },
        onHistory: function () {
          var that = this;
          var oModelAppConfig = that.getOwnerComponent().getModel("AppConfig");
          var sHTTPS = oModelAppConfig.getProperty("/protocol");
          var uri = oModelAppConfig.getProperty("/apiUrl");
          var sUrl = sHTTPS + uri + "/GET_PROOF_HISTORY";
          var settings = {
            "async": true,
            "crossDomain": true,
            "url": sUrl,
            "method": "GET",
            "headers": {
              "cache-control": "no-cache",
              "Access-Control-Allow-Origin": "*",
              "Access-Control-Allow-Headers": "*"
            }
          };
    
    $.ajax(settings).done(function (response) {
    // that.getView().byId("idOutput").setText(response);
    var results = [];
    response = JSON.parse(response);
    response.updates.forEach(function (temp) {
    if (temp.update.USERNAME !== undefined && temp.update.USERNAME !== "") {
    results.push({
    "USERNAME": temp.update.USERNAME,
    "PASSWORD": temp.update.PASSWORD,
    "TIMESTAMP": temp.update.TIMESTAMP,
    "BLOCKTIME": temp.timestamp
    });
    }
    });
    var jsonModel = new sap.ui.model.json.JSONModel({
    results: results
    });
    that.getView().byId("idTable").setModel(jsonModel, "loginData");
    sap.m.MessageBox.success("Login Proof Loaded Successfully!");
    });
    },
    onLogon: function () {
    var that = this;
    var USERNAME = this.getView().byId("IdUsername").getValue();
    var PASSWORD = this.getView().byId("IdPassword").getValue();
    var TIMESTAMP = Date.now();
    var oModelAppConfig = that.getOwnerComponent().getModel("AppConfig");
    var sHTTPS = oModelAppConfig.getProperty("/protocol");
    var uri = oModelAppConfig.getProperty("/apiUrl");
    var sUrl = sHTTPS + uri + "/UPDATE_OBJECT_HISTORY?USERNAME=" + USERNAME + "&PASSWORD=" + PASSWORD + "&TIMESTAMP=" + TIMESTAMP;
    $.ajax({
    "async": true,
    "crossDomain": true,
    "url": sUrl,
    "method": "GET",
    "headers": {
    "cache-control": "no-cache",
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Headers": "*"
    },
    success: function (oResp) {
    sap.m.MessageBox.success("Block Updated Successfully!");
    },
    error: function (oError) {
    sap.m.MessageBox.error("Block Updated Failed!");
    }
    });
    }
    });
    });
    

    UI5 App Output Screen

    As discussed above, the given screen will be the final screen of our UI5 App. As of now, only two buttons are enabled and they are used either to update the block (Logon Button) or to get the proof of history (Check History Button). Also, the sources shown here are only for illustrative purpose and only MTA calls are implemented in the given scenario.

    SAP MTA based UI5 Application 02