ABAP on Cloud Development – Part 1

2 weeks ago 3

ABAP on cloud development

In today’s rapidly evolving technological landscape, businesses are increasingly turning to cloud-based solutions to enhance agility, scalability and innovations. As a cornerstone of SAP’s enterprise solutions, ABAP(Advanced Business Application Programming) has been a trusted language for developing robust business applications for decades. With the advent of cloud computing, SAP has extended the capabilities of ABAP to the cloud, enabling enterprises to leverage its powerful features in cloud-native environment. This blog marks the beginning of comprehensive series aimed at guiding developers through the journey of ABAP on Cloud development. Our goal is to equip you with the knowledge and tools necessary to transition seamlessly from traditional ABAP development to creating modern, cloud-based applications.

The steps and technique we will cover in the series can be carried out using the SAP Business Technology Platform (BTP) ABAP trial instance, as well as on S/4HANA on-premise from the 2022 release onwards.
Additionally, these practices are applicable to both private and public cloud deployments of S/4HANA, allowing you to choose the setup the best suits your organisations needs.

Create a package:

Step 1: Select your ABAP (Cloud) Project. Right click, select NEW > OTHER (or ABAP PACKAGE). Select ABAP Package and click on NEXT.

Enter Name, Description, select to “Add to favorite package” and click on Next.

Add Software Component. Click on NEXT.

Enter the Request Description and click on FINISH.

The package is created successfully and it should be visible in your Favorite Packages in Project Explorer.

Create Data Element:

Select the package in the Project Explorer and right-click, select NEW > Other ABAP Repository Object.
Create a data element for First Name.

Enter the name: ZAOC_FNAME_<unique_id>, description, and click on NEXT.

Before we proceed with our tutorial, we would like to give you an opportunity to join our ZAPYard’s learning community where we have more than 35 groups and more than 1600 real SAP Consultants interacting with each other daily. Only SAP topics and not BS. Else, they will be banned from the community without warning. 👇👇👇👇

If you want to be part of ZAPYard’s Discussion Community, please feel free to check the below Link. We Ask, Answer, Help and Learn Together. There are more than 35 groups from different topics like Generative AI, SAP Joule, CAPM, BTP, RAP, BPT, Fiori, iRPA, CAI, CPI, PI/PO, ABAP on HANA, SAPUI5, SAP Build, SAP Adobe Forms, ChatBots, SAC etc. Join any group of your interest and interact with our Community.

Join ZAPYard’s WhatsApp Community – Ask, Answer, Propose & Defend SAP Topics

NEW TRAINING ANNOUNCEMENT

Enrollment Link – CAPM on SAP BTP| Training Starts 8th Feb 2025
Day Wise Course Break Up – CAPM on SAP BTP
Training Dates: 8, 9, 15, 16, 22, 23 Feb, 1, 2, 8 & 9 Mar 2025 IST Dates
Training Time: 7:30 AM to 10:00 AM IST

Join our comprehensive training on CAPM on SAP BTP . For a LIVE, INTERACTIVE Learning experience with an expert Instructor, ENROLL in the course mentioned above.

Now, lets move on to the next topic.

Select or create transport and click on Finish.

Enter Predefined as Category. Data Type = CHAR. Length = 40.

Add Field Labels.
Activate. You should be able to see it in your package.

Create a database table:

We will create a database table now. Name of the table ZAOC_EMPLOYEE_.
Select the package in the Project Explorer and right-click, select NEW > Other ABAP Repository Object. Browse and find database table. Select and click on NEXT.

Enter the NAME, Description and click on NEXT.

Select the transport and click on FINISH.

This code will be coming by default. Lets add more code to it.

Activate. Now you should have a database table which can be viewed from SE11 transaction.

Create a Output program (Class):

Select the package and right-click and click on NEW > ABAP Class. If you cannot see the ABAP Class option. Select the Other ABAP Repository object and type in ABAP Class.
Name of the class: ZCL_AOC_HELLO_WORLD_<unique_id>.
Enter the Name and Description and then click on Add…
Enter IF_OO_ADT_CLASSRUN in the search box and select the Interface. Click Ok to add the interface.

Should look like this. Click NEXT. Enter transport. Click on Finish.

Add following in the method if_oo_adt_classrun~main

Now activate the class. Run the class and you should see “Hello world” in the Console.

This is how an executable program (class) is created in the ABAP on Cloud.

This is how an executable program (class) is created in the ABAP on Cloud.

Now let’s create a class to populate the data in the table which we just created.

Create the class as described above.
Name – ZCL_AOC_DE_EMPLOYEE_<unique_id>.

Add the following code in method if_oo_adt_classrun~main

End of code. You can add more data or change the data if you want to.
Execute the program and now the data should be there in the table.

Create a CDS View:

Select the package and right-click, click New > Other ABAP repository Objects. Select Data Definition under Core Data services and click on NEXT.

Select the transport and click on NEXT (or FINISH).
If clicked on NEXT, select the Define Root View Entity. The template will generate the code.

Final code should look like this:

Activate the code.

Sample CDS Views:

Use the above described method to create the CDS views and the code is given here. With this examples, try to create your own Views as well. Add your own unique ids after the names of the views.

Simple view over MARA table

Join in CDS

CDS View with parameters

Association

Create a Projection View:

Create a CDS View with name: ZAOC_CDSC_EMP_
Follow the previous method to create a view entity.

Choose the transport and then click on FINISH.

Service Definition and Binding:

Select the package, right click and click NEW > Other ABAP Repository Objects. Seach for Service Definition.

Click Next.
Enter NAME, Description and Source Type

Choose the transport and click on Finish.
Enter the following code:

Note here we are exposing the consumption view which we created in previous step.
Activate. With this our service definition is complete.
We need to bind this service.
Select the package, right click and click on NEW > Other ABAP repository objects.
Search for Service Binding

Click on NEXT
Enter the Name and Description, select the binding type and service definition.

In order to find the service definition, click on BROWSE. (or copy paste the name of the service).

After clicking OK, the screen should look like this.

Click on Next. Choose the transport and click on FINISH.

Activate the binding and click on Publish. After publishing, the screen should look like this.
Select employee and click on preview,

On your default browser you should be prompted to log in.

Please try to create another table, view and service binding. You can name as per your wish but please add your unique id somewhere.

If you found this article helpful, we’d love to hear from you! Share your thoughts, questions, or experiences in the comments below, your feedback is always welcome and helps us create even more valuable content for you.

Please follow our LinkedIn PageLinkedIn Group , Facebook PageFacebook GroupTwitter & Instagram.

Do not forget to SUBSCRIBE to our YouTube Channel for Free Courses and Unconventional Interesting Videos.

Do join ZAPYard’s Learning Community.

Read Entire Article