banner ads

Select Total Field Records

How to select total records from one or more than one fields from database?
We can do that by not using the WHERE condition as simple as that. Below is an example where we have selected PO numbers & items from table EKPO and we haven’t used WHERE condition. The system fetches all records from those two fields and prints the output.

To know the total numbers of rows we have used describe table statement so that we can see the total number records.

REPORT  zabap_gui.

TABLES: ekpo.

* Creating a custom structure of Item Table
TYPES:
      BEGIN OF ty_ekpo,
        ebeln TYPE ekpo-ebeln,
        ebelp TYPE ekpo-ebelp,
      END OF ty_ekpo.

* Creating a line type of predefined structure
DATA:
      wa_ekpo TYPE ty_ekpo,
      it_ekpo TYPE STANDARD TABLE OF ty_ekpo.

* Not using Where condition will fetch all rows from the fields
SELECT ebeln ebelp
  FROM ekpo INTO TABLE it_ekpo.

DESCRIBE TABLE it_ekpo.
WRITE:/  'Total Entries: ', sy-tfill.
SKIP.

WRITE:/    'PO No.'15 'Item'.
ULINE.

LOOP AT it_ekpo INTO wa_ekpo.
  WRITE:/    wa_ekpo-ebeln, 15 wa_ekpo-ebelp.
ENDLOOP.

Here is the output.


No comments