ABAP on Cloud – 7 – Insert Records through Class and Create Metadata Extension

Let’s start where we left off in the previous article, just for a change! Please take a moment to read our previous article, then come back here to get the full tale.

When you double-click the wrench icon, a new window containing the ZEMP_DTLS table’s technical specifications emerges.

We can add the data class, size category, storage type, buffering, and other features, just as in conventional ABAP. We can also specify the Log Changes.

Buffering: Since we are aware of the precise kind of action being carried out, this version of ABAP is far better than the traditional one.

How can the entries be added to the database? Through ABAP Course?

First step:

Select “Other ABAP Repository Object” with a right-click on your ABAP Cloud Project.
After expanding “Source Code Library,” choose “ABAP Class.” Select “Next.”

Step 2:

After entering the name and description, click “Next.” Choose the standard TR. Complete.

Step Three:

Take note of the Global Class section and the Class-relevant Local Types tab.

Worldwide Class

As is common knowledge, the section must contain all necessary data, such as the definition of the class, methods, and parameters (for importing, exporting, updating, and returning).

Section 1: Fixed Techniques

The following variations of the statement “CLASS-METHODS distinguish different types of method declaration” are listed in the SAP documentation:

  • Generally used static techniques
  • Any number of input and output parameters can be defined for static methods in classes and interfaces using the most general form of the CLASS-METHODS statement.
  • Static Functional Approaches
  • Classes and interfaces’ functional methods can have any number of formal parameters and have precisely one return value.
  • Constructors that are static
  • Methods with the preset name class_constructor that are automatically called before their class is used are known as static constructors of classes. Static constructors cannot be expressed in interfaces and lack a parameter interface.
  • Event handlers that are static
  • The static methods of classes and interfaces that get called when a class or interface event occurs are known as static event handlers. An event handler’s formal parameters are limited to input parameters.

Section 2: Dynamic Methods

As can be observed in the ABAP documentation, the various instance method variations are as follows.

Methods for general instances
It is possible to define instance methods with any combination of input and output parameters using the general version of the METHODS statement.

Practical instance techniques
Functional methods can take any number of formal parameters and have precisely one return value.

builders of instances
When a class is instantiated, methods with the name constructor are called automatically; these are known as instance constructors. Constructors don’t have any output parameters and can have any number of input arguments. In interfaces, they cannot be declared.

Event coordinators
Although they can be called directly from statements or within statements, event handlers are primarily called in response to an event triggered by an interface or class.

Step 4:

After defining an interface, put a method into practice.

We must use the crucial “if_oo_adt_classrun” interface in order to add new entries and see the status.

Step 5:

To insert records, add the necessary code.

Step 6:

Run Program F9

A few things to note here:

Unlike standard ABAP, we are operating without a GUI or selection screen to view the output.
Here, we have an object known as CONSOLE that records the necessary output.

A basic internal table is declared in our code.
New values are included.

There’s one thing that matters here. Zempid = cl_system_uuid=>create_uuid_c32_static() is what we’re using.
For those in the know, this is hardly a novel idea. Please let us know if you are unsure.

Put written statement here.
Ultimately, the success message appears in the console thanks to out->write(‘Success’).

Thus, this is among the MOST IMPORTANT example codes that can be utilized wherever in the ABAP Cloud where CODE ALONE is required to manipulate data.

In the interim, until a Fiori App is ready, this is the appropriate course of action for adding, editing, and removing records.

Step 7:

Verify that records have been added to the database table.

F8 is the shortcut to launch the DB Table data preview.

Exactly right! A record is made.

Again you see we have done wonderful job so far!!!

Step 9:

Yes, a database table was created. Completed. Click this.

Access Control for Data: False. Let us ignore this for the time being.

We are able to manage both this and the authorizations topic.

Extension of Metadata – No. Next Subject!!!

Definition of Behavior – No. Next Article

Next Article: Behavior Implementation – No.

Let’s try to be fair now. Let’s add some metadata extensions to give the view more strength.
Choose “Core Data Services” -> New -> Metadata Extension with a right-click.
Alternatively, right-click the package and select “Core Data Services” -> New -> Metadata Extension -> New -> Other ABAP Repository Object.

then, Next -> Next -> Finish.

Step 10:

Put in the code as shown below:

@Metadata.layer: #CUSTOMER
@UI.headerInfo: { typeName: 'Employee Detail',
typeNamePlural: 'Employee Details',
title.value: 'zempid',
title.criticality: 'zempdesg'
}
annotate view Z_I_EMP_DTLS
with
{
@UI.facet: [{ id : 'zempid',
              type: #IDENTIFICATION_REFERENCE,
              label: 'Employee Details'}]  
@UI.lineItem: [{position: 10, label: 'Employee ID'}] 
@UI.identification: [{ position: 10, label: 'Employee ID' }]  
zempid;

@UI.lineItem: [{position: 20, label: 'Employee Name'}] 
@UI.identification: [{ position: 20, label: 'Employee Name' }]
zempname;

@UI.lineItem: [{position: 30, label: 'Employee Designation'}] 
@UI.identification: [{ position: 10, label: 'Employee Designation' }]
zempdesg;

@UI.lineItem: [{position: 40, label: 'Employee Gender'}] 
@UI.identification: [{ position: 10, label: 'Employee Gender' }]
zgender;

@UI.lineItem: [{position: 50, label: 'Employee Salary'}] 
@UI.identification: [{ position: 10, label: 'Employee Salary' }]
zsalary;

@UI.lineItem: [{position: 60, label: 'Salary Currency'}]
@UI.identification: [{ position: 10, label: 'Salary Currency' }] 
zcurrency_key;
}

Turn on. by pressing Ctrl + F3.

Was there a logical conclusion to the article? Have we overlooked anything?

It goes without saying that the code contained in the metadata extension and its annotations need to be addressed. These are critical because they allow ABAP to become a UI (proxy) Expert.

Have fun coding and don’t stop asking questions! Recall that there are numerous unresolved issues in the essay that need to be addressed.

We hope that our astute insights will highlight a few points; please include them in the comment area.

Please leave a comment!

WSDL file in SAP – Part I

  • Related Posts

    SAP XI/PI – Invoice Attachment Transfer from ARIBA to VIM

    The documents that are connected to the invoice in the Ariba Network system should be transferred to the VIM system via PI Integration as part of the Ariba Supplier Invoice…

    Attachments for SAP XI/PI – ARIBA Invoices sent via PI to S/4HANA

    Integration with SAP systems has never been more intriguing, especially with Ariba, Workday, Concur, Successfactors, Fieldglass, Hybris, and other satellite cloud solution vendors banging on doors every day. 🙂 I…

    Leave a Reply

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

    You Missed

    SAP XI/PI – Invoice Attachment Transfer from ARIBA to VIM

    • By Varad
    • November 8, 2024
    • 2 views
    SAP XI/PI – Invoice Attachment Transfer from ARIBA to VIM

    11 Steps to Include a New Field in an Already-Existing SAP LSMW Batch Input Recording

    • By Varad
    • November 6, 2024
    • 3 views

    Part 23 of ABAP for SAP HANA. How Can AMDP Be Used to Access Database Schema Dynamically?

    • By Varad
    • November 4, 2024
    • 3 views

    S/4HANA VDM 1 Employing CDS Virtual Data Model for Embedded Analytics

    • By Varad
    • November 1, 2024
    • 5 views