Hallo,
hier mal ein Mustercoding, damit klar wird was ich will bzw. jemanden auffällt was falsch ist
REPORT ZHR_TESTREPORT.
TYPE-POOLS SLIS.
TABLES: PERNR.
INFOTYPES: 0000, 0001.
DATA: BEGIN OF TAB OCCURS 50,
PERNR LIKE P0001-PERNR, "Personalnummer
KOSTL LIKE P0001-KOSTL, "Kostenstelle
ANZAHL TYPE P DECIMALS 0,
END OF TAB.
DATA: LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
LT_REPID LIKE SY-REPID,
IT_SORT_INFO TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,
S_LAYOUT TYPE SLIS_LAYOUT_ALV. " Für ALV-Grid
LT_REPID = SY-REPID. " Für ALV Grid = REPORT-ID
PARAMETERS:
ZSUM AS CHECKBOX DEFAULT 'X'.
GET PERNR.
CLEAR TAB.
ADD 1 TO TAB-ANZAHL.
TAB-PERNR = PERNR-PERNR.
MOVE-CORRESPONDING P0001 TO TAB.
APPEND TAB.
* Verarbeitung am Ende der Datenselektion
END-OF-SELECTION.
PERFORM ALV_LIST USING LT_FIELDCAT. " Listausgabe
*---------------------------------------------------------------------*
* ALV LISTE AUSGEBEN *
*---------------------------------------------------------------------*
* Fielcatalog aubauen
*----------------------------------------------------------------------
FORM ALV_LIST USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: TOTALS_ONLY(1) TYPE C. " show only totals
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = LT_REPID
I_INTERNAL_TABNAME = 'TAB'
I_INCLNAME = LT_REPID
CHANGING
CT_FIELDCAT = LT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
* Felder formatieren
*---------------------------------------------------------------------*
FIELD-SYMBOLS:
<GS_FIELDCAT> LIKE LINE OF LT_FIELDCAT.
READ TABLE LT_FIELDCAT
WITH KEY FIELDNAME = 'PERNR'
ASSIGNING <GS_FIELDCAT>.
IF SY-SUBRC = 0.
<GS_FIELDCAT>-SELTEXT_L = 'Personalnummer'.
<GS_FIELDCAT>-SELTEXT_M = 'Personalnummer'.
<GS_FIELDCAT>-SELTEXT_S = 'Persnr'.
ENDIF.
READ TABLE LT_FIELDCAT
WITH KEY FIELDNAME = 'KOSTL'
ASSIGNING <GS_FIELDCAT>.
IF SY-SUBRC = 0.
<GS_FIELDCAT>-SELTEXT_L = 'Kostst'.
<GS_FIELDCAT>-SELTEXT_M = 'Kostst'.
<GS_FIELDCAT>-SELTEXT_S = 'Kostst'.
ENDIF.
READ TABLE LT_FIELDCAT
WITH KEY FIELDNAME = 'ANZAHL'
ASSIGNING <GS_FIELDCAT>.
IF SY-SUBRC = 0.
<GS_FIELDCAT>-SELTEXT_L = 'Anz'.
<GS_FIELDCAT>-SELTEXT_M = 'Anz'.
<GS_FIELDCAT>-SELTEXT_S = 'Anz'.
<GS_FIELDCAT>-DO_SUM = 'X'. "Summe bilden
ENDIF.
* Sortierung der Spalten und Zwischensummen
*-----------------------------------------------------------------------
REFRESH IT_SORT_INFO.
CLEAR IT_SORT_INFO.
IT_SORT_INFO-SPOS = '01'.
IT_SORT_INFO-FIELDNAME = 'KOSTL'.
IT_SORT_INFO-UP = 'X'.
IT_SORT_INFO-SUBTOT = 'X'.
APPEND IT_SORT_INFO.
*
S_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. " Optimale Spaltenbreite
IF ZSUM EQ 'X'.
S_LAYOUT-TOTALS_ONLY = 'X'. " Nur Summe ausgeben
ENDIF.
* ALV Ausgeben
*----------------------------------------------------------------------
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZHR_VK_CO_PERSONALZAHLEN'
IT_FIELDCAT = LT_FIELDCAT
IS_LAYOUT = S_LAYOUT
IT_SORT = IT_SORT_INFO[]
TABLES
T_OUTTAB = TAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
Wenn der Schalter ZSUM gesetzt ist, soll nur die Anzahl pro Kostenstelle ausgegeben werden und eben nicht die Zeilen pro Personalnummer. Ich ahbe gedacht, dies geht mit dem "Totals_Only".
Wäre nett, wenn mir jemand helfen kann, bin echt am Verzweifeln kurz vor dem Wochenende
Gruß
Volker