Category: ODATA

  • How to Register SAP OData Service in /IWFND/MAINT_SERVICE

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

    Introduction

    Once we have created an OData in SEGW. The very next step is to register the OData. After registering only we can access the SAP OData service. By registering, we mean we open our service to the internet. We can Register the service in two ways:

    • From the transaction SEGW
    • From the transaction /n/IWFND/MAINT_SERVICE

    Steps to Register an OData service using SEGW

    Once the OData is generated, now it is the time to register the service. Once the service is registered, then only it can be used anywhere.

    To generate an OData, follow the given steps:

    1. Double click the node Service Maintenance
    2. Select any System and click Register as shown below:
      OData Service Register
    3. Enter an Alias, if asked as shown below:
      OData System Alias
    4. Now, in the next screen you get following options:
    Field Description
    Technical Service Name This is auto generated service name
    Service Version It is auto generated service version
    Description It is the Description of the OData you have mention earlier
    External Service Name It is same to the auto generated service name
    Namespace It is by default bank
    External Mapping ID It is by default Empty
    External Data Source Type It is by Default set to source type C
    Technical Model Name It is auto generated Model Name
    Model Version It is auto generated Model Version
    Package Assignment Assign your package name here, or just choose Local Object from the button below. It will be then $TMP
    ICF Node It is by default “Standard Mode”
    oAuth Enablement It provides option to add extra authentication, in case you need oAuth2 enablement choose it, else leave it blank

     

    In our case, we just need to choose package and click confirm, as shown below:
    OData Service Registration

    Once the service is registered, the Registration will turn green, as shown below:
    OData Service Status

    Test the OData service

    1. To test the OData service, click the SAP Gateway Client button, as shown below:
      OData Test Service
    2. It will open a new screen, here click Add URI Option as shown below:
      OData Add URI Option
    3. Choose $metadata, here:
      OData $metadata
    4. Click Execute as shown below:
      OData Service Status 200

    If the status is 200, as shown above, then it means your OData is working fine.

    Steps to Register an OData service using /IWFND/MAINT_SERVICE

    1. Open the Service Maintenance Screen using the transaction /IWFND/MAINT_SERVICE. The given screen will open:
      Open the Service Maintenance Screen
    2. Click “Add Service” button. It will open “Add Selective Services” popup.
      Click “Add Service”
    3. Filter your service by entering it in the field “External Service Name” as shown below and click the search icon.
      Filter your service
    4. Now, the above search will return your OData Service name. Select your service and click Add Selected Service
      Select your service
    5. Now, assign your package name to the Service as shown below. In case, you don’t have package name, either click on “Local Object” or write $TMP in the package assignment. Then, save the above settings.
      Assign your package name to the Service
    6. Now, a pop up will open saying “Service <your service name> was created and its metadata was loaded successfully
    7. Now, go back to the transaction /iwfnd/maint_service and filter your service again. This time select your service and select SAP Gateway client
      select SAP Gateway client

    The Filter will open this popup, enter your details here and click execute (the green button).

    enter your details

    Then, follow these steps:

    follow these steps

    1. Here, test your service by following the steps given below:
      1. To test the OData service, click the SAP Gateway Client button, as shown below:
        OData Test Service
      2. It will open a new screen, here click Add URI Option as shown below:
        OData Add URI Option
      3. Choose $metadata, here:
        OData $metadata
      4. Click Execute as shown below:
        OData Service Status 200

    If the status is 200, as shown above, then it means your OData is working fine.

    Error Resolution

    In case you get an error while testing. It might be due to the wrong configuration, or a few nodes are inactive.

    To activate nodes, you need to visit T-Code SICF and search your service. Whatever result you will get, right-click on each and click “Activate”.

    In case you are still getting the same error of Node Activation “Check the ICF nodes in Tx SICF: At least one node is inactive.”, that might be because your server doesn’t have HTTPS enabled. To configure that, you need to visit T-Code RZ10. Check these blogs for the same: Error Explanation, Error Resolution.

    Tutorial Video

    You can watch the below video to learn implementation:

    [embedyt] https://youtu.be/2rEZrFj2haE?list=PLlZBMkVFeev4mdT2qpbUHTmZh4JMwrLqe&t=691[/embedyt]
  • How to perform OData Query and CRUD operation in OData

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

    Introduction

    In previous articles, we have discussed What is an OData and how to create an OData in SAP. We have also shown how to test an OData if it is working fine or not. Now, we need to learn how to read a table using an OData Query and also perform operations like Insert, Update and Delete on that table. In this article we will also learn basic queries of reading data.

    How it works

    In case of OData, there are three phases of data transfer. These are:

    1. Sending Data from Frontend

    Data is sent from UI (Client) to OData (Server) in form of query

    2.      Taking Data from Frontend

    At OData we receive data from Frontend using data provider (Code implemented in CRUD Operation section)

    io_data_provider->read_entry_data(IMPORTING es_data= ls_entity).

    3.      Sending Data to Frontend

    From OData we send data to UI using et_entityset or er_entity after data manipulation (Code implemented in CRUD Operation section)

    The above steps are shown in the image below:

    How to perform OData Query and CRUD operation in OData

    Operations in ODATA

    In this section, we will explore all the methods generated automatically, once you generate an OData. In last article, we have already instructed to write all your CRUD operations related code in DPC_EXT class. Hence, we will follow the same concept here.

    SAP ABAP OData provides different methods for CRUD operations, these are:

    Method SQL Operation Description
    GET_ENTITY Select This method is used to read a single data based on table keys
    GET_ENTITYSET Select This method is used to read entire data of a table
    CREATE_ENTITY Insert This method is used to create/insert a new data in table
    UPDATE_ENTITY Update/Modify This method is used to update an existing data in table
    DELETE_ENTITY Delete This method is used to delete an existing data in table

     

    Query in SAP OData

    In this section, we will explore all the Query we can perform while reading data from OData. In above section, we have learnt how to do read calls using GET_ENTITY and GET_ENTITYSET. Sometimes, we need to filter out data according to our requirement, or to get total number of data counts or to get data in specific order. These all SAP OData Queries are explained below:
    Here, let us suppose <your service name>  = https://isd.sap.com/<OData Service Name>

    Query Description Example
    $metadata It gives the metadata detail of your service. By metadata we mean it will provide information about all the entity sets with their field names and their attributes <your service name>/$metadata
    $FILTER It is mainly used during Read Entity Set call. During Read, we can send some filter value in backend that can be later used in where condition of Select queries <your service name>/$FILTER
    $top and $skip It is mainly used to get limited data in the UI, in case you are reading all the data, and the table is having a very large data <your service name>/$top and $skip
    $orderby This is used to order the data in ascending or descending order for a specific key <your service name>/$orderby
    $format=json This returns the data in form of JSON format. By default, the result is in XML format. <your service name>/$format=json
    $inlinecount This returns the number of data of a table that will appear in the UI <your service name>/$inlinecount
    $expand This is used to bind the association and navigation data together <your service name>/$expand
    $value This is used to return the media data <your service name>/$value

    Tutorial Video

    You can watch the below video to learn implementation:

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

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

    Introduction

    In our previous article, we have already discussed what an OData is. In this article we will go through step by step process to create a SAP OData service. Later on, we will register our service and also test if it is working fine. In this article, we will not write any code related to CRUD (create, write, update and delete). To learn CRUD in OData, click here.

    Step by Step Process to create SAP OData service

    In this section we will follow multiple predefined steps to create an OData, these are:

    1. We will use SAP Service Gateway Builder (SEGW) to create a new project
    2. We will Import DDIC/CDS or other Structure to create an OData Model
    3. We will Generate our OData
    4. We will Register and test our Service

    Create a new Service Builder project

    To create a new project, follow the given steps:

    1. Go to transaction code SEGW, it will start the Gateway Service Builder.
    2. Click on the Create Project button, as shown below:
    3. Enter the given information
    Field Description Example
    Project It is the name of your SAP OData Service. It will start with Z or Y ZPROJECT_NAME
    Description Enter a description for your OData Demo OData Project
    Project Type SAP Provides given four Project Options:

    1.       Service with SAP Annotations

    2.       Service with Vocabulary-Based Annotations

    3.       Annotation Model for Referenced Service

    4.       OData 4.0 Service

    We will learn about them in details, later.

    Service with SAP Annotations

     

    Generation Strategy It will be preloaded as Standard which means, it has all standard configurations. Standard
    Package Enter your project package or temporary package i.e. $TMP $TMP
    Person Responsible It will be preloaded with your User ID/ User Name barryAllen

    OData creation

    1. Press Continue and Save.

    Import a DDIC structure

    To use an OData Service, it should be designed in such way that it will read/update one or more table. Therefore, we need to import any table, structure or view. These are part of DDIC structure. We can also import Data model from file, RFC/ BOR Interface or a search help. But in this section, we will learn how to import a DDIC structure:

    1. Click on the Data Model under the project we have recently created to expand it.
    2. Right Click on Data Model and click Import and then click DDIC Structure
      OData DDIC Import
    3. Now, a Wizard will open. Enter the following details, there:
    Field Description Example
    Name Enter a name of Model. It should be explanatory. CustomerData
    Type We have two options here:

    1.       Entity Type: This means a simple DDIC structure/table/view will be imported

    2.       Complex Type: This means a complex DDIC structure/table/view will be imported

    Choose Entity Type
    ABAP Structure Choose your required table or structure name. Just copy and paste the name of your DDIC table/structure/view zcustomer_data
    Create Default Entity Set It will create an Entity Type with the same fields as of Entity. Also, the name will remain same. We recommend you to leave it check marked. Leave it check marked

     

    The above details are shown below:
    OData Entity Set Creation

    1. In the next step, the wizard will show all the fields of the imported table. Just select them all and click next as shown below:
      OData Entity Set Creation2
    2. In the next step, the wizard will show all the checked fields. Here you need to check the primary keys and finish, as shown below:
      OData Entity Set Creation3

     

    Generate OData Service

    Now, we have created an OData object with a model. Now to use this Object we need to generate all the required classes. To generate, press the Generate Runtime Objects  OData Generate Icon button, as shown below:

    OData Generate Runtime Objects

    Note: The Generate Runtime Objects button automatically saves the project before generating classes.

    Pressing the above button, will open a dialog box as shown below:

    OData Class Generation

    Just press Continue, as shown above. The above process will generate following classes:

    Class Name Description
    MPC Class MPC stands for Model Provider Class. This is generated and refreshed every time, we generate a class. It is not recommended to extend this class for Model Annotations, because all the methods are deleted whenever the OData is generated.
    MPC EXT Class This is the Extended MPC class, and all the methods are conserved even the OData is generated.
    DPC Class DPC stands for Data Provider Class. This is generated and refreshed every time, we generate a class. It is not recommended to extend this class for CRUD operation, because all the methods are deleted whenever the OData is generated.
    DPC EXT Class This is the Extended DPC class, and all the methods are conserved even the OData is generated.
    MDL Class The is the Model Class.
    SRV Class This is the Service Class.

     

    Just click on Lock Object to generate the classes, as shown below:

    OData Service Generation

    Register SAP OData using the Gateway client

    Once the OData is generated, now it is the time to register the service. Once the service is registered, then only it can be used anywhere.

    To generate an OData, follow the given steps:

    1. Double click the node Service Maintenance
    2. Select any System and click Register as shown below:
      OData Service Register
    3. Enter an Alias, if asked as shown below:
      OData System Alias
    4. Now, in the next screen you get following options:
    Field Description
    Technical Service Name This is auto generated service name
    Service Version It is auto generated service version
    Description It is the Description of the OData you have mention earlier
    External Service Name It is same to the auto generated service name
    Namespace It is by default bank
    External Mapping ID It is by default Empty
    External Data Source Type It is by Default set to source type C
    Technical Model Name It is auto generated Model Name
    Model Version It is auto generated Model Version
    Package Assignment Assign your package name here, or just choose Local Object from the button below. It will be then $TMP
    ICF Node It is by default “Standard Mode”
    oAuth Enablement It provides option to add extra authentication, in case you need oAuth2 enablement choose it, else leave it blank

     

    In our case, we just need to choose package and click confirm, as shown below:

    OData Service Registration

    Once the service is registered, the Registration will turn green, as shown below:

    OData Service Status

    Test the OData service

    1. To test the OData service, click the SAP Gateway Client button, as shown below:OData Test Service
    2. It will open a new screen, here click Add URI Option as shown below:
      OData Add URI Option
    3. Choose $metadata, here:
      OData $metadata
    4. Click Execute as shown below:
      OData Service Status 200

    If the status is 200, as shown above, then it means your OData is working fine.

    In upcoming articles, we will learn how to perform CRUD operation using OData.

    Tutorial Video

    You can watch the below video to learn implementation:

    [embedyt] https://www.youtube.com/watch?v=2rEZrFj2haE[/embedyt]
  • What is SAP OData

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

    Introduction

    If you plan to expose your SAP Data (Table or Query Data) to external environment like UI5/Fiori or HANA, then you need to push your data in a form of API. By API we mean, using OData we will generate a service link that can be accessed via internet and can be used to perform CRUD operations. SAP OData in SAP ABAP environment is just like another ABAP Class. We can access the methods of this class using SEGW transaction. We can write our required code here for the data manipulation and once we activate the class, the service link that we generate will act accordingly.

    Definition

    SAP OData is a standard Web protocol used for querying and updating data present in SAP using ABAP, applying and building on Web technologies such as HTTP to provide access to information from a variety of external applications, platforms and devices.

    In SAP, we use SEGW transaction code to create an OData Service. SEGW stands for Service Gateway.

    Architecture of SAP OData

    Here, we will discuss about the High level architecture of SAP OData.

    SAP OData High Level Architecture
    SAP OData High Level Architecture

    Why we need ODATA

    SAP OData comes with multiple advantages. It not only helps us to expose data but also helps a customer to access data from anywhere and any device. If there will be no OData services, then the data will remain on premise and in case a user needs to access their data, they might have to visit the data location, which is uncomfortable for the digital world.

    Advantages of an ODATA

    Using SAP OData provides us following advantages:

    • It helps to obtain human readable results i.e. you can use your browser to see the output data
    • It is very easy and relatively fast to access data
    • It uses all the standards of web protocols i.e. GET, PUT, POST, DELETE, and QUERY
    • It uses Stateless Applications: It means Server does not save any data of Client (e.g. UI5 Application) and treats every OData call as a new call
    • It receives data in form of related pieces of information, one leading to another: It is an interaction pattern known as “alert-analyse-act”, “view-inspect-act”, or “explore & act”. According to this pattern not all data are loaded together, and a user analyses a data and reaches its required information after navigation. In this way the data loads quickly and correctly.

    SAP OData V2 (Version 2)

    OData v2 is a set of new standards which are add-ons to SAP OData V1, and these are as follows:

    • Client-side sorting and filtering
    • All requests can be batched
    • All data is cached in the model
    • Automatic Message handling

    You can read more about SAP OData v2 vs OData v1 here.

    SAP OData V4 (Version 4)

    OData v4 is the latest upgradation to the SAP OData services which comes with some addition and some reduction of features, such as:

    • The new version brings simplification in terms of data binding. The new OData V4 model simplifies the data binding parameter structure.
    • OData v4 requires only asynchronous data retrieval.
    • The Batch groups are solely defined via binding parameters in the new OData v4 calls with the corresponding parameters on the model as default.
    • It supports use of an operation binding. And now it is much easier to bind operation execution results to controls.
    • Create, Read, Update and Delete (Remove) operations are available implicitly via the bindings
    • In OData v4, the Metadata is only accessed via ODataMetaModel

    You can read more about SAP OData v4 vs OData v2 here.

  • What are Restful Web Services

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

    Introduction

    In our previous article we have discussed what is an API. There are different types of API calls e.g. Simple Object Access Protocol (SOAP), Remote Procedure Call (RPC) and Representational State Transfer (REST). All these API calls have same purpose i.e. to transfer data securely among two or more systems. In this article we will only explore the Restful Web Services.

    What is REST

    As stated earlier, REST stands for Representational State Transfer. It is a simple way of sending and receiving data between client and server. It doesn’t require any software or standards to transfer data. It has a predefined structure to do the API call. Developers just need to use the predefined way and pass their data as JSON payload.

    Restful Web Services

    Attributes of Restful Web Services

    A RESTful web service has following six constraints/attributes:

    1. Client-Server: It is a very important aspect of REST APIs. A REST API follows client-server architecture and these both should be separate. It means both the server and client can not be same server. In case it is same, you will receive CORS error.
    2. Stateless: In REST, all calls are treated as a new call and any previous call state will not give any advantage to the new call. Hence during each call, it is required to maintain all the necessary authentication and other information.
    3. Cache: A REST API encourages the browser and server caching process to enhance its processing speed.
    4. Uniform Interface: The interface between the Client and Server remains uniform, hence any changes in either side will not affect the API functionality. This help in development of Client and Server system independently.
    5. Layered System: REST allows usage of layered structure in server side i.e. you can have data on different server, authentication on different server while the API on different server. The client will never come to know that it is getting the data from which server.
    6. Code on Demand: It is an optional feature of REST API where server can even send executable code to the client that can run directly during run time.

    Methods in Restful Web Services

    Using Restful web services, we can perform these basic four operations:

    1. GET: This method is used to get a list of data from server.
    2. POST: This method is used to post/create a new record in server.
    3. PUT: This method is used to update an existing record of server.
    4. DELETE: This method is used to perform deletion of a record at server side.

    Note: Just calling the above method doesn’t guarantee that the operations will be performed until these operations are implemented at the server side too.

    Advantages of Restful Web Services

    Following are the major advantages of a RESTful API:

    • They are simpler and flexible to implement
    • It supports greater variety of data formats e.g. JSON, XML, YAML, etc.
    • It is faster and provides better performance

    Disadvantages of Restful Web Services

    Although REST services tend to provide multiple benefits, still it has given demerits:

    • To implement state related query the REST Headers are required which is a clumsy work
    • The PUT and DELETE operations are not usable through firewalls or in some browsers.
  • Differences between Constructor and Class Constructor

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

    Before discussing the difference between Constructor and Class Constructor, let’s have a short introduction of the two.

    Introduction

    Constructors are a special type of method in a class that is called automatically by the system to set the initial state of a new object or the class. They cannot be called using the CALL METHOD statement. The constructors are always present in a class but to implement a constructor it must be declared explicitly with the METHODS or CLASS-METHODS statements.

    There are two types of constructors: Instance constructor and Static Constructor.

    Constructor

    The predefined method CONSTRUCTOR is an instance constructor of the class.  This instance constructor is automatically called when an instance of the class is created. Its signature can have only importing parameters or exceptions. Since it is an instance method, it can access all the attributes of the class.

    Syntax to declare :

                    METHODS : constructor.

    Class Constructor

    The predefined method CLASS_CONSTRUCTOR is a static constructor of the class and is automatically called when the components of the class are accessed for the first time. Its signature cannot have importing parameter or exceptions.  It is called once for each class irrespective of the instance created.

    Syntax to declare :

                    CLASS-METHODS : class_constructor.

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

    Constructor and Class Constructor

    Differences between Constructor and Class Constructor

    Constructor Class Constructor
    It is executed automatically whenever an object is created or instantiated. It is executed automatically whenever the first call to the class is made.
    It is called once for each instance. It is called only once for each class and internal session.
    It is declared using METHODS statement. It is declared using CLASS-METHOD statement.
    It has only Importing Parameters. It has no Importing and Exporting Parameters.
    It can raise exception. It cannot raise exception.
    It is an Instance method. It is a static method.
    It can access all attributes of a class. It can access only static attributes of a class.

     

  • Differences between Call by Value and Call by Reference

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

    Before discussing the differences between Call by Value and Call by Reference, let’ have a quick introduction of the two.

    Introduction

    Modularization techniques in ABAP is a way to write codes in different processing blocks like subroutine, Function Modules and ABAP objects. If these blocks have any parameter interface, while calling them it is required to pass values to all the formal parameter interface. These blocks with parameters can be called via either Call by Value or Call by Reference.

    Call by Value

    In Call by Value, the value of the actual parameters is copied to the formal parameter of the function. The value of the two types of parameters is stored in different memory locations. The memory location of the formal parameter is allocated when the function/subroutine is called and gets freed when the function/subroutine returns. The references to the formal parameter refer to a unique memory and are only known within the function/subroutine. Any changes done inside the function/subroutine are not reflected in the actual parameter.

    Call by Reference

    In Call by Reference, the address of the actual parameters is copied to the formal parameters of the function. The references to the formal parameter reference the same memory as of the actual parameter. Any changes done inside the function/subroutine are reflected in the actual parameter i.e. all the operations are performed on the value stored at the address of the actual parameter, and the modified value is stored at the same address.

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

    call by value and call by reference

    Differences between Call by Value and Call by Reference

    Call by Value Call by Reference
    The value of the actual parameter is copied into the formal parameter. The address of the actual parameter is copied into the formal parameter
    Both the parameters are stored in different memory locations. Both the parameters refer the same memory location.
    The change in formal parameters is not reflected in the actual parameters. The change in formal parameters is reflected in the actual parameters.
    Original value cannot be changed. Original value is changed.

     

  • How APIs work

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

    Introduction

    Everything is online nowadays. From grocery website to online medical services, we can do anything and everything right from our home with the help of any electronic device such as laptop, PC or mobile. Have you ever wondered that how the App or the website you visit understands you and processes your payment. This all happens with the help of different APIs. In this article, we will learn all about APIs. All the OData servies are also an example of APIs.

    What is an API

    An API stands for Application Programming Interface. As the name suggest, an API is an interface between two applications. These are the programs written in such a way that they accept certain inputs, process them and returns an output.

    E.g. We can create an API which can accept two numbers and return their sum. It sounds crazy to do such basic job, but it is just an example.

    How APIs Works

    To better understand this flow, we will illustrate the same using step by step process, as shown below:

    How API Works

    The API is triggered by a script code in UI, in our case UI5/FIORI App. The call is in the form of either of any CRUD operation. In case of Read calls, the returning response consist of JSON data. In case of Create, Update and Delete operations, the response is just a status where 200/201 represents success. We will study more about API Response codes in upcoming article.

    An API is in the form of a URL i.e. Uniform Resource Locator.

    Example: https://service_name/payload

    An API contains the following:

    • HTTP Request: It defines which CRUD operation is being called. E.g. GET is for Read call and POST is for Create call
    • Service Name: It can be your website name or any other registered service name. In case of OData it varies with the OData name.
    • Payload: In case of Create, Update and Delete call, payload is an object sent to the API
    • Response: This is a status with response data. The status represents if the API call was successful or not.

    Example:

    In real world, we can take an example that the API accepts Credit Card details with an amount to deduct, process deduction and returns success status. These types of APIs are widely used by payment gateway industries. The same is illustrated in the GIF below:

    APIs

    Advantages of an APIs

    • It helps in abstraction of Data between two systems
    • It reduces the duplication of code and architecture and enhances modularity
    • It reduces the coding language dependency as any two systems using different coding languages can be connected via an API
    • It reduces rework and enhances code quality as well as readability
  • ODATA in ABAP

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

    In this article we have just mentioned imported keys related to ODATA in ABAP. To learn OData in detail view our OData tutorial here.

    Index

    • What is ODATA? Why we need it?
    • How to Create an ODATA Service?
    • Exploring ODATA
    • CRUD Operation via ODATA
    • Calling CLASS, FM in ODATA
    • Checking your Service: CRUD

     

    Exploring ODATA

    • Data Model
    • Entity Types
    • Association
    • Entity Sets
    • Vocabularies
    • Service Implementation
    • Runtime Artifacts
    • Service Maintenance

     

    What is ODATA

    • ODATA stands for Open Data.
    • It was created by Microsoft
    • Based on REST API.

    Definition:

    ODATA is the representation of Data in form of XML/JSON.

    • XML for ios based device, JSON for Android based device.

     

    Why ODATA

    • To communicate between different Interfaces

     

    How to create ODATA

    • Go to SEGW.
    • Create a new project
    • Import a DDIC Structure
    • Redefine the methods
    • Generate your ODATA
    • Register your Service

     

    Data Model

    • A Data model can be anything : A table, A structure, A View.
    • When we import a DDIC structure, its Entity Types, Entity Sets, Service Implementation, Runtime Artifacts are created automatically.
    • A Data Model is the one that decides on which fields the CRUD operations will be performed

     

    Runtime Artifacts

    • DPC& DPC_EXT
    • MPC & MPC_EXT
    • The mentioned above are four classes generated by SAP. We only redefine methods of EXT classes, because the codes written in DPC and MPC are provided by SAP, and will override our codes once ODATA is generated.
    • In DPC_EXT we perform CRUD operations
    • IN MPC_EXT we write annotations.
    • Annotations are the extra functionality we want to achieve that is not provided by SAP by default.

     

     

    Operations in ODATA

    • CRUD Operation
    • Same codes that we write in ABAP report will be written here
    • Calling FM & Class
    • Same codes that we write in ABAP report will be written here
    • Taking Data from Frontend:
    • io_data_provider->read_entry_data(IMPORTINGes_data=wa_entity).
    • SendingData to Fronend:
    • et_entitysetor er_entity.

     

    Check your Service via Service Maintenance

    1.To read all files just open your entity and click GET and press Execute

    2.To read one file -Write the primary keys in bracket just after the URI as mentioned here: (ACQ_ID=’NEW1′,BUKRS=’7070′).

    3.To Create, you need to read one file. After reading, click USE AS REQUEST. Change the values of primary keys and other fields you want, click POST Radio Button, remove the Primary keys from URI and click Execute.

    4.To Update Perform Step 02, Click Use as request, just change the fields other than primary keys, Click PUT Radio Button, and Execute.

    5.To Delete, perform Step 02. Click Delete Radio Button, Execute.

     

    What’s Next?

    • Association
    • Vocabularies
    • MPC_EXT
    • Mapping : CDS Views
    • Batch Operation
    • Function Import
    • SICF : Getting your Service Link
    • Whitelisting your Service

     

    Reference: