Hallo Rufat,
schau mal in dem Entwicklungspaket SLIS nach. Unter den Programmen findest Du genügend Beispiele, wie Du so einen Ausgabereport machen kannst.
Der Funktionsbaustein REUSE_ALV_GRID_DISPLAY braucht auf jeden Fall noch ein paar mehr Parameter, als Du hier angegeben hast.
Anbei mal ein Beispiel (nicht lauffähig), wie man den REUSE_ALV_GRID_DISPLAY befüllt und vorbereitet.
*&---------------------------------------------------------------------*
*& Report ZMYPROGRAM *
*& *
*&---------------------------------------------------------------------*
report ZMYPROGRAM message-id ZMESSAGE.
include ZMYPROGRAM top . " global Data
include ZMYPROGRAM select. " Selection-Include
include ZMYPROGRAM forms. " FORM-Routines
include ZMYPROGRAM ucomm. " User-Commands
initialization.
perform initialize.
start-of-selection.
perform get_ selection changing gt_select.
" nun noch am Bildschirm anzeigen
perform reuse_alv_grid_display.
end-of-selection.
*&---------------------------------------------------------------------*
*& Include ZMYPROGRAM_TOP *
*&---------------------------------------------------------------------*
type-pools: slis, imrep, rsds.
data: gt_select type table of st_select,
gt_output type table of st_select.
data: gcl_grid type ref to cl_gui_alv_grid,
gcl_dock_container type ref to cl_gui_docking_container.
*…
data: gt_fieldcat type slis_t_fieldcat_alv,
gs_layout type slis_layout_alv,
gv_sortfield(30) type c,
gv_desc_order type boole_d,
gs_variant type disvariant, "Display-Variante
gv_grid_title type lvc_title.
*…
tables: ska1.
*…
data: gv_repid type syrepid,
gv_rows_str type string,
gv_row type i,
gv_row_color type lvc_cifnm value ‚LINECOLOR‘,
gv_save(1) type c value ‚A‘, " Parameter X, U oder A
gv_subrc type sysubrc.
*&---------------------------------------------------------------------*
*& Include ZMYPROGRAM_SELECT *
*&---------------------------------------------------------------------*
selection-screen begin of block sel with frame title text-001.
* Selektionsblock 1
selection-screen begin of block sel1 with frame title text-002.
select-options s_belnr for bkpf-belnr.
select-options s_bukrs for bkpf-bukrs.
select-options s_gjahr for bkpf-gjahr.
select-options s_lifnr for bkpf-lifnr.
selection-screen end of block sel1
selection-screen begin of block sel2 with frame title text-004.
parameter: p_max type i default 300.
parameter: pa_varia type slis_vari.
selection-screen end of block sel2…
*&---------------------------------------------------------------------*
*& Include ZMYPROGRAM_FORMS *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form initialize
*&---------------------------------------------------------------------*
form initialize .
clear: gt_fieldcat, gt_select.
perform prepare_fieldcat.
perform layout_init.
* Title der Selektionsmaske
set titlebar c_init_title with text-110.
* Report ID zuordnen
gv_repid = sy-repid.
endform. " initialize
*&--------------------------------------------------------------------*
*& Form prepare_fieldcatalog
*&--------------------------------------------------------------------*
form prepare_fieldcat.
data: lt_tabname type slis_tabname,
lv_repid type sy-repid,
ls_fcat type line of slis_t_fieldcat_alv.
lt_tabname = ‚gt_select‘.
lv_repid = sy-repid.
"REFRESH gt_fieldcatalog. fieldcounter = 0.
call function ‚REUSE_ALV_FIELDCATALOG_MERGE‘
exporting
i_program_name = lv_repid
i_internal_tabname = lt_tabname
i_structure_name = ‚MYGRIDSTRUCTURE‘
* I_CLIENT_NEVER_DISPLAY = ‚X‘
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
changing
ct_fieldcat = gt_fieldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc 0.
message s015.
endif.
" Nun die anklickbaren Hotspot-Felder definieren.
loop at gt_fieldcat into ls_fcat.
case ls_fcat-fieldname.
" — Felder nicht anzeigen
when ‚WIID‘ or ‚AR_OBJECT‘ or ‚ARC_DOC_ID‘
ls_fcat-tech = ‚X‘.
" — Ändern der Position, Beschriftung, etc.
when ‚BELNR‘.
ls_fcat-seltext_s = text-302. "‚FI Beleg‘.
ls_fcat-seltext_l = text-303. "‚FI Belegnummer‘.
ls_fcat-hotspot = ‚X‘.
when ‚LIFNR‘.
ls_fcat-seltext_s = text-306. "‚Kreditorennr‘.
ls_fcat-seltext_l = text-307. "‚Kreditorennummer‘.
ls_fcat-hotspot = ‚X‘.
when ‚BUKRS‘.
ls_fcat-seltext_s = text-310. "‚BKrs.‘.
ls_fcat-seltext_l = text-311. "‚Buchungskreis‘.
ls_fcat-outputlen = ‚4‘.
endcase.
modify gt_fieldcat from ls_fcat index sy-tabix.
endloop.
endform. "prepare_fieldcatalog
*---------------------------------------------------------------------*
* FORM layout_init *
*---------------------------------------------------------------------*
form layout_init.
" Layout-Parameter setzen
gs_layout-no_hotspot = ‚‘. " headings not as hotspot
gs_layout-zebra = ‚X‘. " striped pattern
gs_layout-f2code = ‚DISPLAY‘. "
gs_layout-colwidth_optimize =‚X‘.
gs_layout-totals_before_items = ‚X‘. " diplay totals before the items
gs_layout-group_change_edit = ‚X‘. " Settings by user for new group
gs_layout-info_fieldname = gv_row_color. " infofield for listoutput
endform. "LAYOUT_INIT
*&---------------------------------------------------------------------*
*& Form get_selection
*&---------------------------------------------------------------------*
form get_selection changing gt_select.
data: lv_result type sysubrc,
lv_lifname type name1_gp.
clear: lv_result, lv_lifname, gt_output[], gt_select[].
perform manipulate_lifname.
perform manipulate_erdat changing s_tstmp.
if not s_tstmp is initial.
append s_tstmp.
endif.
select * from bkpf
into corresponding fields of table gt_select up to p_max rows
where bukrs in s_bukrs "Buchungskreis
and belnr in s_belnr "FI-Belegnummer
and gjahr in s_gjahr "Geschäftsjahr
and lifnr in s_lifnr "Lieferantennummer
order by belnr descending.
" Anzahl Treffer ermitteln
gv_row = sy-dbcnt.
gv_rows_str = sy-tfill.
replace ‚&hits‘ in gv_grid_title with gv_rows_str.
gt_output = gt_select.
endform. " get_selection
*&---------------------------------------------------------------------*
*& Form reuse_alv_grid_display
*&---------------------------------------------------------------------*
form reuse_alv_grid_display .
gs_variant-report = sy-repid.
gs_variant-variant = pa_varia.
call function ‚REUSE_ALV_GRID_DISPLAY‘
exporting
i_buffer_active = ‚X‘
i_callback_program = sy-repid
i_callback_pf_status_set = ‚WHOLE_TOOLBAR‘
i_callback_user_command = ‚USER_COMMAND‘
is_layout = gs_layout
it_fieldcat = gt_fieldcat
i_default = ‚X‘
i_save = ‚A‘
is_variant = gs_variant " Layout-Variante
tables
t_outtab = gt_select
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.
endform. " reuse_alv_grid_display
Fank erst einmal klein an. Liste nur mal im ALV die Sachkonten auf. Wenn das klappt, dann füge die weiteren Felder ein.
Have fun.
Calvin