ABAP on Cloud Development – Part 2

1 week ago 3

ABAP on Cloud Development part -2

ABAP (Advanced Business Application Programming), a cornerstone of SAP’s enterprise solutions, has long been trusted for developing robust business applications.
This blog kicks off a comprehensive series designed to guide developers on their journey into ABAP on Cloud development. Our mission is to provide you with the essential knowledge and tools to transition smoothly from traditional ABAP practices to crafting cutting-edge, cloud-based solutions. Let’s unlock the future of enterprise application development together!

If you are eager to get your hands dirty and practice ABAP on Cloud using a BTP trial account, setting up the ABAP trial instance is a straightforward process. Follow these steps to set up your environment and start your journey into ABAP on cloud development.

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

Connect to BTP Trial Account:

Create your own account. You can you use personal email to get this account. Register at sap.com
After creating your account (or if you already have it), go to SAP BTP Trial page, https://account.hanatrial.ondemand.com/ and log in.

Go to the trial account:

Click on the region closet to you or make sense for the datacenter.
Trial Account has one subaccount – trial. This trial account should have one space already created – dev.
Note instantiating the account takes time.
In the dev space, go to the Services > Service Marketplace. Search for ABAP environment.

Then select on the 3 dots and select CREATE. If you already have an ABAP environment subscription, this step is not needed. Enter the Instance name and click on Next to complete the set up.

In the next screen, enter your email id to complete the JSON. Important step – use the email id you are using for the BTP trial account.

Click Finish.
After the instance is created, you should be able to see in the instance page (under the dev space). Click on the three dots and click on “Create Service Key”

Enter the service key name and hit create.

After the key is created.
Now there should be a key here. Click on that.

Click on copy JSON.

Now head to Eclipse.
Click File > New > New ABAP Cloud Project. Select BTP ABAP Environment > Use Service Key.

Now paste the service key and click Finish. Congratulations!!
Click on the Trial Account and Open Logon page in browser.

Note this option leads to default browser. If you have multiple accounts or cannot use the default browser for some reason, select the other option – Copy Logon URL on clipboard and then use any browser.
Enter the logon credentials of the BTP trial account and you should be able to log into the trial account.
The steps are same for the BTP Enterprise account but needs proper authorization at all levels – something you need to coordinate with your team.
Create package and add it to the favorite package. Remember the trial account is shared for all. Having your package will keep everything together and do not share anything which you don’t want on the public domain.

Create RAP application with CRUD:

Create a Behavior Definition
Right click on the root view create and click on New Behavior Definition. Change the description if needed.


Click Next. Choose Transport and Click Finnish.
Enter the following code and click on activate.

Now the Business Object is ready.

Create Projection View and Behavior Projection – zaoc_C_field_Agent_
Projection View Code

Behavior Projection
Right click on the projection view and select New Behavior Definition.

Click Next. Select Transport and click on Finish

Activate
Now create Service Definition and Service Binding as explained in Assignment 1.
Service Definition: ZAOC_FIELD_AGENT_SRV_
Service Binding: zaoc_bind_FA_>unique_id>

Test and troubleshoot the errors.

Adding ABAP Logic:

In the Behavior definition ZAOC_FIELD_AGENT_, change the first line to this implementation in class zbp_aoc_field_agent_trainer unique
Then hover on the left hand side pane which should show a warning and use the warning to autogenerate the class.

Click Next and choose transport and Finish.
Activate the class.
Now go back to Behavior definition and add one more line.

Since this method does not exist, a similar warning (how it we had when class was missing will come) and click on it to prompt for autocreation of the method.

Add this code in the method implementation

Create the message class first and give a message number 001.
Message Class: ZAOC_MSG_CLASS_
Text 001 – Only possible value for status fields are A or I

Autogenerate Objects for UI:

Create a database table. Sample code:

These fields are added for draft to work.
Select the table, right click and click on Generate ABAP Repository Objects. Select OData UI Service and click on Next.

Enter the package Name where you want to save the objects.
Following objects will be created.
Data Model
Behavior
Projection Entity
Projection Behavior
Service Definition
Service Binding.


You can also preview the code.
Hit Next and complete the process.
It will lead to service binding, where you need publish the service and test.

Behavior Definition

Please take time to understand the components.

Association Sample:

Another Sample of Association in CDS

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.

ABAP on Cloud – Practical

Read Entire Article