01-31-2008 7:54 AM
I am downloading ALV report to Excel sheet by using standard SAP ALV report Menu Option.
When I have MS-office 2003 in my system then there is no problem to download but while having MS-Office 2007, the system is not allowing me to download it.
Is there any compatibilty issue as I am working on SAP Version 4.7 ?
Soln tried: I have even set the macro security level to Low but still downloading gives excel sheet with no data.
Please Help...!!
01-31-2008 8:19 AM
Hi,
use GUI_DOWNLOAD instead. Pass the output table to the alv to the FM.
am sending a sample code for normal report.Plz check the below code that will solve ur problem.ok..
code:
&----
*& Report YITAB_XLS *
*& *
&----
REPORT YITAB_XLS.
-
Internal Table
-
data: begin of gt_data occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
netpr like vbap-netpr,
end of gt_data.
-
Global Variables
-
data: t_vbeln type vbeln.
-
Global Structures
-
data: gv_file type string.
-
Selection Screen
-
selection-screen: begin of block b1 with frame title text-001.
parameters : p_file(90).
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
select-options : s_vbeln for t_vbeln.
selection-screen: end of block b2.
*For Path Selection
at selection-screen on value-request for p_file.
perform path_directory.
*Initilization
initialization.
perform initial.
start-of-selection.
*Fetching data from the Database Table
perform fetch_data.
end-of-selection.
*Download Data to XLS file
perform download_data.
&----
*& Form initial
&----
text
-
--> p1 text
<-- p2 text
-
form initial .
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '5000'.
append s_vbeln.
endform. " initial
&----
*& Form fetch_data
&----
text
-
--> p1 text
<-- p2 text
-
form fetch_data .
select vbeln
posnr
netpr
from vbap
into table gt_data
where vbeln in s_vbeln.
endform. " fetch_data
&----
*& Form path_directory
&----
text
-
--> p1 text
<-- p2 text
-
form path_directory .
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
WINDOW_TITLE = 'SELECT THE PATH'
INITIAL_FOLDER = 'C:/'
CHANGING
selected_folder = gv_file
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2
others = 3
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
p_file = gv_file.
endform. " path_directory
&----
*& Form download_data
&----
text
-
--> p1 text
<-- p2 text
-
form download_data .
gv_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = gv_file
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = '~'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = gt_data
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.
endform. " download_data
Hope this helps..
Reward Points if found helpfull..
Cheers,
Chandra Sekhar.
01-31-2008 8:19 AM
Hi,
use GUI_DOWNLOAD instead. Pass the output table to the alv to the FM.
am sending a sample code for normal report.Plz check the below code that will solve ur problem.ok..
code:
&----
*& Report YITAB_XLS *
*& *
&----
REPORT YITAB_XLS.
-
Internal Table
-
data: begin of gt_data occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
netpr like vbap-netpr,
end of gt_data.
-
Global Variables
-
data: t_vbeln type vbeln.
-
Global Structures
-
data: gv_file type string.
-
Selection Screen
-
selection-screen: begin of block b1 with frame title text-001.
parameters : p_file(90).
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
select-options : s_vbeln for t_vbeln.
selection-screen: end of block b2.
*For Path Selection
at selection-screen on value-request for p_file.
perform path_directory.
*Initilization
initialization.
perform initial.
start-of-selection.
*Fetching data from the Database Table
perform fetch_data.
end-of-selection.
*Download Data to XLS file
perform download_data.
&----
*& Form initial
&----
text
-
--> p1 text
<-- p2 text
-
form initial .
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '5000'.
append s_vbeln.
endform. " initial
&----
*& Form fetch_data
&----
text
-
--> p1 text
<-- p2 text
-
form fetch_data .
select vbeln
posnr
netpr
from vbap
into table gt_data
where vbeln in s_vbeln.
endform. " fetch_data
&----
*& Form path_directory
&----
text
-
--> p1 text
<-- p2 text
-
form path_directory .
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
WINDOW_TITLE = 'SELECT THE PATH'
INITIAL_FOLDER = 'C:/'
CHANGING
selected_folder = gv_file
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2
others = 3
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
p_file = gv_file.
endform. " path_directory
&----
*& Form download_data
&----
text
-
--> p1 text
<-- p2 text
-
form download_data .
gv_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = gv_file
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = '~'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = gt_data
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.
endform. " download_data
Hope this helps..
Reward Points if found helpfull..
Cheers,
Chandra Sekhar.