0% found this document useful (0 votes)
40 views

Dynamic Table Download

This document describes downloading a dynamic table as a file. It defines data structures for fields and the table, retrieves field metadata, selects data from the table, and downloads it to a file. Key steps include: 1. Defining data structures for fields and the table 2. Retrieving field metadata from DD03P using DD_TABL_GET 3. Selecting data from the table into an internal table 4. Downloading the internal table to a file using GUI_DOWNLOAD

Uploaded by

Rangabashyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Dynamic Table Download

This document describes downloading a dynamic table as a file. It defines data structures for fields and the table, retrieves field metadata, selects data from the table, and downloads it to a file. Key steps include: 1. Defining data structures for fields and the table 2. Retrieving field metadata from DD03P using DD_TABL_GET 3. Selecting data from the table into an internal table 4. Downloading the internal table to a file using GUI_DOWNLOAD

Uploaded by

Rangabashyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

REPORT ydynamic_tab_download.

TYPES:
* Feldtyp
BEGIN OF t_fld.
INCLUDE STRUCTURE dd03p AS dd03p. "Dictionary-Struktur
" weitere Attribute für die Pflege
TYPES:
mark LIKE rsdxx-mark, "Eintrag markiert
type_icon TYPE dd02d-datatype, "Typ-Ikone
shlporigin_text LIKE dd07t-ddtext, "Text zur SHLPORIGIN
fkexi(1), "Flag für Existenz der FS.prüfung
mod(1), "Modifikations-Id für Erweiterungen §CLM
" MOD=Space/M/C (Original/Modifiziert/Kunden-Teilobjekt)
actf(1), "Flag: X-Feld der aktiven Version im Modus F_ADDFMODE=X
f_display,
switch_id TYPE sfw_switch_id,
END OF t_fld.

DATA:
gt_fld_copy TYPE TABLE OF t_fld,
ls_fld_copy TYPE t_fld,
gt_dd03p TYPE TABLE OF dd03p.

DATA: get_state TYPE dctablget,


got_state TYPE dctablget,
got_state_d TYPE dctabdget.

PARAMETERS:
p_tab TYPE tabname OBLIGATORY,
p_file TYPE localfile OBLIGATORY.

TYPES:
BEGIN OF ty_str_hdr,
field_name TYPE char20,
END OF ty_str_hdr.

DATA:
lv_file TYPE string,
lit_hdr TYPE STANDARD TABLE OF ty_str_hdr,
lwa_hdr TYPE ty_str_hdr,
lvo_ref TYPE REF TO data,
lvo_ref_line TYPE REF TO data.

FIELD-SYMBOLS:
<lfi_tab> TYPE STANDARD TABLE,
<lfs_tab> TYPE any.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.


CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'p_file'
IMPORTING
file_name = p_file.
START-OF-SELECTION.

get_state-tabd = get_state-tabt = 'A'.

CALL FUNCTION 'DD_TABL_GET'


EXPORTING
get_state = get_state
prid = -2
tabl_name = p_tab
withtext = 'X'
add_typeinfo = 'X'
TABLES
dd03p_tab_a = gt_dd03p
EXCEPTIONS
OTHERS = 2.

gt_fld_copy = gt_dd03p.

CALL FUNCTION 'DD_LIST_TABFIELDS'


EXPORTING
eutype = 'V'
p_with_type = 'X'
TABLES
fieldtab = gt_fld_copy
EXCEPTIONS
not_executed = 1
OTHERS = 2.

END-OF-SELECTION.

CREATE DATA lvo_ref TYPE STANDARD TABLE OF (p_tab).

ASSIGN lvo_ref->* TO <lfi_tab>.

IF <lfi_tab> IS ASSIGNED.
SELECT * FROM (p_tab) INTO TABLE <lfi_tab>.
ENDIF.

DELETE gt_fld_copy WHERE mark IS INITIAL.

LOOP AT <lfi_tab> ASSIGNING FIELD-SYMBOL(<line>).

ENDLOOP.

lv_file = p_file.

CALL METHOD cl_gui_frontend_services=>gui_download


EXPORTING
filename = lv_file
filetype = 'ASC'
write_field_separator = 'X'
fieldnames = lit_hdr
CHANGING
data_tab = <lfi_tab>
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
IF sy-subrc = 0.
WRITE:/ 'File downloaded successfully' COLOR COL_POSITIVE.
ENDIF.

You might also like