‎2010 Mar 03 6:03 PM
Can someone point me to an actual use case or documentation on how to create pivot tables with this function?
‎2010 Mar 03 6:17 PM
‎2010 Mar 04 1:04 PM
In a word, "Yes". I always search there before posting here.
‎2010 Mar 04 2:03 PM
Hi,
This function module populates an existing excel sheet with the data from the ABAP internal table, and also to include headings in excel download Please find below code which shows how to declare and populate the import and important parameters.
REPORT ZEX_DATATOEXCEL .
Parameters: P_file like RLGRAP-FILENAME.
data : begin of int_head occurs 0,
Filed1(20) type c, " Header Data
end of int_head.
data : begin of int_data occurs 0,
Field1(20) type c, " Data
Field2(20) type c,
Field3(20) type c,
Field4(20) type c,
end of int_data.
int_head-Filed1 = 'Sales Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Sold-to-Party'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Purchase Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Ship-to-Party'.
APPEND int_head.
CLEAR int_head.
int_data-field1 = '1JOHN'.
int_data-field2 = '2TOM'.
int_data-field3 = '3BRAD'.
int_data-field4 = '4PETER'.
Append int_data.
Clear int_data.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file " path offile where u need to download
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
TABLES
PIVOT_FIELD_TAB =
data_tab = int_data "internal table with data
fieldnames = int_head "internal table with header
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Shirisha
‎2010 Mar 04 2:19 PM
Shirisha,
My question specifically addresses how to create an Excel file with a *pivot table.*using the FM. Your example does not show that.
Thanks anyway.
‎2020 Jan 15 6:35 AM
DATA:
LV_PATH TYPE STRING,
LV_FULLPATH TYPE STRING,
LV_RESULT TYPE I,
LV_FILENAME TYPE STRING,
LV_FNAME1 TYPE RLGRAP-FILENAME.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOGEXPORTING " FILE DIRECTORY
WINDOW_TITLE = 'File Directory'
INITIAL_DIRECTORY = 'C:\User\Desktop'
CHANGING
FILENAME = LV_FILENAME
PATH = LV_PATH
FULLPATH = LV_FULLPATH
USER_ACTION = LV_RESULT.
LV_FNAME1 = LV_FULLPATH.
*===================================================================================
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'EXPORTING
FILE_NAME = LV_FNAME1 "FILE_NAMETABLES
DATA_TAB = DATA_TAB " Internal Table
FIELDNAMES = IT_JOIN_FIELDS " Header Table
EXCEPTIONS
FILE_NOT_EXIST = 1
FILENAME_EXPECTED = 2
COMMUNICATION_ERROR = 3
OLE_OBJECT_METHOD_ERROR = 4
OLE_OBJECT_PROPERTY_ERROR = 5
INVALID_PIVOT_FIELDS = 6
DOWNLOAD_PROBLEM = 7OTHERS = 8.
IF SY-SUBRC <> 0.
MESSAGE '' .
ELSEIF SY-SUBRC = 0 .
MESSAGE '' .
ENDIF.