create table in abap adt btp









T ABAP ADT View table and select data


D ABAP ADT View table and select data
& Help ABAP ADT View table and select data

View Database table definition in ABAP ADT (Ecipse)


Simply follow these simple steps to view an existing sap table definition

nativate->Open ABAP Development Object
abap adt table step 1



Start typing the name of the table and select the table you want to view
abap adt table step 2



The details of the table including list of fields will then be shown
abap adt table step 3


Example table defintion coding


@EndUserText.label : 'Flight Reference Scenario: Connection'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table /dmo/connection {

key client : abap.clnt not null;
key carrier_id : /dmo/carrier_id not null;
key connection_id : /dmo/connection_id not null;
airport_from_id : /dmo/airport_from_id;
airport_to_id : /dmo/airport_to_id;
departure_time : /dmo/flight_departure_time;
arrival_time : /dmo/flight_arrival_time;
distance : /dmo/flight_distance;
distance_unit : msehi;

}

View Database table data in ABAP ADT (Ecipse)


To view it's data within the ADT, simply execute the definition file/view

Either using the tool bar button
abap adt table step 4



or right click on the code
abap adt table step 5


abap adt table step 6



SAP table data will then be displayed
abap adt table step 7




ABAP Code


See below for full code listing to seelct data from table /dmo/connection

First view the table
abap adt table step 8



and check what data exists in your system
abap adt table step 9




CLASS zcl_myselect DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_oo_adt_classrun .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_myselect IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.

DATA airport_from_id TYPE /DMO/airport_from_id.
DATA airport_to_id TYPE /DMO/airport_to_id.

DATA airports TYPE TABLE OF /DMO/airport_from_id.

* Example 1
***********
SELECT SINGLE
FROM /dmo/connection
FIELDS airport_from_id, airport_to_id
WHERE carrier_id = 'AA'
AND connection_id = '0017'
INTO ( @airport_from_id, @airport_to_id ).

IF sy-subrc = 0.
out->write( |Flight departs from { airport_from_id }.| ).
ELSE.
out->write( |There is no flight | ).
ENDIF.

* Example 2
***********
SELECT SINGLE
FROM /dmo/connection
FIELDS airport_from_id
WHERE carrier_id = 'XX'
AND connection_id = '1234'
INTO @airport_from_id.

IF sy-subrc = 0.
out->write( |Flight departs from { airport_from_id }.| ).
ELSE.
out->write( |There is no flight | ).
ENDIF.

ENDMETHOD.
ENDCLASS.

Execute ABAP select statements



abap adt table step 10


Clear ABAP Console


Every time you execute your ABAP code within the ADT editor it will add any outputs to the console, note you can right click and choose clear to refresh the consol display

abap adt table step 11