Blog

  • What is SAP FICO?

    What is SAP FICO?

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

    Introduction

    The SAP FICO acronym stands for SAP Financial Accounting and Controlling and is one of the most important SAP modules. It can be integrated with SAP MM, SAP SD, SAP PP, SAP SCM, etc.

    SAP FI is a financial management system that analyzes the financial data of an organization. SAP CO is responsible for monitoring, coordinating, and optimizing all the processes of an organization.

    Subcomponents of SAP FI

    The SAP FI system is divided into several subcomponents for specific account processing. The following are the SAP FI subcomponents:

    • Finance Accounting General Ledger: It contains all the transactions of companies.
    • Finance Accounting Accounts Receivable: Records customers’ transactions and manages their accounts.
    • Finance Accounting Accounts Payable: Records all vendor and manpower transactions.
    • Finance Accounting Asset Accounting: Captures all the transactions related to the company’s fixed assets such as land etc.
    • Finance Accounting Bank Accounting: Keeps track of the company’s financial account transactions and data.
    • Finance Accounting Travel Management: It manages all aspects of the travel process, including booking trips and handling travel expenditures.
    • Finance Accounting Fund Management: Manages the company’s revenue and expense budgets.
    • Finance Accounting Legal Consolidation: It provides an overview of the company’s financial position as a whole by combining financial statements for multiple entities.
    • Finance Accounting Special Purpose Ledger: The ledgers are defined in SAP FI for reporting purposes.

    SAP FI Subcomponents

    Figure 1: SAP FI Subcomponents

    Why use SAP FI?

    SAP FI manages financial accounting data across multiple companies, currencies, and languages. The objective is to record all financial transactions posted by an entity and prepare an accurate financial statement at the end of the trading period.

    There are several financial components involved.

    • Fixed asset
    • Accrual
    • Cash journal
    • Accounts receivable and payable
    • Inventory
    • Tax accounting
    • General ledger
    • Fast close functions
    • Financial statements
    • Parallel valuations
    • Master data governance
  • Introduction to Quantum Computing

    Introduction to Quantum Computing

    Preface – This post is part of the Quantum Computing series.

    Introduction

    Modern Computing devices come in various shapes and forms. From smart-watches to GPS systems, from mobile phones to supercomputers, from space probes to drones, all these devices operate on the same underlying machinery which is that of a classical computer. The fundamental operation of a classical computer relies on encoding information as a string of binary characters. A single character-the smallest chunk of information-is called a bit which can either be 0 or 1. As modern computers are digital, 0 represents the low voltage and 1 represents high voltage. This information is stored in the millions of transistors present in your processor which then carries out operations on this information. 

    The reason we are talking about modern computers and their working principles is that we want to highlight the fact that all modern computing devices work on the same fundamental principle. Quantum Computers on the other hand do not operate on these principles. They are fundamentally different than their classical counterparts. The way we represent and process information in a Quantum Computer relies heavily on exploiting the principles of “Quantum mechanics”. In this and the upcoming modules, we will learn these principles and ways to exploit said principles to perform Quantum Computation.   

    Advantages of Quantum Computing  

    Now, before we explore the more technical workings of a Quantum Computer in detail, we would like to cover the reason we are interested in building one in the first place! Exploring these reasons themselves will give us a good intuition on what a Quantum Computer should be able to accomplish. In this section, we will discuss these reasons in teams of both their advantages and disadvantages.

    Basically, there are several problems, that are hard to solve on classical computers. Let’s take the example of one such problem. 

    Suppose you have to plan a small dinner party. Your task is to find the best seating arrangement. Let’s take a small number, suppose you have 7 guests. You have to plan a seating arrangement such that no opposing parties sit near each other and more importantly, make sure that every person is sitting next to a like-minded individual. For simplicity suppose the table is round. Now, if you do the math then there are 6x….x1 = 6! = 720 ways of seating 7 people around the table. Let’s say that your atheist friend cannot sit next to your very religious grandma. So, the number of possibilities comes down to 6! – 2×5! = 480. 

    Now, you are faced with the daunting task of analyzing all the 480 combinations and finding the best one. It is not a big deal for your personal computer to analyze 480 combinations. You’ll probably find the best arrangement in a matter of seconds if you write a good enough program. But what if instead of 7 guests, you have to seat 10 guests. The number of possibilities will increase to 282240 which will take more than a couple of seconds for your computer to analyze. As the number of guests increases, the number of possibilities increases exponentially which will take more time for your computer to process. This is what Computer Scientists call “Exponential Time Complexity” which is obviously not a good thing when you want to solve a problem like this. 

    The problem which we described above is called an Optimization Problem. It simply means that out of all the possible combinations of states, we want to find the state which solves the problem optimally. As we already discussed, Optimization Problems are hard to solve on a Classical Computer. That, however, does not mean that they cannot be solved. Computer Scientists have developed algorithms to solve these types of problems where they find a good enough solution (if not the best) in a reasonable amount of time. But that does not mean we cannot do better. 

    It is theoretically proven that Quantum Computers can solve certain problems much more efficiently than classical computers. For instance, Shor’s algorithm can factorize large numbers into their prime factors in Polynomial-time rather than the Exponential-time taken by a classical computer. This was not exactly good news when Peter Shor discovered it in 1994. Turns out, our modern cryptosystem relies on this inefficiency of classical computers and although we are very far away from developing a large-scale Quantum Computer which can run Shor’s Algorithm, it is still a problem that needs to be addressed before we are anywhere near doing so. 

    The last thing we want to talk about in this section is simulations, Quantum Mechanical Simulations to be precise. The theory of Quantum Mechanics proves that the world is Quantum Mechanical in nature. To make any reasonable predictions about any natural phenomena, we should be able to simulate those phenomena on a machine. Simulating Quantum Mechanical systems is again pretty difficult in terms of both time and space on a classical machine. In the 1980s theoretical physicist, Richard Feynman proposed the idea to address this problem by developing a Quantum Machine to simulate Quantum Systems. He was one of the first people to propose the idea of developing a Quantum Computer.

    What is Quantum Computing?

    The textbook definition of Quantum Computing goes something like this – ‘Quantum Computing is defined as an area of computing that harnesses the principles of “Quantum Mechanics” to perform computations. The devices used to perform Quantum Computation are called Quantum Computers’. Sounds simple, right? It is pretty obvious as far as textbook definitions go. 

     As we explained in the previous sections, the “Quantum” nature of a Quantum Computer allows us to perform operations in a different way than classical computers. The basic Quantum mechanical principles that allow such huge advantages are: Superposition, Entanglement, and Interference. 

    The principle of Superposition explains the ability of a Quantum bit (qubit) to be in a combination of multiple states at the same time until a measurement is made, in which case the superposition collapses into a single state.

    Two qubits can be Entangled which allows them to change states in the instance one of the qubits changes its state.

    Interference is a relatively easier concept to grasp than the previous two. Various qubits Interfering with each other can either reinforce or diminish each of their states. Think of each quantum particle as a wave function, which constructively or destructively interferes with each other.

    This is a highly condensed version of these principles that aims to provide an overview as opposed to conceptual understanding. We will talk about these principles in a lot more detail in the upcoming modules.

    Applications of Quantum Computing

    Now that we have a basic sketch, in very broad strokes of what Quantum Computing is all about, it’s time that we discuss how scientists are convincing governments and investors of why they should allow them to spend large sums of money on this technology. And let me tell you, this is not an easy task. There’s a reason why Defence and weapons development have a lot more funding than fields like theoretical physics. So, here’s why they think all that money is worth it.

    Cryptography: We discussed Shor’s Algorithm in the previous section and how it is a threat to modern cryptosystems. This has opened up a whole new field called Quantum Cryptography to address this threat and develop Cryptographic Protocols relevant for a post-quantum world. One such notable protocol is Quantum Key Distribution (QKD). QKD allows two users to exchange keys over a Quantum Channel such that any third-party interception will result in discarding the keys, starting the process all over again. 

    Artificial Intelligence: Quantum Machine Learning (QML) can revolutionize the field of Artificial Intelligence. AI requires some heavy number crunching for the models to learn and make good predictions. Quantum Computers can potentially do this in significantly less time than a classical computer. QML is an up-and-coming research field that aims to develop various “Quantum” Algorithms to efficiently realize an AI model.

    Drug development: Drug Development requires analyzing the structure and properties of various chemical compounds and molecules in order to develop better medications. These compounds are made up of molecules. Molecules are made up of atoms which are in turn made up of subatomic particles which are Quantum mechanical in nature. As we discussed earlier, Quantum Systems can be simulated much more efficiently on a Quantum Computer than they can on a classical one. Quantum computers have already successfully simulated simple molecules and are predicted to simulate much more complex chemicals in time. Thus, promising synthesis of better, more efficient drugs against known and unknown diseases.  

  • Steps to Create SAP Business Application Studio (BAS) Account

    Introduction

    SAP BAS or SAP Business Application Studio is a new SAP IDE built on the layout similar to Microsoft VS Code, is a next version development environment of SAP Cloud and SAP UI applications. In this article we will show how to create a SAP BAS trial account. This article can be even used to access your actual BAS (non-trial), jump to step 11 for that.

    Steps to create SAP BAS Account

    1. Visit https://www.sap.com/ and click on Account Button as shown below:
    2. Enter your details in the form shown below:
    3. You will get a mail after filling the form:
    4. On click of activate account, enter your password and click submit:
    5. You will be redirected to a link or visit it: https://account.hanatrial.ondemand.com/. Here, you will be required to approve your phone number:
    6. Accept the legal disclaimer as shown below:
    7. Now you will be logged into SAP BTP, here you need to choose a region near to you, it will create a global account and subaccount for you, click continue once done:
    8. Now go to your trial account, by clicking the below button:
    9. Click on your subaccount:
    10. Inside subaccount, click Service Marketplace, there search “SAP B”, and then click the three dots next to “SAP Business Application Studio” and thereafter click on “Go to Application”
    11. Press “OK” and proceed:
    12. You will land on homepage of “Business Application Studio” as shown below:
    13. Save or bookmark the link of the BAS for future use. Now, you can start here by clicking a new Dev Space.

     

  • Delete an Entity using SAP OData

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

    Delete operation is used when you want to remove a record from the database. For example, you have created one quotation and now you no longer want it. So you will delete the quotation using the DELETE request.

    This article describes the step-by-step procedure to implement and test delete operation in SAP OData.

    Context

    Delete entity can be implemented by redefining the DELETE_ENTITY method.

    Procedure

    1. Open *DPC_EXT class artifact of OData and redefine *DELETE_ENTITY method.
    2. Reimplement the delete method.
      Delete an Entity using SAP OData
      IT_KEY_TAB holds the values from the frontend.
    3. Activate the class and register the service.
    4. Execute and test the OData.
      1. Select Entity set
      2. Select DELETE option
      3. Add the key value to be deleted in the request URL
      4. Execute the request
        Delete an Entity using SAP OData Testing
      5. Status 204 represents success.
      6. Verify in the table the record is successfully deleted.

    Tutorial Video

    You can watch the below video to learn implementation:

    [embedyt] https://www.youtube.com/watch?v=2rEZrFj2haE[/embedyt]
  • Update an Entity using SAP OData

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

    Many times, we come across a scenario where we want to update the data records, for example, we want to update the phone number or address.

    This article describes the step-by-step procedure to implement and test update operations in SAP OData.

    Context

    Update entity can be implemented by the redefining UPDATE_ENTITY method.

    1. Using PUT HTTP method.
    2. Using PATCH HTTP method.

    Difference between PUT and PATCH HTTP method

    • PUT: The request body is considered as the updated version of the original data stored in the database. When using PUT, we need to send the full payload in our request.
    • PATCH: It is used for the partial modification of the resource. When using PATCH, we only send the data to be modified in the request body.

    Procedure

    1. Open *DPC_EXT class artifact of OData and redefine *UPDATE_ENTITY method.
    2. Reimplement the method for the update.
      UPDATE_ENTITY method
    3. Activate the class and register the service.
    4. Execute and test the OData.
      1. Select Entity set
      2. Get the data to be updated using the GET request
      3. Click on Use as Request to copy the HTTP response to HTTP request which works as input.
        Execute and test the OData
      4. Change the field value Carname and URL in HTTP Request
      5. Select PUT option
      6. Add the key value to be updated in the request URL
      7. Execute the request
        Execute and test the OData PUT Request
      8. Status code 204 represents success
        PUT Request response
      9. Verify-in the table data is successfully updated.
        verify the updated data

    Tutorial Video

    You can watch the below video to learn implementation:

    [embedyt] https://www.youtube.com/watch?v=2rEZrFj2haE[/embedyt]
  • Create an Entity using SAP OData

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

    Context

    Create entity can be implemented in two ways:

    1. Using CREATE_ENTITY method for single entity creation.
    2. Using CREATE_DEEP_ENTITY method to create a single entity as well as parent and child entity together.

    Procedure

    1. Open *DPC_EXT class artifact of OData and redefine *CREATE_ENTITY method.

    2. Reimplement the method.

    method PARTNERS_CREATE_ENTITY.
    
      data: lv_id                type          snwd_partner_id,
            ls_id                type          bapi_epm_bp_id,
            ls_header            type          bapi_epm_bp_header,
            lt_return            type 	      table of bapiret2,
            error_msg            type          string,
            ls_message           type          scx_t100key,
            lt_keys              type          /iwbep/t_mgw_tech_pairs,
            ls_snwd_bpa          type          snwd_bpa,
            lv_timestamp         type          timestamp.
    
      io_data_provider->read_entry_data( importing es_data = ls_header ).
    
      CALL FUNCTION 'BAPI_EPM_BP_CREATE'
        EXPORTING
          HEADERDATA        = ls_header " EPM: BP header data
        IMPORTING
          BUSINESSPARTNERID = ls_id
        TABLES
          RETURN     = lt_return.     
    
      if lt_return is not initial.
        loop at lt_return reference into data(lr_return).
          err_msg = lr_return->message .
        endloop.
    
        ls_message-msgid = 'SY'.
        ls_message-msgno = '002'.
        ls_message-attr1 = error_msg.
    
        raise exception type /iwbep/cx_mgw_busi_exception
          EXPORTING
            textid = ls_message.
      endif.
    
      CALL FUNCTION 'BAPI_EPM_BP_GET_DETAIL'
        EXPORTING
          BP_ID             = ls_id
        IMPORTING
          HEADERDATA        = er_entity
    endmethod. 
    

    The input data is passed in es_data structure and captured in ls_header. The structure ls_header is then used as the input parameter of BAPI ‘BAPI_EPM_BP_CREATE’ to create data in the database. Then BAPI ‘BAPI_EPM_BP_GET_DETAIL’ will retrieve the created data and capture it in er_entity which will be passed to the response body.

    3. Activate the class.

    4. Create Deep Entity (To create Header with Item): Redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY

    5. Reimplement the method.

    method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY.
    
     types: ty_t_soitem type standard table of  zcl_z_epm_rkt_mpc=>ts_salesorderitem with default key.
     types: begin of ty_s_so.
              include type zcl_z_epm_rkt_mpc=>ts_salesorder.
               types: items type ty_t_soitem,
             end of ty_s_so.
    
      data: ls_sales_order     type ty_s_so,
            lv_compare_result  type /iwbep/if_mgw_odata_expand=>ty_e_compare_result.
    
      data: lv_so_id    type BAPI_EPM_SO_ID,
            ls_so_hdr    type BAPI_EPM_SO_HEADER,
            ls_so_hdr2   type BAPI_EPM_SO_HEADER,
            ls_so_item   type BAPI_EPM_SO_ITEM,
            lt_so_item   type standard table of BAPI_EPM_SO_ITEM,
            lt_so_item2  type standard table of BAPI_EPM_SO_ITEM,
            lt_return   type bapirettab,
            ls_return   TYPE bapiret2,
            ls_message  type scx_t100key,
            error_msg     type string.
    
      constants: lc_so_itm TYPE string VALUE 'Items'.
    
    * Validate whether data matches
      lv_compare_result = io_expand->compare_to( lc_so_itm ).
    
    * Access data from IO_DATA_PROVIDER
      if lv_compare_result EQ /iwbep/if_mgw_odata_expand=>gcs_compare_result-match_equals.
    io_data_provider->read_entry_data( IMPORTING es_data = ls_sales_order ).
    
    *   Move header Sales order data into BAPI structure
        move-corresponding ls_sales_order to ls_so_hdr.
    
    *   Move Sales Order items into BAPI table structure
        loop at ls_sales_order-items into ls_so_item.
           append ls_so_item to lt_so_item.
        endloop.
    
        CALL FUNCTION 'BAPI_EPM_SO_CREATE'
          EXPORTING
            HEADERDATA          = ls_so_hdr
          IMPORTING
            SALESORDERID        = lv_so_id
          TABLES
            ITEMDATA            = lt_so_item
            RETURN              = lt_return.
    
        if lt_return is not initial.
          loop at lt_return into ls_return.
            err_msg = ls_return-message .
          endloop.
    
          ls_message-msgid = 'SY'.
          ls_message-msgno = '002'.
          ls_message-attr1 = error_msg.
    
          raise exception type /iwbep/cx_mgw_busi_exception
            exporting
              textid = ls_message.
        else.
    
          CALL FUNCTION 'BAPI_EPM_SO_GET_DETAIL'
            EXPORTING
              SO_ID            = lv_so_id
            IMPORTING
              HEADERDATA       = ls_so_hdr2
            TABLES
              ITEMDATA         = lt_so_item2.
          move-corresponding ls_so_hdr2 to ls_sales_order.
          ls_sales_order-items = lt_so_item2.
    
          copy_data_to_ref(
          EXPORTING
            is_data = ls_sales_order
          CHANGING
            cr_data = er_deep_entity ).
        endif.
      endif.
    endmethod. 
    

    The structure of incoming data contains parent and child entity nested structure. This is defined with type ty_s_so.

    6. Activate the class

    7. Execute the Create request.

    • Select Entity Set
    • Select HTTP method as POST
    • Add the data in the request body
    • Click Execute

    Tutorial Video

    You can watch the below video to learn implementation:

    [embedyt] https://www.youtube.com/watch?v=2rEZrFj2haE[/embedyt]
  • Testing SAP OData CRUD operations using Postman

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

    Introduction

    Postman is an API development tool that helps developers to create, test, share and document the APIs. It has various HTTP requests like GET, POST, PUT, PATCH and the ability to save the environment.

    In this article, we will learn how to set up the POSTMAN and then we will test OData CRUD operations using POSTMAN.

     

    Installing POSTMAN

    To install POSTMAN on your device you can use the link go.postman.co/home and download the latest version for your platform.

    For more details on installing and updating POSTMAN, you can refer to the link https://learning.postman.com/docs/getting-started/installation-and-updates/

     

    Components of POSTMAN

    Postman UI is made up of various components.
    Components of POSTMAN

    • Left sidebar provides the navigation to Collections, APIs, Environments, Mock Servers, Monitors and History.
    • Header provides the access to Workspace, Reports, and Search option.
    • Center area is where we work with requests.
    • Right sidebar provides the link to Comments, Request Info’s, Code and Documentations.

     

    Variables

    We will use the variables to store our data which will be reused multiple times.

    You can create variables by clicking ENVIRONMENT in the left panel and selecting GLOBAL.

    Variables in Postman

    Here you create variables and provide initial and current value. In case you need to change the value of the variable you only need to update the CURRENT VALUE field. This is the field from where the data is picked up.

    Scope of variables:

    Scope of variables

    • Global scope: Enable you to use data between the Collection, requests, test scripts and environment.
    • Collection: Enable you to use data in different requests under the same collection.
    • Environment: Enables to tailor the processing to different environments.
    • Data: Comes from external files like CSV, JSON.
    • Local: The scope is temporary and can only be used in the defined requests.

    Create variable

    1. Select data and click on Set as Variable.
      Create variable
    2. Select Set as new Variable.
      Set as new Variable
    3. Provide name, value and scope.
      Save Variable

     

    Format to use variables in request: {{variable_name}}

    Example:  .Example of variable in postman

     

    HTTP requests

    There are various HTTP methods available that are used to make a request to APIs. Some of the frequently used HTTP methods are:

    • GET: Used to retrieve data from APIs (Read scenario)
    • POST: Used to send new data to API (Create scenario)
    • PUT or PATCH: Used to update existing data (Update scenario). PUT request modifies the entire resource in the database whereas PATCH request modifies only the supplied resource. So, while using PUT we need to send the entire data in request URI and by using PATCH we need to send only the updatable field.
    • DELETE: Used to remove existing record (Delete scenario)

    It supports various addition methods. Refer to the below snip.
    HTTP requests in Postman

    Creating requests

    You can create a request by clicking on the NEW tab and selecting HTTP Request. Also, you can create a request by clicking + button.

    Creating requests

    After selecting HTTP Request, a screen will open. Provide relevant name, description to your HTTP request.

    Specify the relevant details for your requests (like HTTP method, URL, parameters, body data).

    Get request in Postman

    Click on SEND button to save your call. You can create a collection to save all your related requests under one folder.

     

    Collection

    A collection is a folder that groups the number of API requests. There can be n number of collections in Postman. Generally, an API request belonging to the same business object is saved under  the same Collection. You can even share your API requests with your team via collection.

    Authentication

    Authentication is verifying the client’s identity who is accessing the request whereas authorization is verifying the client’s action of permission. Some APIs require authorization details act.

    To provide authorization details, click on the Authorization tab and select auth Type. Provide the relevant details and SAVE.

    There are various auth types, for more details check out Authorizing requests.

    Authentication in Postman

    Instead of adding an authorization in each request individually, you can add your authorization details directly to your Collection.

    Steps:

    1. Select TYPE as Inherit auth from parent.
      Type of Authorization
    2. Click Collection and add authorization details there.
      Basic Authentication in Postman

    Sending requests

    GET request

    Steps to follow:

    1. Click on the NEW button and select HTTP request
      New GET request

     

    1. Select HTTP request GET and enter OData service URL in URL field
      Enter URL

     

    1. Click on the Send button
      Send Request

     

    At the bottom, you can see the output and status code.

     

    Fetch x-csrf-token

    An x-csrf-token is used to prevent cross-site request forgery attacks. While making a call for Create/Update/Delete we must need to send x-csrf-token value via Header.

    Steps to fetch the x-csrf-token value.

    1. Create a GET
    2. Add in HEADERS: key = x-csrf-token and value = fetch.
      Fetch x-csrf-token
    3. Execute the request by clicking on SEND
    4. Below you will get the result. In the Header section of the result you can find fetched x-csrf-token value. Get that value and paste it in HEADERS section of CUD requests.

     

    POST request

    1. Select HTTP request POST and enter OData service URL for create in URL field. (Do not provide the key field and its value in URI)
      POST request in Postman
    2. Provide x-csrf-token parameter in HEADERS (To fetch x-csrf-token refer How to fetch x-csrf-token?).
      Provide x-csrf-token
    3. Provide the data to be created in the BODY tab and select the relevant data type. Here, we have selected raw.
      Provide the data to be created in the BODY
    4. Save and click on Send to execute the request.

     

    PUT/PATCH request

    To know which request URI to use please read HTTP requests.

    1. Select HTTP request PUT/PATCH and enter OData service URL for create in URL field. ( Add key field and its value which is to be updated)
      Select HTTP request PUT
    2. Provide x-csrf-token parameter in HEADERS (To fetch x-csrf-token refer How to fetch x-csrf-token?).
      Provide x-csrf-token parameter in HEADERS tab
    3. Provide the data to be created in the BODY tab and select the relevant data type. Here, we have selected raw.
      For Put Provide the data to be created in the BODY tab
    4. Save and click on Send to execute the request.

     

    DELETE request

    1. Select HTTP request DELETE and enter OData service URL for create in URL field. ( Add key field and its value which is to be deleted)
      Select HTTP request DELETE
    2. Provide x-csrf-token parameter in HEADERS (To fetch x-csrf-token refer How to fetch x-csrf-token?).
      Provide x-csrf-token for Delete
    3. For DELETE requests we don’t have to provide any input in BODY.
      No body required for Delete
    4. Save and click on Send to execute the request.

    Sharing API requests

    To share your API requests with your team or other people follow the below steps.

    1. Save your requests in Collection.
    2. Click on Collection that you want to share.
    3. Click on the Share button
      Sharing API requests
    4. There are three ways you can share.
      Share Quota

    Best practices

    1. If a parameter or value is used at multiple places. Always try to create its variable in the Environment section and use the variable in your requests.
      Example: If api.getpostman.com is used in all your requests URL.
      Postmand Best practices 1
      Create a variable with value api.getpostman.com and use the variable everywhere.
      The positive aspect is in case your domain is changed, you only need to change the value in one place and all your requests will adapt it.
      Postmand Best practices 2
      Postmand Best practices 3

     

    1. If you are adding Authorization, never provide your password directly in your Request or Collection level.

    The mishappening is, if you provide your password directly at a collection level or in request and you share the collection with your team or other people, the password will also get shared with them. So, everyone with that collection will get to know your password.

    Postmand Best practices 4

    The best approach is to create a variable for your password in the environment section and use that variable in the password field. This way only the variable name will be shared and your password will be safe.

    Postmand Best practices 5

    1. Instead of fetching x-csrf-token value and adding it to request every time manually, you can create a variable for x-csrf-token in the environment and add a script code to automatically update the x-csrf-token value in the environment.
  • MIME handling in SAP OData (File Media handling)

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

    This article will give a bare minimum to read and upload media files or MIME in SAP OData service.

    Procedure

    1. Create OData service
    2. Register service
    3. Execute service

    Steps

    1. Create OData
    2. Select EntityType and select checkbox ‘Media’
      Enable MIME in OData
    3. Generate runtime artifact. In MPC ext class redefine the DEFINE method.
      Generate MIME runtime artifact ODATA
    4. Redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM .
      Create Stream
    5. Redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM .
      Get Stream
    6. Redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~UPDATE_STREAM .
      Update Stream

     

    1. Redefine method FILESET_GET_ENTITYSET.
      FILESET_GET_ENTITYSET
    2. Register OData service
    3. Execute
      1. GET_STREAM is used to download the media
      /sap/opu/odata/sap/ZMIMEFILE_SRV/File(Mandt=’100′,Filename=’mobile.jpg’)/$value.
      Download the media
       

      2. CREATE_STREAM is used to upload the media
      /sap/opu/odata/sap/ZMIMEFILE_SRV/File
      Upload the media

     

    Features

    List of supported MIME Types that can be stored in MIME Repository:

    Category/Subcategory File Extension Description
    texts text/css css CSS stylesheet file
    text/html html, htm HTML file
    text/javascript js JavaScript file
    text/plain txt, c, cc, g, h, hh, m, f90 Plain text file
    text/richtext rtx MIME rich text
    text/xml xml XML file
    Images image/gif gif GIF graphic
    image/ief ief Exchange Format
    image/jpeg jpeg, jpg, jpe JPEG graphic
    image/x-rgb rgb RBG graphic
    image/x-windowdump xwd X-Windows dump
    image/tiff tiff, tif TIFF graphic
    image/bmp bmp Icon
    image/ico ico Icon (Windows)
    Audio audio/basic au, snd AU and SND sound files
    audio/x-aiff aif, aiff, aifc AIFF sound file
    audio/x-aiff midi, mid MIDI file
    audio/x-pn-realaudio ram, ra RealAudio file
    audio/x-pn-realaudio-plugin rpm RealAudio plug-in file
    Video video/mpeg mpeg, mpg, mpe MPEG video
    video/x-msvideo avi Microsoft AVI video
    video/x-sgi-movie movie Microsoft SGI video
    video/quicktime qt, mov Quicktime video
    Applications application/acad (NCSA) dwg AutoCAD file
    application/dxf (CERN) dxf AutoCAD file
    application/mif mif Maker Interchange Format (Adobe FrameMaker)
    application/msword doc, dot MS Word file
    application/mspowerpoint ppt, ppz, pps, pot MS PowerPoint file
    application/msexcel xls, xla MS Excel file
    application/mshelp hlp, chm MS Windows help file
    application/octet-stream com, exe, bin, dll, class Executable file or program code file
    application/pdf pdf PDF file (Adobe Acrobat Exchange/Reader)
    application/postscript ai, eps, ps Postscript file (Adobe)
    application/rtf rtf RTF file (Microsoft)

     

  • $ORDERBY Query in SAP OData

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

    In this article, we will learn how to use $orderby query in our SAP OData services.

    What is the use of $orderby query?

    There are many query options to control the amount and order of data. One of the query options provided is $orderby. It adds the sorting capability to OData services. You can order the collection based on the fields available.

    System version

    SAP NetWeaver Gateway Release 2.0 Support Package >=03

    Syntax

    http://<server>:<port>/sap/opu/odata/sap/<service_name>/EntitySet?$orderby=<fieldname> <sortorder>

    where,

    • <fieldname> :is the name of the field.
    • <sortorder>: desc/asc

     

    Business Example

    An OData service has retrieved all the Product details, but you want the details in some specified order say, you want the details in descending order by price. Here you can use the $orderby query to achieve the desired output.

    You want to fetch the Product details in order by its Price in descending.

    Implementation

    In this section, we will implement $orderby on our Product Entity Set.

    Step 1: After the creation of the OData service, right Click on Entity Set under Service Implementation, go to ABAP workbench.

    SAP OData Implementation

    Step 2:

    Adjust your code for $orderby query. The orderby query option is available in the method by accessing importing parameter IT_ORDER.

    $ORDERBY Query in SAP OData

     

    In the GetEntitySet method, first, we retrieve all the products and get orderby “fieldname”, “sortorder” and apply them to the BAPI result data to get the required sort order.

    Step 3:

    Execute the service. If we don’t add $orderby in our service URL, we will get all the results from the system. If we add $order by in-service URL we will get the result based on the sort order provided.

    Service URL: /sap/opu/odata/sap/ZDEMO_GW_SRV_SRV/ProductsSet?$orderby=Price asc’.

    $ORDERBY Query in SAP OData Output

  • $TOP and $SKIP Query in SAP OData

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

    In this article, we will learn how to use $top and $skip query in our OData services.

    What is the use of $top $skip query?

    The OData query $top and $skip are used to restrict the data from the backend.

    To achieve the client-side pagination, we can use $top = n query and $skip = m is used in coordination with $top. $top query fetches the top n records skipping first m records.

    System version

    SAP NetWeaver Gateway Release 2.0 Support Package >=03

    Syntax

    • http://<server>:<port>/sap/opu/odata/sap/<service_name>/EntitySet?$top=5
    • http://<server>:<port>/sap/opu/odata/sap/<service_name>/ EntitySet?$top=5&skip=3

     

    Business Example

    • You want the first 5 records of Products. Or we want the first 10 roll number students in our result.
    • Teach wants first 10 roll number students skipping first 5.

    Implementation

    In this section, we will implement $top and $skip on our Product Entity Set.

    Step 1: After the creation of OData service, right Click on Entity Set under Service Implementation, go to ABAP workbench.

    SAP OData Implementation

    Step 2:

    Adjust your code for $top and $skip query.

    $TOP and $SKIP Query in SAP OData

    In the above code, we retrieved all the product details and applied $top and $skip query to get the required output.

    Step 3:

    Add $top and $skip query in OData URL and execute the service.

    Service URL: /sap/opu/odata/sap/ZProduct_Srv/ProductsSet?$top=5

    $TOP and $SKIP Query in SAP OData Output