Michael
Michael

Reputation: 37

SQL statement return results into ALV table

I am fairly new to ABAP and wrote a SQL statement to return a list of items into an ALV. However when I execute the program, it returns nothing. Below is the code I wrote. I created a table type to show only the columns I needed in the results.

REPORT  Z_DISPLAY_RESULTS.

TYPES: BEGIN OF t_Display,
 foodItem TYPE foodList-foodItem,
 foodDescription TYPE foodList-foodDescription,
END OF t_Display.
DATA: it_Display TYPE STANDARD TABLE OF t_Display INITIAL SIZE 0,    
  wa_Display TYPE t_Display,                   
  wa_Display1 LIKE LINE OF it_Display.

START-OF-SELECTION.

SELECT foodItem foodDescription
FROM foodList INTO TABLE it_Display
WHERE foodID = '00001'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
*   I_INTERFACE_CHECK              = ' '
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                = ' '
*   I_CALLBACK_PROGRAM             = ' '
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
I_STRUCTURE_NAME               = 'foodList'
*   IS_LAYOUT                      =
*   IT_FIELDCAT                    =
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
TABLES
 T_OUTTAB                       = it_Display
* EXCEPTIONS
*   PROGRAM_ERROR                  = 1
*   OTHERS                         = 2
      .
IF SY-SUBRC <> 0.

ENDIF.

Upvotes: 0

Views: 223

Answers (1)

vwegert
vwegert

Reputation: 18483

  1. Don't learn obsolete stuff - use the new class-based API.
  2. Double-check whether the table is actually filled using the debugger.
  3. I_STRUCTURE_NAME refers to a global DDIC type. If you're using a local type, you will probably need to supply the field catalog yourself - with this obsolete function module. With the new class-based API, this is not (no longer?) needed.

Upvotes: 1

Related Questions