Code: Alles auswählen.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_user_command = 'reaction'
i_grid_title = 'Overview'
i_save = 'A'
it_fieldcat = lt_fcat
is_layout = gs_layout
tables
t_outtab = g_s_resulttable.
if sy-subrc <> 0.
endif.zzcpak hat geschrieben:Wenn du schon in OO entwickelst, könntest du dir die Klassen CL_ALV* bzw. CL_SALV* mal ansehen. Ich habs selbst noch nicht oft verwendet, aber da dürfte alles dabei, was man für die Listverarbeitung braucht.
das könnte auch nützlich sein:
http://help.sap.com/saphelp_nw2004s/hel ... ameset.htm
Code: Alles auswählen.
method on_double_click.
data wa_result like line of g_s_resulttable.
data dref type ref to data.
field-symbols: <table> type any,
<field> type any.
data tname type tabname.
data tablename like table of tname.
data: lt_fcat type slis_t_fieldcat_alv.
data: ls_fcat type slis_fieldcat_alv.
read table g_s_resulttable index row into wa_result.
tname = wa_result-table.
create data dref type (tname).
assign dref->* to <table>.
select *
into <table>
from (wa_result-table).
append <table> to tablename.
clear <table>.
endselect.
while sy-subrc = 0.
assign component sy-index of structure <table> to <field>.
* append <field> to lt_fcat.
endwhile.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_structure_name = 'tablename'
changing
ct_fieldcat = lt_fcat
exceptions
programm_error = 1
others = 2.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_grid_title = '2nd layer'
i_save = 'A'
it_fieldcat = lt_fcat
tables
t_outtab = tablename.
endmethod. "on_double_clicka) der Satz ist unverständlich da grammatikalisch völliger Unsinn.Spookykid hat geschrieben:Folgende Methode erhält den String einen DDIC Tabellenname (wa_result-table) soll daraufhin den Inhalt ziehen und als alv ausgeben.
b) Was für Probleme? Was ist "dynamisches leechen"?Spookykid hat geschrieben: Leider stoße ich beim Feldkatalog auf Probleme. Ich kann mit REUSE_ALV_FIELDCATALOG_MERGE den Feldkatalog nicht dynamisch leechen.
Womit sollte denn field bestückt werden? Hast du dir das mal im Debugger angeschaut?Spookykid hat geschrieben:Beim Zusammenbauen des Feldkats mit assign component sy-index ... gibt es auch Probleme da <field> nicht bestückt wird.

Code: Alles auswählen.
class-methods on_double_click " DOUBLE_CLICK
for event if_salv_events_actions_table~double_click
of cl_salv_events_table
importing row
column.Code: Alles auswählen.
method on_double_click.
data wa_result like line of g_s_resulttable.
data dref type ref to data.
data tname type tabname.
data: lt_fcat type slis_t_fieldcat_alv.
data: ls_fcat type slis_fieldcat_alv.
data ls_gridtitle type lvc_title.
data: ls_dref_case type ref to data.
data: ls_dref_case1 type ref to data. " Identifizierugsmerkmal für CASE1
data: ls_dref_case2 type ref to data. " Identifizierugsmerkmal für CASE2
data: ls_dref_case3 type ref to data. " Identifizierugsmerkmal für CASE3
data: ls_dref_case4 type ref to data. " Identifizierugsmerkmal für CASE4
data: begin of ls_tabix,
tabix like sy-tabix,
case type i,
end of ls_tabix.
data lt_tabix like table of ls_tabix. "Enthält die Idizes der betroffenen Zeilen.
data otab type abap_sortorder_tab.
data ls_lang type tabname.
data ls_rowcol type LVC_S_ROW.
data lt like table of ls_rowcol.
field-symbols: <table> type standard table,
<field> type any,
<case> type any table,
<case2> type any,
<row_case> type any.
**Anlegen der Tabellenstruktur ensprehchend der ausgewählten Zeile.
read table g_s_resulttable index row into wa_result.
tname = wa_result-table.
create data dref type table of (tname).
assign dref->* to <table>.
*Befüllen der Tabelle
select *
into table <table>
from (wa_result-table).
**Feldkatalog erstellen.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_structure_name = tname
changing
ct_fieldcat = lt_fcat
exceptions
programm_error = 1
others = 2.
ls_gridtitle = wa_result-table.
**Analyse wird vorgenommen.
secondlayer_display(
exporting t_name = tname
importing ls_dref_case1 = ls_dref_case1
ls_dref_case2 = ls_dref_case2
ls_dref_case3 = ls_dref_case3
ls_dref_case4 = ls_dref_case4
otab = otab
CHANGING ls_lang = ls_lang
).
** Verarbeiten der importierten Analysetabellen.
** Die ausgewählte Tabelle wird wird auf den Inhalt der entsprechendnen "Fälle"
**überpüft. Sy-Tabix und ensprechender Fall werden vermerkt.
create data ls_dref_case type table of (tname).
ls_dref_case ?= ls_dref_case1.
assign ls_dref_case->* to <case>.
loop at <case> ASSIGNING <case2>.
READ TABLE <table> from <case2> ASSIGNING <row_case> .
ls_tabix-tabix = sy-tabix.
ls_tabix-case = 1.
append ls_tabix to lt_tabix.
endloop.
create data ls_dref_case type table of (tname).
ls_dref_case ?= ls_dref_case2.
assign ls_dref_case->* to <case>.
loop at <case> ASSIGNING <case2>.
READ TABLE <table> from <case2> ASSIGNING <row_case> .
ls_tabix-tabix = sy-tabix.
ls_tabix-case = 2.
append ls_tabix to lt_tabix.
endloop.
create data ls_dref_case type table of (tname).
ls_dref_case ?= ls_dref_case3.
assign ls_dref_case->* to <case>.
loop at <case> ASSIGNING <case2>.
READ TABLE <table> from <case2> ASSIGNING <row_case> .
ls_tabix-tabix = sy-tabix.
ls_tabix-case = 3.
append ls_tabix to lt_tabix.
endloop.
create data ls_dref_case type table of (tname).
ls_dref_case ?= ls_dref_case4.
assign ls_dref_case->* to <case>.
loop at <case> ASSIGNING <case2>.
READ TABLE <table> from <case2> ASSIGNING <row_case> .
ls_tabix-tabix = sy-tabix.
ls_tabix-case = 4.
append ls_tabix to lt_tabix.
endloop.
ralf.wenzel hat geschrieben:Ups, verlesen. Du willst die ZEILE einfärben, nicht die ZELLE. Dann lass den Spaltennamen leer.

Code: Alles auswählen.
read table g_s_resulttable index row into wa_result.
tname = wa_result-table.
create data dref type table of (tname).
assign dref->* to <table>.Könntest du hierzu ein Bsp machen?Warum baust du dir keine Struktur auf, die an das Feldsymbol per INCLUDE STRUCTURE die notwendige ALV-Struktur dranhängt (unabhängig davon, welche ALV-Struktur das ist).
Doch - das geht.Spookykid hat geschrieben:Das Problem hierbei ist jedoch, dass ich meine Tabellen-Struktur nicht um ein char(4)- Feld erweitern kann. Ich weiß erst zur Laufzeit, um welche Struktur es geht.
Folgende Benutzer bedankten sich beim Autor black_adept für den Beitrag:
Spookykid
wunderbar!black_adept hat geschrieben:Doch - das geht.Spookykid hat geschrieben:Das Problem hierbei ist jedoch, dass ich meine Tabellen-Struktur nicht um ein char(4)- Feld erweitern kann. Ich weiß erst zur Laufzeit, um welche Struktur es geht.
http://www.apentia-forum.de/viewtopic.php?f=3&t=22501
Code: Alles auswählen.
class-methods extend_structure importing p_structure type any table
p_tabix type any table
changing p_dref type ref to data.Code: Alles auswählen.
method extend_structure.
data: cl_desc1 type ref to cl_abap_structdescr,
t_component_table1 type cl_abap_structdescr=>component_table,
cl_desc2 type ref to cl_abap_structdescr,
t_component_table2 type cl_abap_structdescr=>component_table,
cl_desc type ref to cl_abap_structdescr,
t_component_table type cl_abap_structdescr=>component_table,
dreftable type ref to data.
data p_test type ref to data.
data: begin of fix_part,
linecolor(4) type c,
end of fix_part.
data dref_temp type ref to data.
data lf_linecolor(4) type c.
field-symbols: <oldtable> type table,
<ln_oldtable> type any,
<fs_table> type any,
<fs_tabix> like gs_tabix,
<p_dref> type any,
<dreftable> type table.
*Sicherung des Tabelleninhalts.
create data dref_temp like table of p_structure.
dref_temp ?= p_dref.
cl_desc2 ?= cl_abap_typedescr=>describe_by_data( fix_part ) .
t_component_table2 = cl_desc2->get_components( ).
cl_desc1 ?= cl_abap_typedescr=>describe_by_data( p_structure ) <============================================== .
t_component_table1 = cl_desc1->get_components( ).
Code: Alles auswählen.
cl_desc1 ?= cl_abap_typedescr=>describe_by_data( p_structure )