Simple first ABAP OO program

Posted on Posted in ABAP, ABAP OO

Simple first program of ABAP OO, using a selection in the database. Posting to keep in mind the keywords of a ABAP OO for who does not have any experience with OO.
I recommend this course: https://www.udemy.com/abap-objects/learn/v4/overview

 

 

REPORT  z_teste01.

*———————————————————————-*
*       CLASS flight DEFINITION
*———————————————————————-*
* Definition, where are the data and the methods definitions
*———————————————————————-*
CLASS flight DEFINITION.

PUBLIC SECTION.

DATAit_flight TYPE STANDARD TABLE OF sflight.
DATAwa_flight TYPE sflight.

METHODSget_flight IMPORTING fldate TYPE sflightfldate
connid TYPE sflightconnid.

ENDCLASS.                    “flight DEFINITION

*———————————————————————-*
*       CLASS fligh IMPLEMENTATION
*———————————————————————-*
* Where are the execution of the methods
*———————————————————————-*
CLASS flight IMPLEMENTATION.

METHOD get_flight.

SELECT FROM sflight INTO TABLE it_flight
WHERE fldate fldate AND connid connid.

IF sysubrc 0.
LOOP AT it_flight INTO wa_flight.
WRITE/ wa_flightconnidwa_flightfldatewa_flightprice.
ENDLOOP.
ENDIF.

ENDMETHOD.                    “show_flight

ENDCLASS.                    “fligh IMPLEMENTATION

START-OF-SELECTION.

* Input of selection parameters
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text001.
PARAMETERSp_date TYPE sflightfldate,
p_connid TYPE sflightconnid.
SELECTION-SCREEN END OF BLOCK b1.

* Creating the object.
DATA o_flight TYPE REF TO flight.
CREATE OBJECT o_flight.

* Calling the method.
o_flight->get_flightfldate p_date connid p_connid ).

 

Total Views: 56 ,

Leave a Reply

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