Code: Alles auswählen.
*------------------------------------------------------------------
* Type Pools
*------------------------------------------------------------------
type-pools: slis.
*------------------------------------------------------------------
* Tabellen
*------------------------------------------------------------------
tables: zpfad.
*------------------------------------------------------------------
* Eingabe
*------------------------------------------------------------------
parameters: p_table type slis_tabname.
*------------------------------------------------------------------
* Variablen
*------------------------------------------------------------------
data: it_table type slis_t_fieldcat_alv.
data: gt_fieldcat type slis_t_fieldcat_alv with header line.
data: gt_lvc_fieldcat type lvc_t_fcat.
data: gp_table type ref to data.
data: c_progname like sy-repid.
data: c_workfile(100) type c.
* Field Symbols
field-symbols: <gt_table> type table.
field-symbols: <tab> type table.
*------------------------------------------------------------------
* Start
*------------------------------------------------------------------
start-of-selection.
* Datei öffnen
select single *
from zpfad
where host = sy-host
and zzschluessel = 'TRANSFTP'
and zzschluessel1 = sy-mandt.
concatenate zpfad-zztrans 'ERSTUEB\' p_table '.txt' into c_workfile.
open dataset c_workfile for output in text mode.
* Fehler beim öffnen der Datei?
if sy-subrc ne 0.
message e169(zrb) with text-e01 c_workfile.
endif.
* Zuordnung des Programmnamens für FB aufruf
c_progname = sy-repid.
* Aufbau des Feldkatalogs aus Dictionarystruktur p_table
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = c_progname
i_structure_name = p_table
i_inclname = c_progname
changing
ct_fieldcat = gt_fieldcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
* Fehler beim FB?
if sy-subrc ne 0.
message e169(zrb) with text-e02 sy-subrc.
endif.
call function 'LVC_TRANSFER_FROM_SLIS'
exporting
it_fieldcat_alv = gt_fieldcat[]
importing
et_fieldcat_lvc = gt_lvc_fieldcat[]
tables
it_data = it_table
exceptions
it_data_missing = 1
others = 2.
* Fehler beim FB?
if sy-subrc ne 0.
message e169(zrb) with text-e03 sy-subrc.
endif.
* Dynamisch interne Tabelle aufbauen und zuweisen
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = gt_lvc_fieldcat
importing ep_table = gp_table.
assign gp_table->* to <gt_table>.
* Select ausführen
select *
from (p_table)
into table <gt_table>.
* Datei per FB ausgeben
call function 'WS_DOWNLOAD'
exporting
filename = c_workfile
filetype = 'ASC'
data_tab = 'DAT'
tables
data_tab = <gt_table>.