Author: Rudramani Pandey

  • 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

  • $FILTER in SAP OData

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

    In this section, we will learn the concept of the $filter query in SAP OData and its usage.

    Supported System Version

    SAP NetWeaver Gateway Release 2.0 Support Package >=03

    Syntax

    http://<server>:<port>/sap/opu/odata/sap/<service_name>/EntitySet?$filter=ProductId eq ‘HP-101’

    Business Example

    The shopping site, say, Amazon is displaying all the products but you want some specific category to be displayed. So, you will apply filters (select category phones or laptops)  to display the data of your choice.

    Implementation

    In this section, we will implement $filter 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 $filter query.

    $FILTER in SAP OData

    The filter query option is available by accessing the parameter IT_FILTER_SELECT_OPTIONS.

    In the above code, we first retrieved the filter options passed from the frontend by reading IT_FILTER_SELECT_OPTIONS. And then passed the select-option range to BAPI to get the desired filtered output.

    Step 3:

    If we do not pass any filter option, we will get all the products from the system.

    Add $filter query in OData URL and execute the service. You can add one or more filter options.

    Service URL: /sap/opu/odata/sap/ZDEMO_GW_SRV_SRV/ProductsSet?$filter=Name eq ‘Notebook Basic 15.

     

    Operators used with $filter

    Logical Operators

    Logical Operator Description Example
    eq Equal https://<API-Server>/odata/v2/User?$filter=gender eq ‘F’ .
    ne Not Equal hhttps://<API-Server>/odata/v2/User?$filter=place ne ‘’London’
    gt Greater than https://<API-Server>/odata/v2/PicklistLabel?$filter=amount gt 200
    ge Greater than or equal https://<API-Server>/odata/v2/PicklistLabel?$filter=amount ge 200
    lt Less than https://<API-Server>/odata/v2/PicklistLabel?$filter=amount lt 200
    le Less than or equal https://<API-Server>/odata/v2/PicklistLabel?$filter=amount le 200
    and Logical and https://<API-Server>/odata/v2/PicklistLabel?$filter=amount le 200 and amount ge 300
    or Logical or https://<API-Server>/odata/v2/PicklistLabel?$filter=amount le 200 or amount ge 300
    not Logical not https://<API-Server>/odata/v2/PicklistLabel?$filter=amount le 200 not amount ge 300

     

    Arithmetic Operators

    Arithmetic Operator Description Example
    add Addition https://<API-Server>/odata/v2/PicklistLabel?$filter=amount add 5 gt 10
    sub Subtraction https://<API-Server>/odata/v2/PicklistLabel?$filter= amount sub 5 gt 10
    mul Multiplication https://<API-Server>/odata/v2/PicklistLabel?$filter= amount mul 5 gt 10
    div Division https://<API-Server>/odata/v2/PicklistLabel?$filter= amount div 5 gt 10
    mod Modulus https://<API-Server>/odata/v2/PicklistLabel?$filter= amount mod 5 gt 10

     

    Grouping Operators

    Grouping Operator Description Example
    ( ) Precedence grouping https://<API-Server>/odata/v2/PicklistLabel?$filter=(number sub 20) gt 30

     

  • Inquiry – Hands-on

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

    Introduction

    In this section, we’re going to see how to create an inquiry in the system.

    Steps to create an Inquiry:

    • Go to transaction code VA11.
    • Give Inquiry Type and Organization Data details
    • Give Header details
    • Give Item details
    • Save

    Go to transaction VA11.

    This is the transaction code to create an inquiry. You can just hit, enter or click on this green checkmark.

    Transaction VA11

     

     

    If you don’t like to remember these funky codes, they can still do logistics, sales and distribution, sales, inquiry and create.

    Create Inquiry VA11

     

     

    So you can do this transaction, either way, use the transaction Code VA11 or you go to logistics, sales and distribution sales inquiry, then create.

    So you can use VA11 or use the menu path.

    Give Inquiry Type and Organization Data details

    Go inside by either double-clicking it, or typing in VA11 and hitting enter, you’ll be taken to the screen. This is the first screen.

    Inquiry Type

    When you create an inquiry, what do you have here? You have two main pieces of data.

     

    • Inquiry type, and when you go create a quotation, it’s going to say a quotation type. I don’t want to fully get into the concept of actually creating an inquiry type or configuring an inquiry type yet. But for now, I just want to understand that there are two pieces to start with.
      If you want to give me an example, you go to a subway and order some sandwiches, you’re going to start with some basic choices, like is it going to be a six-inches or a foot long? Right. You’re going to make some basic choices and then further move up from there.
      So similarly, this is the first choice that you’ve got to make. What is the inquiry type that you’re going to create? There can be multiple inquiries, inquiries for a certain group of products from another group of products.
      For example, a company like HP could be doing one inquiry type for all parts, any spare parts, another inquiry type for, say, capital goods? Another inquiry type for, say, routers. Because they might represent different lines of businesses and each inquiry is different for them, so they might want to do a different inquiry for each of them.
    • Similarly, there is something called ORG Data. This is more or less the areas or the geographical areas in which they are to business. That’s a very gross misrepresentation. But for now, just think of our data as your different geographies.
      Like, again, if you take the HP example, the ORG data for sales happening in the US is going to be US organization distribution channel, let’s say retail and division park sales. And if they are creating an inquiry into Singapore, it’s going to be sales of Singapore. It could be retail or wholesale distribution channel and say capital goods division. Now, I’m just taking too many examples here, but don’t worry, we’re going to talk about all these things in much greater detail at a later point.

     

    I just want to give you an idea of what’s an inquiry type and what’s your data and more importantly, why you’re seeing them here, because this is going to set the precedent for what you’re going to enter going forward.

    Let me give you one simple example. You don’t want to choose the ORG data for the US. And when you go inside this enter customer from the Singapore or Japanese region. Right. It’s just wrong.

    So you’re making a choice here and you’ll stick to those choices going forward as you enter customer data and material data.

     

    All right, so that’s a goal here, click on this dropdown and select an as your inquiry. As I said, you can create your own inquiry types, but we’re not there yet. For now, we’ll select a standard inquiry type provided by SAP and click OK, and over here, select your sales or distribution channel and division.

    Select Inquiry

    Enter Organizational Data

     

    Now, what are these Sales Organization 1000 represents the German sales org, Distribution Channel 10 represents the retail distribution channel and 00 represents a cross-division. But why is 1000 representing Germany? We will come to that when we come to enterprise structure. But until then, just select this level of details and hit enter.

    Enter Header data.

    Enter Header Data

     

    You need to fill in some data and the rest of the details are automatically be picked up by SAP based on the data that’s already available.

    For example, you want to pick a customer, right? In this case, Wal-Mart is our customer. We might not have created Wal-Mart yet in the system because we don’t know how to create a customer yet, but let’s just pick some customers for now.

    Say 1000, that’s a customer.

    Choose Sold to Party

     

    Now, again, why one thousand? I just picked up a number because I know it exists. If you don’t know a number, you can click on the button beside the Sold-To-Party field and it’ll pop up a search box where they can do a variety of searches by postal code by city.

    Search Ship to Party

     

    Let’s see if there’s anything like Wal-Mart. So I do a start which is a wild character and then to Wal-Mart and then star. So anything that has Wal-Mart in its name will be displayed.

    Search Ship to Party by Company Name

     

    So this is where you do your search and you select what kind of customer you want and so on.

     

    So now coming back to our step. We have entered our customer and now hit the green button. It’s giving me another pop up now.

    Partner Selection Screen

     

    It says this customer has multiple ship to parties.

     

    That means there are many ship to address that the customer could potentially ask us to ship. Which one do you want to select? You can either select the default one, which has a checkmark in there, or you can select the other one.

    Select Ship to Party

    Now you can just let it remain and click OK.

     

    Right, in this case, it has already pulled up the customer name, customer address and other details for the customer corresponding to the number 1000. So, what’s the name of the customer? It’s Becker Berlin and he stays at Calvin Strasse, some address and then Berlin. That’s the address.

    Verify Ship to Party

     

     

    Enter Line item data.

    Enter Line item data

    So here you will enter the line item details like desktops, laptops etc. Now, in this case, we don’t have desktops or laptops yet in the system. I know some materials, so I’m going to enter them here.

    Enter Material Details

     

    I entered material, quantity and hit enter. It will populate the material details with a description. You can enter more line items.

    populate the material details

     

    Now, we will enter the PO number and hit enter. As soon as you hit enter the system validates things. If there is an error, for example, say if you enter some wrong data, raw material, some random number that doesn’t exist. The system is going to look at the database behind the scenes and say, hey, this material is not defined.

     

    So now just click on the save button and look at the left bottom corner here, inquiry 10000006 have been saved.

    Inquiry successful creation

     

    This is called an inquiry number.

    And this is the number that we were referring to in our picture as inquiry number 10000006.

    Now this is what we’re going to give to Wal-Mart and say, you know what, this is the inquiry that we have created from SAP. Thank you very much for your inquiry.

    So this is how we create an Inquiry and an inquiry number is generated.

  • Invoice

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

    Introduction

    After the sales have happened and after the logistics processes, which is physically delivering the goods, have happened and the truck has left the warehouse, you can start to invoice the customer.

    If you take a case of Amazon, you go select the product, you pay and then get the order number. This is typically the case with any B2C physical deliverables. You can take Wal-Mart retail sales. Anybody walks into Wal-Mart, buys a product, you give the product, the sales clerk scans it, generates a bill, you pay, you walk out.

    Now, this is B2B we are talking about, the sale between Wal-Mart and HP. Wal-Mart sends an order. HP takes the order, delivers the order, and then after the delivery, it bills Walmart. In the meanwhile, the delivery would have happened or it might be in between.

    That’s a difference in how billing happens between B2B and B2C scenarios.

     

    What is invoice or billing?

     

    Billing is as simple as how Walmart generates a bill for you. There are these products that you have asked for, some desktops, some laptops, what not quantities. However much has been delivered, we’re going to bill them. Let’s say we have only delivered 95 laptops and 15 desktops. So we are going to bill for 95 laptops and 15 desktops. And what do you do after billing, you generate a bill or an invoice which says customer Wal-Mart these are our products, these are the prices which will include taxes, freight discounts, etc. Then finally sent a copy to Wal-Mart saying, this is what we have delivered and this is what you need to pay us.

     

    So billing is an itemized selection of what has been shipped based on the customer’s order and how much the customer needs to pay. This is where the dollar value comes in.

     

    Now, in the next article, we’re going to create an invoice or billing for the delivery that we have just PGI.