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

    Important T codes for FI GL AR AP

    Details of T Codes Accounting for Finances SPRO Put in the IMG OX02 Company Code to Create, Verify, and Delete OX03. Create Business Area Functional Areas for OKBD OB45 Establish…

    Dynamically Download Data From Any SAP Table in ABAP-740 – Part 1

    A few days ago, one of my SAP BI/BW friends requested a program that would accept any table as input and download it as a file to the local machine.…

    Leave a Reply

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

    You Missed

    Important T codes for FI GL AR AP

    • By Varad
    • December 21, 2024
    • 19 views
    Important T codes for FI GL AR AP

    Dynamically Download Data From Any SAP Table in ABAP-740 – Part 1

    • By Varad
    • December 20, 2024
    • 13 views
    Dynamically Download Data From Any SAP Table in ABAP-740 – Part 1

    Error While Setting Up Trusted System RFC

    • By Varad
    • December 19, 2024
    • 11 views
    Error While Setting Up Trusted System RFC

     Credit Management T codes in SAP

    • By Varad
    • December 18, 2024
    • 24 views
     Credit Management T codes in SAP

    Troubleshooting SAP BD22: Delete Change Pointer Not Picking Correct Processed Messages

    • By Varad
    • December 17, 2024
    • 56 views
    Troubleshooting SAP BD22: Delete Change Pointer Not Picking Correct Processed Messages

    Working with Shell Scripts in SAP ABAP Environment

    • By Varad
    • December 16, 2024
    • 34 views
    Working with Shell Scripts in SAP ABAP Environment