0% found this document useful (0 votes)
9 views15 pages

Amdt New Exemple

The document provides a step-by-step guide for creating an ABAP program and local class, implementing methods, and enhancing the program with system variables. It also compares SE11 views with ABAP CDS views, highlighting the advantages of CDS views and outlining the prerequisites for creating them. Finally, it details the process of creating an ABAP CDS view using the SPFLI table, including activation and data preview steps.

Uploaded by

Balagangadhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views15 pages

Amdt New Exemple

The document provides a step-by-step guide for creating an ABAP program and local class, implementing methods, and enhancing the program with system variables. It also compares SE11 views with ABAP CDS views, highlighting the advantages of CDS views and outlining the prerequisites for creating them. Finally, it details the process of creating an ABAP CDS view using the SPFLI table, including activation and data preview steps.

Uploaded by

Balagangadhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

AMDT NEW EXEMPLE

 Step 1

Create new ABAP program

In the toolbar, choose New > ABAP Program…:

A wizard appears to create a new ABAP Program. Enter z_invoice_items_euro in the name field.
Enter a meaningful text in the description field. Choose Finish to create the report.Afterwards an
editor will be opened which shows the empty report.

Done

 Step 2
Create ABAP local class

1. Type lcl and choose Ctrl+Space to get code completion proposals. Select the code
template for the insertion of a local class by choosing lcl - Local class or
choose Enter if the right entry is already selected.

2. Adjust the name of the local class to lcl_main using inline editing.

Done

 Step 3

Create CREATE method

Position the cursor in the class definition statement and choose Ctrl+1 to open the Quick Fix menu.
Choose Generate factory method create to create a static factory method.
Done

 Step 4

Implement RUN method

1. Add the definition of an additional instance method run by entering methods run. in
the public section.

2. Then position the cursor on the method name and choose Ctrl+1 to open the Quick-
Fix menu. Choose Add implementation for run.

3. Implement a simple WRITE statement in the method run.


Done

 Step 5

Make ABAP program runnable

1. Add a START-OF-SELECTION event to your report

2. Create an instance of the local class lcl_main.

3. Call the run method.That is, enter the following code:

ABAP

Copy

START-OF-SELECTION.

lcl_main=>create( )->run( ).

Class methods are called using => ; instance methods are called using ->.

Done

 Step 6

Save and activate ABAP program

Save and activate your program by choosing Save and Activate in the toolbar.

Done

 Step 7
Run the ABAP program

Choose F8 to run your program. An embedded SAP GUI will open inside an Eclipse editor. After
checking the output of the report choose Close.

Done

 Step 8

Output system variables

You will now enhance the program to output your user name and today’s date. Change
the WRITE statement to:

WRITE: 'Welcome, ', sy-uname, / 'Today is the', sy-datum.

sy- is the table containing all the system fields. For the complete list, see the ABAP keyword
documentation: ABAP System Fields.

/ is simply the new line character. (See also ABAP keyword documentation: WRITE.)

Done

 Step 9

Run the ABAP program

Again, choose F8 to run your program. Your output should now look something like this:
Done

 Step 10

Check your code

Your code should look like this:

ABAP

Copy

*&---------------------------------------------------------------------*

*& Report zjp_basic_app

*&---------------------------------------------------------------------*

*&

*&---------------------------------------------------------------------*

REPORT z_invoice_items_euro.

class lcl_main definition create private.

public section.

methods run.

CLASS-METHODS create

RETURNING

value(r_result) TYPE REF TO lcl_main.

protected section.

private section.

endclass.
class lcl_main implementation.

method create.

create object r_result.

endmethod.

method run.

WRITE: 'Welcome, ', sy-uname, / 'Today is the', sy-datum.

endmethod.

endclass.

START-OF-SELECTION.

lcl_main=>create( )->run( ).

Done

 Step 11

Test yourself

Which event keyword is used to turn a report into an executable program? Choose one answer
only.

o INITIALIZE.

o START-OF-SELECTION.

o MAIN.

Congratulations! Your answer is correct


ABAP CDS VIEWS simplified - PART 1

aparnami

Participant

Subscribe

Options

2020 Feb 17 11:58 AM

38 Kudos

44,939

 SAP Managed Tags:

 ABAP Development,

 SAP HANA,

 SAP HANA studio

INTRODUCTION:

ABAP Core Data Service Views also known as ABAP CDS Views. There are so many limitations in SE11
views but we can come out of all the limitations and create a powerful views with the help of ABAP
CDS Views.
In general SE11 views and ABAP CDS Views both will create a database views at the backend. When
we try to access these views as a table in the ABAP code, this code will be executed at the database
level.

Hence, SE11 views and ABAP CDS Views both will implement code push-down, In-spite of this, CDS
views has many advantages in CDS views.

Below are the comparison between SE11 views and ABAP CDS Views:

SE11 Views CDS Views

1. It can only be created from Eclipse platform


2. Calculated columns are possible.
A. Operator
1. It can be created from SAPGUI or Eclipse. B. CDS Function
2. Calculated column are not possible. C. CASE Expression D. Aggregated Functions
3. Input Parameters are not possible. 3. Input parameter are allowed.
4. Only Join is possible. A. In calculated Columns
5. Grouping and aggregation are not possible. B. For filtering data
6. Annotations are not possible. 4. Join and Union both are possible.
5. Grouping and aggregation are possible.
6. Annotation can be used to provide more m
information to individual fields and Views.

Basic ABAP CDS View creation:

Below are the prerequisite knowledge required to create a ABAP CDS View:
1. Creation of ABAP Project

2. Creation of ABAP Package

3. ABAP programming

I have already created the ABAP Project and ABAP Package in the HANA Development perspective
and below are the screen shot of these object.

1. ABAP Project

2. ABAP Package
Note: Make sure that you should create a ABAP package inside the ABAP project.

I am demonstrating the ABAP CDS view creation using SPFLI table with all the fields of it.

Step1. Right click on the ABAP Package and select new ABAP repository object and navigate to
Core Data Services, select the Data Defination and provide a name to CDS view.
Step2 and Step 3. Please provide a suitable name based on your project's naming
convention. Click on next and select the Transport request as shown below:

Step 4. Select the template based on your requirement and Click finish. I am selecting Define View
template since I am creating a ABAP CDS view with all the fields of Database table SPFLI.
Step5. As soon as you click on the finish, Below code will appears. Please refer the screen shot for
explanation.

Step6: Below is the logic for CDS views.


Step7. Activate it and click on data preview option.

Step8. Click on data preview to view the data of this CDS view.

With this example, we have completed the First part of ABAP CDS VIEWS simplified.
Please like and comment on it if you find it helpful.

https://community.sap.com/t5/technology-blogs-by-members/abap-cds-views-simplified-part-1/ba-
p/13426951

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy