2008 Jan 17 8:31 AM
Hi Everyone,
My requirement is how to set the DOWNLOAD button on ALV grid ?
and how to download the data from that perticular GRID using that perticular button
and how to set the flag in the tables for those fields wt i downloaded from defferent tables?
can any give the solution
Tks in advance
2008 Jan 17 11:32 AM
Hi Phani,
SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE text-b03.
SELECTION-SCREEN : BEGIN OF LINE.
PARAMETERS : rb_epc RADIOBUTTON GROUP rbg4.
SELECTION-SCREEN : COMMENT (14) text-b2p.
PARAMETERS : p_elfile LIKE rlgrap-filename.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : END OF BLOCK b3.
u can creat f4 options for down load file.
u can create chek box like if u check display alv grid, un check download file.
loop at u r final internal table.
and pass values, then concatenate final internal table into t_file separated by cama, then append t_file and display alv grid pass value t_outtab = t_final.
this information is usful for u.plz give me points.
Regards,
Ram
2008 Jan 17 9:02 PM
Hi ,
1. First you create Z-PFstatus in your ALV grid . And call that ZPF status in to ALV user command . There you need to write the follwing code for Download button.
case sy-ucomm.
when 'DOWNLOAD'.
if NOT gt_outtab[] IS INITIAL. " where gt_outtab[] is your final output table which has dipaly on output list.
lt_viewdat-zmstatus = text-344.
lt_viewdat-zmarticle = text-388.
lt_viewdat-zmarticledesc = text-389.
lt_viewdat-zmcategory = text-448.
lt_viewdat-zmclass = text-332.
lt_viewdat-zmstyle = text-333.
append lt_viewdat. This one giving the header details on your XL. sheet. you can fill the description according to your requirment.
LOOP AT gt_outtab INTO lw_outtab. " where lw_outtab is work area.
MOVE-CORRESPONDING lw_outtab TO lt_viewdat.
APPEND lt_viewdat. " This is appending your output records to lt_viewdat internal table.
IF NOT lt_viewdat[] IS INITIAL.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = gc_title " Give the title for this XL sheet - it like title of your data
default_extension = 'TXT'
DEFAULT_FILE_NAME =
WITH_ENCODING =
FILE_FILTER =
INITIAL_DIRECTORY =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = lv_filename " File name.
path = lv_filepath "Where you need to save
fullpath = lv_fullpath "Where you need to save
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4
.
IF sy-subrc = 0 AND NOT lv_fullpath IS INITIAL.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = lv_fullpath
filetype = 'DAT'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = lt_viewdat[]
FIELDNAMES =
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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSE.
MESSAGE 'Please enter a file name' type 'I'.
ENDIF.
ELSE.
MESSAGE 'No Records Exists'(301) TYPE 'I'.
ENDIF.
ENDIF.
This will really helping you and solve your problem.