Code: Alles auswählen.
REPORT zbr_bonus_lst_1.
TYPE-POOLS: slis. " SLIS contains all the ALV data types
TABLES: kna1, knvv.
TYPES: BEGIN OF tp_list,
* sel,
kunnr TYPE kunnr,
land1 TYPE land1_gp,
name1 TYPE name1_gp,
name2 TYPE name2_gp,
stras TYPE stras_gp,
ort01 TYPE ort01_gp,
pstlz TYPE pstlz,
telf1 TYPE telf1,
ev_umsatz TYPE bonba,
END OF tp_list.
*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: gt_list TYPE STANDARD TABLE OF tp_list,
gs_list TYPE tp_list,
gt_kna1 TYPE STANDARD TABLE OF kna1,
gs_kna1 TYPE kna1,
it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
FIELD-SYMBOLS: <fs> LIKE LINE OF gt_list.
DATA: ev_umsatz TYPE bonba.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_kunnr FOR kna1-kunnr.
SELECTION-SCREEN END OF BLOCK b1.
PARAMETERS: p_jahr TYPE n LENGTH 4.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
LOOP AT gt_list INTO gs_list.
CALL FUNCTION 'Z_SD_GET_BONBA'
EXPORTING
if_fk_jahr = p_jahr
if_kunnr = gs_list-kunnr
IMPORTING
ef_bonba = ev_umsatz.
ENDLOOP.
LOOP AT gt_list ASSIGNING <fs>.
<fs>-ev_umsatz = ev_umsatz .
ENDLOOP.
*Build field catalog
wa_fieldcat-fieldname = 'KUNNR'. " Fieldname in the data table
wa_fieldcat-seltext_m = 'Kundennummer'. " Column description in the output
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_m = 'Name'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'NAME2'.
wa_fieldcat-seltext_m = 'Name2'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'STRAS'.
wa_fieldcat-seltext_m = 'Strasse'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'PSTLZ'.
wa_fieldcat-seltext_m = 'PLZ'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'ORT01'.
wa_fieldcat-seltext_m = 'Ort'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'LAND1'.
wa_fieldcat-seltext_m = 'LKZ'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'TELF1'.
wa_fieldcat-seltext_m = 'Telefon'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-fieldname = 'ev_umsatz'.
wa_fieldcat-seltext_m = 'Bonusumsatz'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR: wa_fieldcat.
*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat
TABLES
t_outtab = gt_list
EXCEPTIONS
program_error = 1
OTHERS = 2.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .
*Fetch data from the database
SELECT a~kunnr a~name1 a~name2 a~stras a~pstlz a~ort01 a~land1 a~telf1 FROM kna1 AS a
INNER JOIN knvv AS b ON a~kunnr = b~kunnr
INTO CORRESPONDING FIELDS OF TABLE gt_list
WHERE vkorg = '1600' AND vtweg = '30' AND a~kunnr IN s_kunnr .
ENDFORM.
Code: Alles auswählen.
LOOP AT gt_list ASSIGNING FIELD-SYMBOL(<fs_list>).
CALL FUNCTION 'Z_SD_GET_BONBA'
EXPORTING
if_fk_jahr = p_jahr
if_kunnr = <fs_list>-kunnr
IMPORTING
ef_bonba = <fs_list>-ev_umsatz.
ENDLOOP.