SAP ABAP:

ABAP stands for Advance Business Application Programming and is the programming language supported on the SAP NetWeaver. Programmers can use procedural, object-oriented, and other programming ideas with ABAP because it is a multi-paradigm programming language from SAP. Although ABAP is SAP’s main programming language, it may coexist with programs created in other languages including Java, JavaScript, and SAPUI5.

Important of SAP ABAP:

ABAP is tightly connected with other SAP NetWeaver ABAP application server functionalities and does not operate in a vacuum. These include the following:

  • Logical database connections, which enable the abstraction of code from a particular database. The actual database connections are set up separately from the ABAP code, enabling the use of the same code across several database systems.
  • Open SQL, a subset of native SQL that is appropriate for the database being used and is an abstraction of the SQL syntax that is a part of the ABAP language. The Language Integrated Query (LINQ) ideas from Microsoft.NET and Open SQL are very similar.
  • Internal tables, which store groups of objects that can be accessed via Open SQL or special language keywords. Contrast this ABAP idea with the idea of typed arrays found in languages like Java or C++.
  • ABAP Dictionary is a system-wide dictionary of data structure definitions that is accessible to all ABAP programs and frequently includes business logic.
  • The Change and Transport System (CTS) monitors changes to development objects and regulates the promotion of development objects to environments for production and quality assurance. A key feature of ABAP that sets it apart from other newer languages is its shared development system, which enables all developers to work simultaneously on the same set of development objects.

 What is RESTful API?

An RESTful API (Representational State Transfer Application Programming Interface) is a collection of standards that enables the communication between two applications. REST APIs follow a specific methodology for creating APIs. They are built on the HTTP protocol and use URIs to send and receive JSON or XML data (uniform resource identifier). The ability to GET, PUT, POST, and DELETE data using that data. Less code RESTful ABAP Programming model is used to develop Fiori application.

Advantages of using ABAP RESTful Application Programming:

  • Faster, Scalable APIs that Support all data types.
  • Easier to develop, use and connect.
  • It has client-service constraints.
  • It completely vanish the use of interface description language (IDL) because it is driven by Hypermedia to understand the response send by the service.
  • For each CRUD (create, read, update, delete) operation between server/client and vice-versa in RESTful API self-descriptive messages are driven back and forth to have a clear understanding of the need of the client and the response of the server.
  • RESTful APIs are stateless hence they will not store any client data, which the lead on the server database is reduced.
  • Cache ability of the server is used for the client information when the client asks for any information which is already in the cache of the server it is communicated to the client.
  • It is easy to communicate with all the layered systems irrespective of R/3 or R/4 tier architecture
  • RESTful API support all types of data formats. Eg: JSON, and XML.
  • When HTTP Request, get JavaScript Object Notation (JSON) is sent as the response to the client browser which helps in integrating these APIs with the existing website.
  • Lower bandwidth is required by JSON restful APIs compared by other API types.
  • Unlike other APIs, RESTful APIs do not need to be designed from Scratch.
  • All those advantages of RESTful APIs than other APIs make it easier for most of developers to use this API.

ABAP Restful Application Architecture:
ABAP Restful Application Architecture

ABAP Restful programming model Supporting SAP S/4 HANA and SAP BTP ABAP Environment. We are using ABAP programming for SAP HANA. ABAP RESTful application programming model is a modern technology that Included

  • Core data service (CDS) used for the data model.
  • ABAP Programming language used to implement the business logic.
  • OData protocol used for data access.
  • Business Object used to build transactional applications.
  • Business service used to Create OData and SQL-based service.

Are you ready for the demo?

 Let’s see how to execute the CRUD actions on a REST API and run this code on an SAP Cloud Platform trial account.

Let’s Create a Sample Purchase Order management application in the SAP Cloud application programming model Platform.

Basic Configuration and Creation ABAP RESTful Application model using Eclipse:

Step 1: Install ADT (ABAP Development Tool) in Eclipse.

Step 2: Open ABAP Perspective and create an ABAP Project

Step 3: Create a New Package.

Step 4: Create a Sales Order Database table.

Replace your code with the following:

@EndUserText.label : ‘database’

@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE

@AbapCatalog.tableCategory : #TRANSPARENT

@AbapCatalog.deliveryClass : #A

@AbapCatalog.dataMaintenance : #ALLOWED

define table zka_database1 {

key client      : abap.clnt not null;

key purchase_no : abap.int8 not null;

product         : abap.char(256);

@Semantics.amount.currencyCode : ‘zka_database1.currency_code’

gross_amount    : abap.curr(10,2);

currency_code   : abap.cuky;

vendor          : abap.char(256);

}

Step 5: Create Data Model using CDS View. (CDS views work like a business object).

  • Here we can use the data and can be able to manipulate the data as well in the database.
  • UI annotation is a part of the projection view.
  • Using CDS we have domine-specific business objects, which are defined in the ABAP RESTful Application programming model with a keyword called ‘Root’.

Replace your code with the following:

@AbapCatalog.sqlViewName: ‘ZKAKADEFIN’

@AbapCatalog.compiler.compareFilter: true

@AbapCatalog.preserveKey: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: ‘definition’

@Search.searchable: true

@Metadata.allowExtensions: true

define root view  zka_kadefin as select from zka_database1 {

@EndUserText.label: ‘Purchase order no’

@UI.facet: [{

type: #IDENTIFICATION_REFERENCE,

label: ‘purchase order’,

purpose : #STANDARD

}]

@UI.identification: [{position: 1 }]

key  purchase_no as Purchaseorderno,

@EndUserText.label: ‘product’

@Search.defaultSearchElement: true

@UI.identification: [{position: 2 }]

product as Product,

@EndUserText.label: ‘gross amount’

@UI.identification: [{position: 3 }]

gross_amount as Amount,

@EndUserText.label: ‘currency’

@UI.identification: [{position: 4 }]

currency_code as Currencycode,

@EndUserText.label: ‘vendor’

@UI.identification: [{position: 5 }]

vendor   as  Vendor

}

Step 6: Define Behaviour Definition.

  • We can do the transactional capability like insert, update, and delete the business object
    using Behaviour Definition. These are the two approaches,
    1. Managed.
    2. Unmanaged.
    now using the managed approach.
  • In the managed approach implementation of Create, Update and delete code will be automatically generated.

Replace your code with the following:

managed implementation in class zbp_ka_kadefin unique;

//strict ( 2 ); //Uncomment this line in order to enable strict mode 2. The strict mode has two variants (strict(1), strict(2)) and is prerequisite to be future proof regarding syntax and to be able to release your BO.

define behavior for zka_kadefin //alias <alias_name>

persistent table ZKA_DATABASE1

lock master

//authorization master ( instance )

//etag master <field_name>

{

create;

update;

delete;

mapping for ZKA_DATABASE1{

Purchaseorderno = purchase_no ;

Product =  product;

Amount =  gross_amount;

Currencycode = currency_code;

Vendor = vendor;

}

}

Step 7: Define Service Definition.

  • Service definition we can define which data is exposed as a business service.

Replace your code with following :

@EndUserText.label: ‘service definition’

define service Zka_serder {

expose zka_kadefin as PurchaseorderSet;

}

Step 8: Define Service Binding.

  • We can bind service definition to client-server communication protocol using service binding like OData. The service binding is used to generate the SAP Fiori Elements App Preview, which makes the application visible on the UI level.

Save and Activate the Service Binding. Double click PurchaseorderSet Choose Open Fiori elements App Preview. Then it will Open SAP Fiori Application Automatically.

abap-restful-programming-1

List Report Using ABAP Restful Application Model.

sap-cloud-application-programming-model

 

RESTful Application Programming with ABAP on Cloud and S/4HANA On-premises.

Leave a comment

Your email address will not be published. Required fields are marked *