SAP ABAP Program-List transactions
Program February 20th, 2008Below ABAP Program(report) is for List transactions.
*———————————————————————-*
* REPORT Z_TRANSACTIONS *
*———————————————————————-*
* TEXT ELEMENTS
* ————-
* Heading
* Transaction code Text
*
* Selection texts
* P_DNLD Download?
* P_FILE Filename:
* S_SPRSL Language:
* S_TCODE Transaction Code:
*
* Text Symbols
* 001 Transaction Selection
* 002 Download Option
* 003 Filename
*———————————————————————-*
REPORT z_transactions.
TABLES: tstct.
TYPES: BEGIN OF itab_tx,
tcode LIKE tstct-tcode,
ttext LIKE tstct-ttext,
END OF itab_tx.
DATA: itab_tx TYPE itab_tx OCCURS 0 WITH HEADER LINE,
tx TYPE itab_tx,
itab_file LIKE sval OCCURS 0 WITH HEADER LINE,
p_file LIKE rlgrap-filename,
returncode LIKE sy-subrc,
filestring TYPE string.
DATA: BEGIN OF fields OCCURS 2.
INCLUDE STRUCTURE sval.
DATA: END OF fields.
* text-001 = Transaction Selection
SELECTION-SCREEN BEGIN OF BLOCK transx WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_tcode FOR tstct-tcode,
s_sprsl FOR tstct-sprsl.
SELECTION-SCREEN END OF BLOCK transx.
* text-002 = Download Option
SELECTION-SCREEN BEGIN OF BLOCK dld WITH FRAME TITLE text-002.
PARAMETERS: p_dnld TYPE c AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK dld.
AT SELECTION-SCREEN OUTPUT.
p_file = ‘C:\SAPTXlist.xls’.
p_dnld = ‘X’.
MOVE ‘I’ TO s_sprsl-sign.
MOVE ‘EQ’ TO s_sprsl-option.
MOVE ‘EN’ TO s_sprsl-low.
APPEND s_sprsl.
START-OF-SELECTION.
REFRESH itab_tx.
SELECT * FROM tstct INTO CORRESPONDING FIELDS OF TABLE itab_tx
WHERE tcode IN s_tcode AND sprsl IN s_sprsl.
IF sy-subrc <> 0.
MESSAGE s265(sf).
ELSE.
SORT itab_tx BY tcode.
LOOP AT itab_tx.
WRITE: /1 itab_tx-tcode(20),
AT 20 itab_tx-ttext.
ENDLOOP.
IF p_dnld = ‘X’.
CLEAR fields.
fields-tabname = ‘RLGRAP’.
fields-fieldname = ‘FILENAME’.
fields-value = p_file.
fields-field_attr = ‘00′.
APPEND fields.
CALL FUNCTION ‘POPUP_GET_VALUES’
EXPORTING
popup_title = text-003
IMPORTING
returncode = returncode
TABLES
fields = fields
EXCEPTIONS
error_in_fields = 1
OTHERS = 2.
CHECK returncode EQ space.
filestring = fields-value.
CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename = filestring
write_field_separator = ‘,’
TABLES
data_tab = itab_tx
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
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE s999(b1) WITH ‘File ‘ filestring
‘ NOT created!’.
ELSE.
MESSAGE s999(b1) WITH ‘File ‘ filestring
‘ Created successfully!’.
ENDIF. “Check on download success
ENDIF. “Download
ENDIF. “Check on selection
Technorati Tags: SAP,ABAP,List,TCODE
Recent Comments