Welchen ALV sollst/willst du verwenden? Je nach ALv (REUSE; LVC; OO; OM) können sich die Spaltennamen ändern.TobiB hat geschrieben:hoff mal einer kann mir sagen we ich des ganze geschickt lösen kann.
Bitte sehr:TobiB hat geschrieben:oder hat jmd n bsp-coding?
Code: Alles auswählen.
REPORT z_test_alv .
* Data Definition
TYPE-POOLS: slis.
DATA:
* Daten
gt_sflight TYPE TABLE OF sflight,
gw_sflight TYPE sflight,
* Fieldcat
gt_fieldcat TYPE slis_t_fieldcat_alv,
gw_fieldcat TYPE slis_fieldcat_alv,
* Sort-Info
gt_sort TYPE slis_t_sortinfo_alv,
gw_sort TYPE slis_sortinfo_alv,
* Reportnamen
g_repid TYPE sy-repid VALUE sy-repid.
* Selection-Screen
SELECT-OPTIONS s_carrid FOR gw_sflight-carrid.
* Daten lesen
SELECT *
FROM sflight
INTO TABLE gt_sflight
WHERE carrid IN s_carrid.
* Fieldcat aufbauen
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
CHANGING
ct_fieldcat = gt_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
* sehr schlechtes Fehlerhandling
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* End-Summe bei bestimmten Spalten
LOOP AT gt_fieldcat INTO gw_fieldcat WHERE fieldname = 'SEATSMAX' OR fieldname = 'SEATSOCC'.
gw_fieldcat-do_sum = 'X'.
MODIFY gt_fieldcat FROM gw_fieldcat.
ENDLOOP. "gt_fieldcat INTO gw_fieldcat
* Sortierung/Zwischensummen
CLEAR: gt_sort, gw_sort.
gw_sort-fieldname = 'CARRID'.
gw_sort-up = 'X'.
gw_sort-subtot = 'X'.
APPEND gw_sort TO gt_sort.
CLEAR gw_sort.
gw_sort-fieldname = 'CONNID'.
gw_sort-up = 'X'.
gw_sort-subtot = 'X'.
APPEND gw_sort TO gt_sort.
* ALV-Ausgabe
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_structure_name = 'SFLIGHT'
it_fieldcat = gt_fieldcat
it_sort = gt_sort
TABLES
t_outtab = gt_sflight
EXCEPTIONS
program_error = 1
OTHERS = 2.
* sehr schlechtes Fehlerhandling
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.