Category: SAP

  • Order to Cash cycle- Inquiry

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

    Introduction

    In this article, we will understand the sales order cycle. Every business will have a cycle. Let’s take an example of the finance business or the finance department. So, the finance department is responsible for looking at what the customer needs to pay and receiving the cash or receiving payments. That’s their business, they call it a report to record.

    Another example can be the procurement department. So, the procurement department is responsible for interacting with the vendors, getting the goods on time, so on. He is responsible for placing the purchase order with a vendor. For example, if Amul procurement department were to be taken as an example, they are responsible for dealing with the vendors that supply the goods. The procurement department will talk to all the different milk vendors. They’ll raise purchase orders, they’ll get the goods into the stock and they’ll pay the invoices, meaning pay the money to their vendors. This cycle is called procure to pay. So similarly, there are different business cycles followed by the different departments.

    Here, we will look into the sales department and different terms used in it. The sales department also follows a cycle, called the sales order cycle.

     

    What is Sales Order Cycle?

    The sales order cycle is a sequence of actions that a business follows to fulfil customer requirements.

     

    What is an RFI or an Inquiry?

    RFI is abbreviated as Request for Inquiry. It is a document requested by the company to gather information about the products and services from suppliers.

     

    What information’s are included in RFI?

    Every business can decide their own format for an RFI that they want to collect from the supplier. There is no particular way to write an RFI.

    Below are some details that can be included in an RFI.

    • Basic information about your company.
    • Request supplier to provide basic information about their organization
    • Confidentiality agreement to prevent the disclosure of information with a third party.
    • Statement for the reason of RFI.
    • Queries related to supplier experience in the relevant projects.

     

    Example

    The sales order cycle is best understood with an example. We will consider a B2B (business-to-business) scenario because SAP is built for more B2B scenarios.

    Let’s take two companies, one company say, a computer manufacturing company, HP or Dell. This is the company which is selling. So, we are looking at things from HP’s perspective. And there will be a buyer company.

    Let’s take the scenario of HP selling computers to the customer, Walmart. Wal-Mart is our customer. So, HP sells computers to Wal-Mart.

    How does the cycle start?

    Wal-Mart is looking for computers. It is inquiring about the different rates of HP, Dell and all the different computer manufacturers. Wal-Mart sends an RFI or Inquiry to HP. So, as soon as HP receive the request from Wal-Mart, they will capture the information in a document based on the customer’s RFI. This document is called an Inquiry.

    And as soon as this inquiry is saved in the system, you get an inquiry number. This inquiry number will be sent over to Walmart as a response to that inquiry.

     

  • Master Data

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

    Introduction

    In this article, we are going to talk about master data. Master Data is everywhere. We see master data all around us. For example, if you go to Safeway, you go buy a bunch of products where you buy some soap and other stuff, and then you go to the billing counter, all your items are scanned and you’ll be asked if you have a reward card. So, this is a card that you’ll be given whereby your discounts will be cumulatively added and if you don’t have one, they’ll give one right away. What does the reward card have? A rewards card has your name, address and some of the personal details about you that they think are relevant for your purchase. This right here is Master Data. You can also call it customer master because you’re a customer in this case and Safeway is the company of the vendor which is selling you these products.

     

    What is Master data?

    Master Data is at its very fundamental level a collection of properties of an object. Objects could be customers, materials, vendors, assets, any of these. Typically, this kind of data is created only once, meaning you don’t create them again and again and again. For example, in the previous case when Best Buy was created as a customer, you don’t get BestBuy again and again and again. It’s created once, but it’s used again and again and again. And because it’s created once, you rarely change it. It’s changed occasionally. It is also the main source of data in transactions. You take any transaction sales order, delivery, billing, purchase, order, transfer order, posting to accounts, any kind of transaction typically has the bulk of the data coming in from the master data.

     

    Properties of Master data

    • Created once and used again and again.
    • Rarely changed.
    • Main Source of data in transactions.

     

    Types of master data

    Master Data in SAP

     

    Examples

    Let’s dig into some examples.

    Example 1

    Let’s say you go buy a piece of bread or buy a bottle of milk and then you go to the counter and these products are scanned. When they are scanned just one little scan can reveal a whole bunch of information about the product.

    What kind of information could that be? Some examples, of that information, could be:

    • Product name. For example, a particular model of bread is bread plain bread, milk break etc.
    • Product description
    • Price for that product and
    • Discounts they are given on that product
    • Cumulative discounts that are given on

     

    Here, Product Name and Product Description are master data. This is called data related to the material. And so it’s called material master data. Whereas, Price, Discounts and Cumulative discounts can be called pricing master data.

     

    Example 2

    Take another example of Amazon. You go to Amazon and you go log in, right? So, you have your username and password as soon as you log in. You can go to your account any time you want. So, when you go to your account you will have details like names, addresses. You can have multiple addresses like one address in Delhi, India one of those in Texas, US, you can store all your different addresses and you can store your credit cards or debit cards details and also different debit cards and credit cards. All of these are master data. And in this case, you are the customer, so you can call it customer master data. All these are common examples of master data that you typically see in a B2C environment all along.

     

    Example 3

    Say, HP is a company that is implementing SAP and a company buying from HP say Best Buy. Now, Best Buy places an order for, let’s say computers or whatever products that HP sells and HP creates an order. The order contains a header and has line items. Let’s say one, two, three, however many.

     

    On the header, what kind of information does it have?

    • Customer information: It has customer information of course and that’s Best Buy in this case,
    • Tax: The next thing is a tax classification
    • Corporate/Government: What kind of a customer is he, a corporate customer or is he a government customer or any other. In this case, he is a corporate customer or retail customer.
    • Ship: Can we ship all the goods together, yes or no? In this case, being a customer it’s an option that Best Buy gives, right?
    • Address: address to which we need to ship the goods.
    • Phone number: If there are issues which phone number to call to.
    • Payer: Who will be paying for this transaction.
    • Billing address: Where should the bill be sent?

    These are all the things that are captured, at the header level.

     

    Now, similarly, at the line-item level, what do we have?

    • Material: We have details like material that say it’s a computer model one on one
    • Weight: Say, 5 lbs
    • Volume
    • Plant: Which plant is it going to send the goods out of? Let’s say it’s sent out to the Bangalore plant.
    • Tax classification: Sometimes some goods, some materials are taxable and some materials are not.

    Looking back to header data, we have data related to customers and line-item data has data related to the material. So basically, master data in this case is a bunch of properties related to a customer or a material.

  • SAP EML (Entity Manipulation Language) in RAP: Guide

    SAP EML (Entity Manipulation Language) in RAP: Guide

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

    Introduction

    SAP Entity Manipulation Language (EML) is an ABAP language that is used to control the behavior of business objects in the context of the RESTful Application Programming model (also called SAP ABAP RAP). The business objects developed with the SAP ABAP RAP model can be consumed not only by OData protocol (Web API, Fiori UI) but also in ABAP using EML statements.

    There are two flavors of EML:

    • Standard API: Uses signature of business object entities
    • Generic API: Used for dynamic consumption of the business object

    The Generic API is used for the dynamic integration of business objects into other frameworks, such as the Cloud Data Migration Cockpit. Generic API is not in our scope. We will focus on Standard API’s.

    The Standard API’s are used when target business object is statically specified. It provides READ and MODIFY statements for the access of transactional scenarios of objects and COMMIT access for triggering save sequence. Using these syntaxes we will be able to perform the transactional behavior ( Create, Update, Delete, Actions, Read ) of business objects that are defined in Behaviour Definition.

    SAP EML Scenarios

    The following table gives you an overview of different SAP EML scenarios:

    Scenario Description Relevant EML statements
    Develop(BO with IN LOCAL MODE within its own behaviour pool) In EML develop scenario, when you provide the functionality for your own BO in its own behaviour pool, you use IN LOCAL MODE. It bypasses the access control, authorization control and feature instance control.  You can use it with CRUD and Actions. ·         READ/READ by ASSOCIATION

    ·         CREATE/CREATE BY ASSOCIATION

    ·         UPDATE/UPDATE BY ASSOCIATION

    ·         DELETE/DELETE BY ASSOCIATION

    ·         EXECUTE

    ·         AUGMENTING BY ASSOCIATION

    Consume (BO from other behaviour pool/ released objects) In consume scenario, you can use EML to consume other BO in or released BO’s. Here, you are not allowed to used IN LOCAL MODE. ·         READ/READ by ASSOCIATION

    ·         CREATE/CREATE BY ASSOCIATION

    ·         UPDATE/UPDATE BY ASSOCIATION

    ·         DELETE/DELETE BY ASSOCIATION

    ·         EXECUTE

    ·         GET PERMISSION

    ·         SET LOCK

    Test To test the BO outside of ABAP behaviour pool, you can use EML statements. Here, it is mandatory to add COMMIT statement to end RAP LUW. When in case of implementation inside behaviour pool, save it is done by the framework and we need not to write explicit COMMIT there. ·         READ/READ by ASSOCIATION

    ·         CREATE/CREATE BY ASSOCIATION

    ·         UPDATE/UPDATE BY ASSOCIATION

    ·         DELETE/DELETE BY ASSOCIATION

    ·         EXECUTE

    ·         GET PERMISSION

    ·         SET LOCK

    ·         COMMIT ENTITIES

    ·         ROLLBACK ENTITIES

     

    SAP EML Syntax

    SAP EML syntax has three major sections:

    • READ
    • MODIFY
    • COMMIT

     

    READ syntax

    READ is used to retrieve the data or you can say read the data of the entity. The syntax supports:

    • Read: Read the entity
    • Read by association: Read child entity using parent key

     

    Short syntax –

    READ ENTITY
    
     EntityName [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance
    
    RESULT et_result
    
    BY \association_name [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_rba
    
    RESULT et_result_rba
    
    LINK et_link_rba
    
    [FAILED ct_failed].
    
    where,
    
    EntityName: specifies the CDS view entity
    
    FIELDS: specifies the direct read for the given fields
    
    RESULT: used to store the retrieved data in variable
    
    LINK: used to store the key pair that is used for read by association operation
    
    Failed: used to store the response about failed retrieve (key-value, fail cause etc)

    Long syntax-

    READ ENTITIES OF RootEntityName
    
    ENTITY entity_1 " entity alias name [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_1
    
    RESULT it_result
    
    BY \association1_name [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_rba
    
    RESULT et_result_rba
    
    LINK et_link_rba
    
    ENTITY entity_2_name " entity alias name [FIELDS ( ......
    
    ENTITY entity_3_name " entity alias name
    
           ... [FAILED ct_failed].

    The long syntax allows you to club READ operation of multiple entities of Business Object specified by RootEntity name at one go. Also, we can use alias names of entities defined in Behavior Definition.

    Example:

    READ ENTITIES OF /dmo/i_travel_m
    
    ENTITY travel
    
    FIELDS ( travel_id
    
      agency_id
    
                          customer_id
    
                          booking_fee
    
                          total_price
    
                          currency_code )
    
    WITH CORRESPONDING #( keys )
    
    RESULT DATA(ct_read_result)
    
    FAILED DATA(ct_failed)
    
    REPORTED DATA(ct_reported).

    MODIFY syntax

    MODIFY statement is used when we want to perform the change of data in entities. It includes:

    • Create
    • Create by association
    • Update
    • Delete
    • Execute (for Action)

    Short syntax-

    MODIFY ENTITY EntityName
    
    CREATE [FIELDS ( field1 field2 ... ) WITH] | [FROM] it instance_crt
    
    CREATE BY \association_name [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_cba
    
    UPDATE [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_upd
    
    DELETE FROM it_instance_del
    
    EXECUTE action_name FROM it_instance_act
    
    [RESULT et_result_a] [FAILED ct_failed] [MAPPED ct_mapped] [REPORTED ct_reported].

    Long syntax-

    MODIFY ENTITIES OF RootEntityName
    
    ENTITY entity1_name CREATE [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance1_crt
    
    CREATE BY \association_name [FIELDS ( field1 field2 ... ) WITH] | [FROM] itinstance1_cba
    
    UPDATE [FIELDS ( field1 field2 ... ) WITH] | [FROM] itinstance1_u
    
    DELETE FROM it_instance1_del
    
    EXECUTE action FROM it_instance1_act
    
    [RESULT et_result]
    
    
    
    
    ENTITY entity2_name
    
    CREATE FROM it_instance2_crt
    
    ...
    
    
    
    
    ENTITY entity3_name
    
    ... [FAILED ct_failed] [MAPPED ct_mapped] [REPORTED ct_reported].

    The long syntax allows clubbing multiple MODIFY operations of entities specified by RootEntity of the business object. We can specify alias names for entities if they are defined in behaviour definition.

    Example

    MODIFY ENTITIES OF /dmo/i_travel_m
    
    ENTITY travel
    
    CREATE FIELDS ( travel_id
    
       agency_id
    
       customer_id
    
       begin_date
    
       end_date
    
       booking_fee
    
       total_price
    
       currency_code
    
       description
    
       overall_status )
    
    WITH lt_create
    
    MAPPED ct_mapped
    
    FAILED ct_failed
    
    REPORTED ct_reported.

     

    COMMIT syntax

    The COMMIT syntax is used along with the MODIFY statement. As MODIFY statement does not change the data at database level, it is required to call COMMIT after MODIFY to persist the database changes.

    The modify statement set the data to transaction buffer and buffer data gets cleared after the ABAP session is closed. That means we need to trigger save sequence to save the data from the transactional buffer to the database. This trigger is called by executing the COMMIT statement. For save sequence methods you can refer to our previous articles.

     

    Simple syntax-

    COMMIT ENTITIES.

     

    Long syntax-

    COMMIT ENTITIES
    
       [RESPONSE OF rootentityname1
    
    [FAILED ct_failed]
    
     [REPORTED ct_reported]]
    
    [RESPONSE OF rootentityname2
    
    [FAILED ct_failed]
    
    [REPORTED ct_reported]].

    Using long syntax we can call COMMIT for multiple entities by explicitly specifying  RootEntity names. Whereas, the simple syntax COMMIT ENTITIES will also work for multiple entities in the same LUW. Here we need to specify the RootEntity name.

  • How to create and deploy UI5 App based upon CAPM using BAS

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

    Introduction

    SAP CAPM is the new and most efficient way to develop SAP Cloud Applications. SAP Business Application Studio is the appropriate IDE that should be used for CAP Application creation. In this article we will explore SAP BAS, CAP Development and CAP Deployment over SAP BTP. Let us explore how to create and deploy UI5 App based upon CAPM using BAS.

    Steps to get started with BAS

    Step 01: The very first step is to visit Business Application Studio using SAP BTP.

    Step 02: Create a Dev Space by clicking the button as shown below:

    Create a Dev Space

    Step 03:  Give a suitable name for your space and choose Full Stack Cloud Application

    Full Stack Cloud Application

    A CAPM space will be created as shown below. Click it.

    CAPM space

    It will open the Business Application Studio Editor (BAS).

    Business Application Studio Editor

    Steps to create a CAPM Project

    1. Click “Start from template” in welcome screen
      Start from template CAP
    2. Select CAP Project and click Start
      CAP Project Start
    3. Provide a name of the project and choose the one shown below:
      CAP Project Configuration
    4. Click Finish. This will generate a project and will open up the same.
    5. In case you get a popover to install recommended extension, click install.

     

    Steps to add Approuter in your CAPM

    The very next thing after CAPM App creation is to add an approuter. You can read more about it here. Follow below steps to create an App Router. You can create both standalone app router as well as SAP Managed App Router (needs additional subscription).

    How to add Standalone Approuter using BAS?

    To add a standalone approuter using BAS, follow the given steps:

    Step 01: Create a MTA or CAPM Application such that your project has a MTA.yaml file (We did this above).

    Step 02: Right click on the MTA file and click “Create MTA Module from Template”

    Open MTA Module from Template

    Step 03: Click “Approuter configuration” from the wizard

    Approuter configuration

    Step 04: Enter the details as shown below:

    App Router Details

    That’s it, an approuter will be added in your project with configuration in MTA file.

    How to add Managed Approuter using BAS?

    The creation of SAP Managed approuter is almost similar to Standalone approuter until step 03.
    In step 04, you need to choose “Managed Approuter” from the drop down, followed by a unique name for the approuter. That’s it, an approuter will be added in your project with configuration in MTA file. Read more about it here.

    Once deployed, you can visit HTML5 Applications under your subaccount. In case you see the given screen:

    Managed Approuter

    In this case you need to subscribe any of the above, then you will be able to see your Applications as shown below:

    HTML5 Applications

    How to add a UI5 project in CAPM

    Once you have a CAPM project with basic module, you will have a folder called app. This folder is meant for UI5 applications. In this use case it is empty. Now we will add MTA modules to create UI5 App.

    Step 01: Create a MTA or CAPM Application such that your project has a MTA.yaml file (We did this above).

    Step 02: Right click on the MTA file and click “Create MTA Module from Template”

    Open MTA Module from Template

    Step 03: Click “SAP Fiori application” from the wizard

    SAP Fiori application

    Step 04: Now, click the filter to choose “SAPUI5 freestyle” (In case you want a Fiori Elements based app, you can keep the first one)

    SAPUI5 freestyle

    Then choose “SAPUI5 Application”:

    SAPUI5 Application

    Step05: Now in next section, either choose your data source if you have or select “None” as below:

    data source for UI5

    Step 06: Now enter the name of the initial view (It can be changed later too):

    View of UI5

    Step 07: This is an important step, choose the folder “app” via project folder path and mark Yes against “Add deployment configuration to MTA project”. This will add all required deployment related configurations in MTA file.
    Deployment configuration of UI5

    Root folder of UI5

    That’s it. Once clicked on Finish will add a UI5 application within app folder.

    Steps to test and deploy whole CAPM project on SAP Cloud foundry (or SAP BTP)

    1. Open Terminal from the menu bar
    2. To test the App locally, write cds watch. You will see a pop up, press “Expose and Open”. You will see a new tab:
      local test of App in CAP
    3. Click on Web Applications link. It will open a blank UI5 App as shown below:
      local run ui5 app in BAS
      This confirms that the UI5 app is working fine.
      If you click the services endpoints link, then you will see an OData as shown below:
      Service in CAP
      This confirms even our services are working fine. This is a green signal for deployment.
    4. Now open a new terminal and write mbt build. This will generate a new folder “mta_archives” with a mtar file
      The above step will also generate new folders
      MTAR generation CAP
    5. Before we deploy to SAP Cloud foundry, we have to login in our environment. In terminal write cf login
      Enter API endpoint: https://api.cf.eu10.hana.ondemand.com/ (or whatever it is for you)
      followed by your login email and password
      You will be logged into your respective environment. In case you have multiple subaccount, then you might be asked to choose one of them (using a number)
    6. Now right click on the mtar file generated and click “Deploy MTA Archive”
      SAP CAP Deployment in BAS

    This will deploy the app in cloud foundry or SAP BTP. In the terminal you will get successful message that all the services were deployed.

    1. To test the deployed UI5 App, go to SAP BTP and reach your respective subaccount -> space. Here list of applications will appear, search for your approuter.
      Run UI5 using App Router
      Open it. You will find a link. You can even find it within the terminal after deployment, e.g.:
    2. Opening only App Router will give error “Not Found”. So, append your approuter as mentioned below:
      Extend the URL with the application ID “/<app ID>”:
      https://ps-scp-<space name>-mta-<app name>-approuter.cfapps.<region>.hana.ondemand.com/<app ID>Note! If the “<app ID>” contains dots e.g. “<app ID>” is “test2.test.1.test0”, dots should be ingnored and the URL should look as:https://ps-scp-<space name>-mta-<app name>-approuter.cfapps.<region>.hana.ondemand.com/test2test1test0

    In our use case the url will be: <app router>/nscap-test/index.html

    1. After login, you will see the below link:
      UI5 deployed App test

    Congratulations, you have successfully created your CAPM UI5 App and deployed the same. You can also check other ways to create a UI5 CAPM App.

  • AppRouter in SAP BTP

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

    Introduction

    In the era of cloud applications, a single project has multiple UI5 applications and multiple microservices. In this use case either we can have individual urls to access these or a single url that can act as an entry point. An approuter helps developers to get a single url to access all their apps and microservices. In this article we will learn more about AppRouter in SAP.

    What is App Router in SAP?

    SAP Cloud Foundry provides a nodeJs library in the form of BTP instance that acts as a single point-of-entry for an application or microservice running in the Cloud Foundry. It is known as Application Router or App Router or AppRouter.

    We can perform following operations using App Router:

    • Serve static data: The index.html file within App Router can be used to display static content or welcome page of an application
    • Authenticate users: A user can be authenticated at approuter level, even before accessing any application
    • Rewrite URLs: It can be used to integrate destination, integrate business services and even perform logout for an application
    • Request to other microservices within same project

    Types of App Router in SAP

    SAP provides two types of approuter, they are:

    1.      Standalone Approuter

    A standalone approuter is a custom approuter that is created and maintained by developer. A developer has to update the xs-app.json and MTA.yaml files according to the project needs.

    2.      SAP Managed Approuter

    A SAP Managed Approuter enables a developer to execute HTML5 applications in SAP Cloud Platform. It is completely managed by SAP, hence you are not required to update any details further, once created.
    To use managed application router, SAP provides three options:

    • SAP Work Zone
    • SAP Launchpad service
    • SAP Cloud Portal

    Once the application is deployed, the apps are available under the tab HTML5Repository within sub-account.

    How to add Standalone Approuter using BAS?

    To add a standalone approuter using BAS, follow the given steps:

    Step 01: Create a MTA or CAPM Application such that your project has a MTA.yaml file.

    Step 02: Right click on the MTA file and click “Open MTA Module from Template”

    Open MTA Module from Template

    Step 03: Click “Approuter configuration” from the wizard

    Approuter configuration

    Step 04: Enter the details as shown below:

    App Router Details

    That’s it, an approuter will be added in your project with configuration in MTA file. Read more about it here.

    How to add Managed Approuter using BAS?

    The creation of SAP Managed approuter is almost similar to Standalone approuter until step 03.
    In step 04, you need to choose “Managed Approuter” from the drop down, followed by a unique name for the approuter. That’s it, an approuter will be added in your project with configuration in MTA file. Read more about it here.

    Once deployed, you can visit HTML5 Applications under your subaccount. In case you see the given screen:

    Managed Approuter

    In this case you need to subscribe any of the above, then you will be able to see your Applications as shown below:

    HTML5 Applications

  • How to create and deploy CAPM using BAS Extensions

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

    Introduction

    SAP CAPM is the new and most efficient way to develop SAP Cloud Applications. SAP Business Application Studio is the appropriate IDE that should be used for CAP Application creation. In this article we will explore SAP BAS, CAP Development and CAP Deployment over SAP BTP. Let us explore how to create and deploy CAPM using BAS Extensions.

    Steps to get started with BAS

    Step 01: The very first step is to visit Business Application Studio using SAP BTP.

    Step 02: Create a Dev Space by clicking the button as shown below:

    Create a Dev Space

    Step 03:  Give a suitable name for your space and choose Full Stack Cloud Application

    Full Stack Cloud Application

    A CAPM space will be created as shown below. Click it.

    CAPM space

    It will open the Business Application Studio Editor (BAS).

    Business Application Studio Editor

    Extensions in BAS

    In this article we will learn how to use Extensions in BAS for application creation.

    1. Click on View -> Find command
      Find Command in BAS
    2. Search “Generators” and click on “Explore and Install Generators”
      Explore and Install Generators in CAP
    3. From the search shortcut, filter SAP UI5 and install “generator-sap-ui5-app”, “generator-easy-ui5” and “generator-ui5_to_mta” and other UI5/Fiori extensions.
      UI5 Generators in CAP

    The above will be helpful in creating UI5 projects and auto generate codes for us.

    Steps to create a CAPM Project

    1. Click “Start from template” in welcome screen
      Start from template CAP
    2. Select CAP Project and click Start
      CAP Project Start
    3. Provide a name of the project and choose the one shown below:
      CAP Project Configuration
    4. Click Finish. This will generate a project and will open up the same.
    5. In case you get a popover to install recommended extension, click install.

    How to add a UI5 project in CAPM using Extension

    The newly created CAP project will have empty app folder as shown below:

    CAP Project Structure

    1. Open View-> Find command (or ctrl+shift+P)
    2. Find “Run Generator”
      Run Generator in BAS
    3. Now find “fiori-module:app”. This will only appear if you install all the extensions that we have mentioned above.
      fiori module in BAS
    4. This will open a wizard. Choose the App folder and click Next
      UI5 wizard in BAS
    5. Enter Module name, it will be the name of your UI5 App, and click Next
      ui5 module in BAS
    6. Choose SAPUI5 Application and click Next
      UI5 template in BAS
    7. Choose the App Router
      App Router Configuration in BAS
    8. Choose Authentication option.
      Authentication for CAPM
    9. Choose View name
      View in UI5
    10. Now, you will see both UI5 and App router is generated
      UI5 app router cap

    Even in MTA you can see these added:
    cap-test-approuter
    cap-test_html_repo_runtime
    cap-test_ui_deployer
    ui5-test

    With all other important files that are mandatory for UI5 module deployment over BTP. Now we are ready to test it locally and deploy it over BTP.

    Steps to test and deploy whole CAPM project on SAP Cloud foundry (or SAP BTP)

    1. Open Terminal from the menu bar
    2. To test the App locally, write cds watch. You will see a pop up, press “Expose and Open”. You will see a new tab:
      local test of App in CAP
    3. Click on Web Applications link. It will open a blank UI5 App as shown below:
      local run ui5 app in BAS
      This confirms that the UI5 app is working fine.
      If you click the services endpoints link, then you will see an OData as shown below:
      Service in CAP
      This confirms even our services are working fine. This is a green signal for deployment.
    4. Now open a new terminal and write mbt build. This will generate a new folder “mta_archives” with a mtar file
      The above step will also generate new folders

    MTAR generation CAP

    1. Before we deploy to SAP Cloud foundry, we have to login in our environment. In terminal write cf login
      Enter API endpoint: https://api.cf.eu10.hana.ondemand.com/ (or whatever it is for you)
      followed by your login email and password
      You will be logged into your respective environment. In case you have multiple subaccount, then you might be asked to choose one of them (using a number)
    2. Now right click on the mtar file generated and click “Deploy MTA Archive”

    SAP CAP Deployment in BAS

    This will deploy the app in cloud foundry or SAP BTP. In the terminal you will get successful message that all the services were deployed.

    1. To test the deployed UI5 App, go to SAP BTP and reach your respective subaccount -> space. Here list of applications will appear, search for your approuter.Open it. You will find a link. You can even find it within the terminal after deployment, e.g.:
      Run UI5 using App Router
    2. Opening only App Router will give error “Not Found”. So, append your approuter as mentioned below:
      Extend the URL with the application ID “/<app ID>”:
      https://ps-scp-<space name>-mta-<app name>-approuter.cfapps.<region>.hana.ondemand.com/<app ID>Note! If the “<app ID>” contains dots e.g. “<app ID>” is “test2.test.1.test0”, dots should be ingnored and the URL should look as:https://ps-scp-<space name>-mta-<app name>-approuter.cfapps.<region>.hana.ondemand.com/test2test1test0

    In our use case the url will be: <app router>/nscap-test/index.html

    1. After login, you will see the below link:
      UI5 deployed App test

    Congratulations, you have successfully created your CAPM UI5 App and deployed the same. You can also check other ways to create a UI5 CAPM App.

  • Azure Pipeline Setup – Release (Continuous Deployment)

    Preface – This post is part of the SAP on Azure series.

    Introduction

    Azure DevOps provides an option to create a pipeline that can be configured in such a way that it can take the latest code from a branch, and build it into artifacts (deployable file) and then deploy the same in a specific cloud platform. This full process can be automated, and it is called Continuous Integration and Continuous Deployment (CI CD Pipeline). In this article, we will discuss the later part of pipeline that is Release and Continuous Deployment.

    Creating a Release Pipeline for Continuous Deployment

    1. Go to Releases, as shown below:

      Go to Releases

    2. Create or import a pipeline (for that you need to export the existing one and then import)
      import a pipeline
    3. When you create a new pipeline, choose Empty Job, as shown below:
      choose Empty Job
    4. Now, add your stage name
      add your stage name
    5. Change the name of the pipeline
      name of the pipeline
    6. Now click on “Add an artifact” and choose the source as the builder we have created above:
      Add an artifact
    7. Now, add a trigger for automation (Continuous Deployment), add your branch by following steps as shown below:
      Continuous Deployment
    8. Now, add artifact filter, just in case you don’t want every stage to run for all the builds:
      add artifact filterHere, you need to choose the branch for which this stage is meant to run the pipeline
    9. The pipeline can be easily copied from existing one by uploading pipeline json which has given code.
      Also, you must change given builder name with yours under Tasks (for each of the stages)
      change given builder name
    10. Once you are done with the above activities, then go to variables and given info there:
      Add variables in Release
    11. Now simply save and run the pipeline
      Run Release Pipeline

    Hence, we have successfully created an end to end CICD Pipeline.

    Continuous Deployment

    In CICD Pipeline, we can automate the deployment part with Continuous Deployment. We have shown how to do that in step 07, above.

  • Azure Pipeline Setup – Build (Continuous Integration)

    Preface – This post is part of the SAP on Azure series.

    Introduction

    Azure DevOps provides an option to create a pipeline that can be configured in such a way that it can take the latest code from a branch, and build it into artifacts (deployable file) and then deploy the same in a specific cloud platform. This full process can be automated, and it is called Continuous Integration and Continuous Deployment (CI CD Pipeline). In this article, we will discuss the first part of pipeline that is Build and Continuous Integration.

    Build Pipeline Creation based on YAML

    Click New Pipeline

    Click New Pipeline

    Click on Azure Repos Git

    Click on Azure Repos Git

    Select your Repository

    Select your Repository

    Choose Starter Pipeline

    Choose Starter Pipeline

    Save and Run (Just add comment: “Initial Configuration”)

    Save and Run

    Note: In case you get error “Pushes to this branch are not permitted; you must use a pull request to update this branch.”  Then you need the permission to Push directly.
    Now you can see the newly created pipeline.

    newly created pipeline

    1. Now, we have a pipeline. The next thing we can do is to manually setup the whole pipeline or use the existing pipeline code. Here, we will use from the existing one.
      Click on the three dots next to the newly created pipeline:

    Edit Pipeline

    Add variables here:

    Add variables in Pipeline

    Add following variables:

    version.major = 1
    
    version.minor = 4
    version.patch = $[counter(variables['version.minor'], 0)]

    Add following variables

    Then add the given code in your yaml now(you can edit as per your branch name):

    # Variable 'version.major' was defined in the Variables tab
    # Variable 'version.minor' was defined in the Variables tab
    # Variable 'version.patch' was defined in the Variables tab
    # Cron Schedules have been converted using UTC Time Zone and may need to be updated for your location
    trigger:
      branches:
        include:
        - refs/heads/dev
        - refs/heads/release
      batch: True
    schedules:
    - cron: 0 0 * * *
      branches:
        include:
        - refs/heads/dev
    - cron: 0 8 * * *
      branches:
        include:
        - refs/heads/devui
    - cron: 0 16 * * *
      branches:
        include:
        - refs/heads/devui
    name: v$(version.major).$(version.minor).$(version.patch)__$(SourceBranchName)
    jobs:
    - job: Job_1
      displayName: Agent job 1
      pool:
        vmImage: ubuntu-18.04
      steps:
      - checkout: self
      - task: Bash@3
        displayName: Generate semantic version variable with value
        inputs:
          targetType: inline
          script: 
            if [ '$(Build.SourceBranchName)' == 'dev'];
    
            then
                echo "##vso[task.setvariable variable=semanticversion]dev_$(version.major).$(( $VERSION_MINOR +1 )).$(version.patch)"
            elif [  '$(Build.SourceBranchName)' == 'release']
    
            then
                echo "##vso[task.setvariable variable=semanticversion]v$(version.major).$(version.minor).$(version.patch)"
            else
                echo "##vso[task.setvariable variable=semanticversion]tmp_$(version.major).$(( $VERSION_MINOR +1 )).$(version.patch)"
            fi
      - task: NodeTool@0
        displayName: Use Node 10.x
        inputs:
          versionSpec: 10.x
      - task: CmdLine@2
        displayName: Build MBT Command
        inputs:
          script: >-
            npm install -g mbt
    
            npm config set @sap:registry https://registry.npmjs.org/
    
            mbt build
      - task: CopyFiles@2
        displayName: Copy Artifact to Staging Directory
        inputs:
          SourceFolder: $(agent.builddirectory)/s/mta_archives
          TargetFolder: $(Build.ArtifactStagingDirectory)
      - task: CmdLine@2
        displayName: Rename MTAR by the semantic versioning
        inputs:
          script: >+
            mv $(Build.ArtifactStagingDirectory)/*.mtar $(Build.ArtifactStagingDirectory)/TEST_$(semanticversion).mtar
    
      - task: file-creator@6
        displayName: Create file with variables
        inputs:
          filepath: $(Build.ArtifactStagingDirectory)/variables.json
          filecontent: >-
            {
                "semanticversion": "$(semanticversion)"
            }
      - task: PublishBuildArtifacts@1
        displayName: 'Publish Artifact: drop'
      - task: git-tag-on-release-task@9
        displayName: Tag Artifacts
        enabled: False
        inputs:
          staticTagName: $(semanticversion)
    ...
    
    
    

     

    Now, save your pipeline and run it. It will fetch the latest code from the base branch (here devui) and create a fresh build.

    Build Pipeline Creation based on tasks

    In this method, we will create a blank pipeline and tasks manually as shown below.

    1. Click on Create a new pipeline
    2. Click “Use the classic editor” from the bottom
    3. Now select a source and other details as shown below:
      select a source
    4. Select “Empty Job” from the next step:
      Select Empty Job
    5. Now you have reached to the main screen where all other information for the pipeline builder will be added:
      Builder configurationHere you can change the project name initially and add the variables in the variable tab as we did earlier. For example I changed the builder name and added a test variable.
      change the project name

      In our use case, add these variable with given value:

      1. major = 1
      2. minor = 4
      3. patch = $[counter(variables[‘version.minor’], 0)]
    6. Now, One by one add given tasks:
      Add tasks in DevOps Builder
    7. For Bash, these are the values, we have added:
      Display name: Generate semantic version variable with value
      Type: Inline
      Script:

      if [ '$(Build.SourceBranchName)' == 'dev'];
      
      then
          echo "##vso[task.setvariable variable=semanticversion]dev_$(version.major).$(( $VERSION_MINOR +1 )).$(version.patch)"
      elif [  '$(Build.SourceBranchName)' == 'release'  ]
      
      then
          echo "##vso[task.setvariable variable=semanticversion]v$(version.major).$(version.minor).$(version.patch)"
      else
          echo "##vso[task.setvariable variable=semanticversion]tmp_$(version.major).$(( $VERSION_MINOR +1 )).$(version.patch)"
      fi
      

       

    8. For Node.js tool installer, make given changes:
      Display name: Use Node 10.x
      Version Spec:
      x
    9. For Command line, make given changes:
      Display name: Build MBT Command
      Script:

      npm install -g mbt
      npm config set @sap:registry https://registry.npmjs.org/
      npm i -g @sap/cds-dk
      mbt build

       

    10. For Copy files, add given changes:
      Display name: Copy Artifact to Staging Directory
      Source Folder: $(agent.builddirectory)/s/mta_archives
      Target Folder:
      $(Build.ArtifactStagingDirectory)
    11. For Command line, make given changes:
      Display name: Rename MTAR by the semantic versioning
      Script:

      mv $(Build.ArtifactStagingDirectory)/*.mtar $(Build.ArtifactStagingDirectory)/TEST_$(semanticversion).mtar
    12. For File Creator, add given changes:
      Display name: Create file with variables
      File path: $(Build.ArtifactStagingDirectory)/variables.json
      File content:
      { “semanticversion”: “$(semanticversion)”}
    1. For Publish Build Artifacts, add given changes:
      Display name: Publish Artifact: drop
      Path to publish:
      $(Build.ArtifactStagingDirectory)
      Artifact name:
      drop
      Artifact publish location:
      Azure Pipelines
    2. Till now, you have added items and variables, now you can add given Triggers:
      Continuous Integration
    3. Now go to Options tab, and make given changes:
      Add Build number format
      Build number format: v$(version.major).$(version.minor).$(version.patch)__$(SourceBranchName)
    4. Now save and queue your pipeline, you have successfully created a pipeline. Now run it with the branch you want.

    Enabling Continuous Integration in Azure Pipelines

    In the above steps, at step number 14, we have added triggers. This is exactly what is known as Continuous Integration. Here, you enable it with a checkbox and add branches for which it is applied. Once the branch is changed by a Pull Request in future then the CI is automatically triggered and build is created. In the next article we will discuss regarding Continuous Deployment, the next part in CICD pipeline.

  • SAP ABAP RAP CRUD operation

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

    Introduction

    To enable the CRUD operations in SAP ABAP RAP managed scenario, you need to enable the transactional behavior in Behavior Definition. There is no need to explicitly implement the CRUD operation in behavior implementation class, the RAP framework itself handles this.

    Steps for enabling CRUD in RAP Managed scenario

    1. Create CDS views
    2. Create Behavior Definition
    3. Enable transactional behavior of Business Object and activate.
    4. Test using EML (Entity Manipulation Language)

    Create CDS views

    Procedure

    1. Right-click on package
    2. Go to New >> Other Repository Objects >> Core Data Services >> Data Definition
    3. Provide the details (Name, Description).
    4. Select Next and provide the Transport Request number.
    5. Select Finish.

    Interface view SAP RAP

    Create Behavior Definition

    Procedure

    1. Right-click on root CDS view
    2. Select New Behavior Definition
    3. Provide the details (Name, Description).
    4. Select Next and provide the Transport Request number.
    5. Select Finish.

    Create Behavior Definition

    Enable transactional behaviour and activate

    Add transactional behaviour in Behavior Definition

    Test using EML

    In Report, implement EML statements to test the CRUD operations

  • OData Development using SAP ABAP RAP

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

    Introduction

    In SAP ABAP RESTful Application programming, the business service is RESTful service which is called by end-users/customers. It consists of two parts: Service Definition and service binding. The service binding implements the protocol such as OData and the services to be consumed by customers. In this article we will learn OData development using SAP ABAP RAP.

    Steps for OData development using SAP ABAP RAP

    1. Create Service Definition
    2. Expose Services
    3. Create Service Binding
    4. Select service type as OData while creation. Click Finish.
    5. Activate service

    Create Service Definition

    Right-click on Package >> New >> Other Repositories Objects >> Service Definition.
    Provide the details to create a Service Definition.

    Create Service Definition

    Once the Service Definition is created, expose the required entities and activate it.

    expose the required entities

    Create Service Binding

    Right-click on Package >> New >> Other Repositories Objects >> Service Binding.
    Provide Package details, Name, Description and Service Definition name. Select the Binding Type as ODATA to create OData Service Binding.

    SAP RAP Create Service Binding

    Verify the information and click on activate.

    OData Publish SAP RAP