Folgende Benutzer bedankten sich beim Autor black_adept für den Beitrag:
erzoo24
Code: Alles auswählen.
TABLES: npat.
type-pools: SLIS.
START-OF-SELECTION.
DATA: lv_vname TYPE npat-vname,
lv_nname TYPE npat-nname,
lv_gschl TYPE npat-gschl,
lv_gbdat TYPE npat-gbdat,
lv_anr(4) TYPE c,
lv_alter(2) TYPE c,
lv_ausgabe TYPE string,
ls_npat TYPE npat.
TYPES: BEGIN OF ty_pat,
patnr TYPE npat-patnr,
vname TYPE npat-vname,
nname TYPE npat-nname,
gschl TYPE npat-gschl,
gbdat TYPE npat-gbdat,
anr TYPE c LENGTH 4,
alter TYPE c LENGTH 2,
END OF ty_pat.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_pat TYPE TABLE OF ty_pat,
wa_pat TYPE ty_pat.
SELECT-OPTIONS s_patnr FOR npat-patnr NO INTERVALS.
SELECT patnr
vname
nname
gschl
gbdat
"anr
"alter
from npat
into TABLE it_pat
WHERE patnr in s_patnr.
* field catalog für die spalten bauen
wa_fieldcat-col_pos = '1'.
wa_fieldcat-row_pos = '1'.
wa_fieldcat-fieldname = 'patnr'. " feld name der datentabelle
wa_fieldcat-seltext_m = 'Patientennummer'. " beschreibung des feldes
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-row_pos = '1'.
wa_fieldcat-fieldname = 'vname'.
wa_fieldcat-seltext_m = 'Vorname'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-row_pos = '1'.
wa_fieldcat-fieldname = 'nname'.
wa_fieldcat-seltext_m = 'Nachname'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-row_pos = '1'.
wa_fieldcat-fieldname = 'gschl'.
wa_fieldcat-seltext_m = 'Geschlecht'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-row_pos = '1'.
wa_fieldcat-fieldname = 'gbdat'.
wa_fieldcat-seltext_m = 'Geburtsdatum'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-cprog
IT_FIELDCAT = IT_FIELDCAT
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
* ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
TABLES
t_outtab = it_pat
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.