11-10-2005 8:16 PM
hello I have an internal table that i want to create into a pivot table. could someone direct me to the right path! here is the same code.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
FILE_NAME = P_SPATH <- path
CREATE_PIVOT = 'YES'
TABLES
PIVOT_FIELD_TAB = XOUT
DATA_TAB = COMBINED <- itab
FIELDNAMES = XOUT
it give me and exception of communication_error. any ideas
11-10-2005 8:31 PM
Here is the example code for pivotal excel sheet creation.
Some variables used in the form are global but it is good enough to understand the concept behind.
LOOP AT i_tabinclude.
CLEAR h_sema.
h_sema-col_no = sy-tabix.
h_sema-col_src = sy-tabix.
CASE i_tabinclude-inttype.
WHEN 'Z'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'AVG'.
WHEN 'C'.
h_sema-col_typ = 'STR'.
h_sema-col_ops = 'NOP'.
WHEN 'X'.
h_sema-col_typ = 'STR'.
h_sema-col_ops = 'NOP'.
WHEN 'T'.
h_sema-col_typ = 'STR'.
h_sema-col_ops = 'NOP'.
WHEN 'P'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'ADD'.
WHEN 'F'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'ADD'.
WHEN 'I'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'ADD'.
WHEN 'N'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'ADD'.
WHEN 'D'.
h_sema-col_typ = 'DAT'.
h_sema-col_ops = 'NOP'.
WHEN OTHERS.
h_sema-col_typ = 'STR'.
h_sema-col_ops = 'NOP'.
ENDCASE.
APPEND h_sema.
*--- Spaltenüberschriften ------------------------------------------
h_hkey-col_no = sy-tabix.
h_hkey-row_no = 1.
h_hkey-col_name = i_tabinclude-scrtext_m.
APPEND h_hkey.
ENDLOOP.
DESCRIBE TABLE h_sema LINES h_n_att_cols.
h_repid = sy-repid.
h_title = sy-title.
h_so_title = sy-title.
h_tabname = 'SYST'.
h_langu = sy-langu.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = h_langu
tabname = h_tabname
withtext = 'X'
TABLES
fieldtab = h_fieldtab
EXCEPTIONS
no_texts_found.
h_online_text-line_no = 1.
LOOP AT h_fieldtab WHERE fieldname = 'TITLE'.
ENDLOOP.
h_online_text-info_name = h_fieldtab-scrtext_l.
h_online_text-info_value = sy-title.
APPEND h_online_text.
h_print_text-hf = 'F'.
h_print_text-lcr = 'R'.
h_print_text-line_no = 1.
h_print_text-text = sy-title.
APPEND h_print_text.
h_online_text-line_no = 2.
LOOP AT h_fieldtab WHERE fieldname = 'UNAME'.
ENDLOOP.
h_online_text-info_name = h_fieldtab-scrtext_l.
h_online_text-info_value = sy-uname.
APPEND h_online_text.
h_print_text-hf = 'F'.
h_print_text-lcr = 'R'.
h_print_text-line_no = 2.
h_print_text-text = sy-uname.
APPEND h_print_text.
h_online_text-line_no = 3.
LOOP AT h_fieldtab WHERE fieldname = 'DATUM'.
ENDLOOP.
h_online_text-info_name = h_fieldtab-scrtext_l.
WRITE sy-datlo TO h_online_text-info_value.
APPEND h_online_text.
h_print_text-hf = 'F'.
h_print_text-lcr = 'R'.
h_print_text-line_no = 3.
WRITE sy-datlo TO h_print_text-text.
APPEND h_print_text.
CALL FUNCTION 'PM_NUMBER_OF_KEY_COL'
EXPORTING
key_col_default = 1
key_col_max = h_n_att_cols
IMPORTING
key_col = h_n_vrt_keys
EXCEPTIONS
cancel = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO h_n_vrt_keys TIMES.
h_index = sy-index.
READ TABLE h_sema INDEX h_index.
h_sema-col_ops = 'DFT'.
MODIFY h_sema INDEX h_index.
READ TABLE h_hkey INDEX 1.
h_vkey-col_no = h_index.
h_vkey-col_name = h_hkey-col_name.
APPEND h_vkey.
DELETE h_hkey INDEX 1.
ENDDO.
h_n_att_cols = h_n_att_cols - h_n_vrt_keys.
LOOP AT h_hkey.
h_hkey-col_no = h_hkey-col_no - h_n_vrt_keys.
MODIFY h_hkey.
ENDLOOP.
* Begin - Add 'actuals to' and 'versn' to the print out. *
h_print_text-hf = 'F'.
h_print_text-lcr = 'R'.
h_print_text-line_no = 4.
CONCATENATE 'Actuals Through'(064) s_perbl-low INTO h_print_text-text
SEPARATED BY space.
APPEND h_print_text.
h_print_text-line_no = 6.
CONCATENATE 'Version'(063) p_versn INTO h_print_text-text
SEPARATED BY space.
APPEND h_print_text.
h_online_text-line_no = 4.
h_online_text-info_name = 'Actuals Through'(064).
h_online_text-info_value = s_perbl-low.
APPEND h_online_text.
h_online_text-line_no = 5.
h_online_text-info_name = 'Version'(063).
h_online_text-info_value = p_versn.
APPEND h_online_text.
h_online_text-line_no = 6.
h_online_text-info_name = 'Currency'(070). h_online_text-info_value = v_ledger_waers.
APPEND h_online_text.
DATA: i_data LIKE i_summary OCCURS 0 WITH HEADER LINE.
i_data[] = i_summary[].
i_data-pspnr = 1.
i_data-psphi = 1.
MODIFY i_data TRANSPORTING pspnr psphi WHERE psphi NE 1.
* End - Add 'actuals to' and 'versn' to the print out. *
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
sema_type = 'X'
filename = h_repid
header_1 = h_title
so_title = h_so_title
no_dialog = ' '
no_start = ' '
n_att_cols = h_n_att_cols
n_hrz_keys = 1
n_vrt_keys = h_n_vrt_keys
TABLES
data = i_data
hkey = h_hkey
online_text = h_online_text
print_text = h_print_text
sema = h_sema
vkey = h_vkey
EXCEPTIONS
cancelled_by_user = 01
data_too_big = 02
dim_mismatch_data = 03
dim_mismatch_sema = 04
dim_mismatch_vkey = 05
error_in_hkey = 06
error_in_sema = 07
file_open_error = 08
file_write_error = 09
inv_data_range = 10
inv_winsys = 11
inv_xxl = 12.
endform.
Message was edited by: Sharad Agrawal
11-10-2005 8:31 PM
Here is the example code for pivotal excel sheet creation.
Some variables used in the form are global but it is good enough to understand the concept behind.
LOOP AT i_tabinclude.
CLEAR h_sema.
h_sema-col_no = sy-tabix.
h_sema-col_src = sy-tabix.
CASE i_tabinclude-inttype.
WHEN 'Z'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'AVG'.
WHEN 'C'.
h_sema-col_typ = 'STR'.
h_sema-col_ops = 'NOP'.
WHEN 'X'.
h_sema-col_typ = 'STR'.
h_sema-col_ops = 'NOP'.
WHEN 'T'.
h_sema-col_typ = 'STR'.
h_sema-col_ops = 'NOP'.
WHEN 'P'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'ADD'.
WHEN 'F'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'ADD'.
WHEN 'I'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'ADD'.
WHEN 'N'.
h_sema-col_typ = 'NUM'.
h_sema-col_ops = 'ADD'.
WHEN 'D'.
h_sema-col_typ = 'DAT'.
h_sema-col_ops = 'NOP'.
WHEN OTHERS.
h_sema-col_typ = 'STR'.
h_sema-col_ops = 'NOP'.
ENDCASE.
APPEND h_sema.
*--- Spaltenüberschriften ------------------------------------------
h_hkey-col_no = sy-tabix.
h_hkey-row_no = 1.
h_hkey-col_name = i_tabinclude-scrtext_m.
APPEND h_hkey.
ENDLOOP.
DESCRIBE TABLE h_sema LINES h_n_att_cols.
h_repid = sy-repid.
h_title = sy-title.
h_so_title = sy-title.
h_tabname = 'SYST'.
h_langu = sy-langu.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = h_langu
tabname = h_tabname
withtext = 'X'
TABLES
fieldtab = h_fieldtab
EXCEPTIONS
no_texts_found.
h_online_text-line_no = 1.
LOOP AT h_fieldtab WHERE fieldname = 'TITLE'.
ENDLOOP.
h_online_text-info_name = h_fieldtab-scrtext_l.
h_online_text-info_value = sy-title.
APPEND h_online_text.
h_print_text-hf = 'F'.
h_print_text-lcr = 'R'.
h_print_text-line_no = 1.
h_print_text-text = sy-title.
APPEND h_print_text.
h_online_text-line_no = 2.
LOOP AT h_fieldtab WHERE fieldname = 'UNAME'.
ENDLOOP.
h_online_text-info_name = h_fieldtab-scrtext_l.
h_online_text-info_value = sy-uname.
APPEND h_online_text.
h_print_text-hf = 'F'.
h_print_text-lcr = 'R'.
h_print_text-line_no = 2.
h_print_text-text = sy-uname.
APPEND h_print_text.
h_online_text-line_no = 3.
LOOP AT h_fieldtab WHERE fieldname = 'DATUM'.
ENDLOOP.
h_online_text-info_name = h_fieldtab-scrtext_l.
WRITE sy-datlo TO h_online_text-info_value.
APPEND h_online_text.
h_print_text-hf = 'F'.
h_print_text-lcr = 'R'.
h_print_text-line_no = 3.
WRITE sy-datlo TO h_print_text-text.
APPEND h_print_text.
CALL FUNCTION 'PM_NUMBER_OF_KEY_COL'
EXPORTING
key_col_default = 1
key_col_max = h_n_att_cols
IMPORTING
key_col = h_n_vrt_keys
EXCEPTIONS
cancel = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO h_n_vrt_keys TIMES.
h_index = sy-index.
READ TABLE h_sema INDEX h_index.
h_sema-col_ops = 'DFT'.
MODIFY h_sema INDEX h_index.
READ TABLE h_hkey INDEX 1.
h_vkey-col_no = h_index.
h_vkey-col_name = h_hkey-col_name.
APPEND h_vkey.
DELETE h_hkey INDEX 1.
ENDDO.
h_n_att_cols = h_n_att_cols - h_n_vrt_keys.
LOOP AT h_hkey.
h_hkey-col_no = h_hkey-col_no - h_n_vrt_keys.
MODIFY h_hkey.
ENDLOOP.
* Begin - Add 'actuals to' and 'versn' to the print out. *
h_print_text-hf = 'F'.
h_print_text-lcr = 'R'.
h_print_text-line_no = 4.
CONCATENATE 'Actuals Through'(064) s_perbl-low INTO h_print_text-text
SEPARATED BY space.
APPEND h_print_text.
h_print_text-line_no = 6.
CONCATENATE 'Version'(063) p_versn INTO h_print_text-text
SEPARATED BY space.
APPEND h_print_text.
h_online_text-line_no = 4.
h_online_text-info_name = 'Actuals Through'(064).
h_online_text-info_value = s_perbl-low.
APPEND h_online_text.
h_online_text-line_no = 5.
h_online_text-info_name = 'Version'(063).
h_online_text-info_value = p_versn.
APPEND h_online_text.
h_online_text-line_no = 6.
h_online_text-info_name = 'Currency'(070). h_online_text-info_value = v_ledger_waers.
APPEND h_online_text.
DATA: i_data LIKE i_summary OCCURS 0 WITH HEADER LINE.
i_data[] = i_summary[].
i_data-pspnr = 1.
i_data-psphi = 1.
MODIFY i_data TRANSPORTING pspnr psphi WHERE psphi NE 1.
* End - Add 'actuals to' and 'versn' to the print out. *
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
sema_type = 'X'
filename = h_repid
header_1 = h_title
so_title = h_so_title
no_dialog = ' '
no_start = ' '
n_att_cols = h_n_att_cols
n_hrz_keys = 1
n_vrt_keys = h_n_vrt_keys
TABLES
data = i_data
hkey = h_hkey
online_text = h_online_text
print_text = h_print_text
sema = h_sema
vkey = h_vkey
EXCEPTIONS
cancelled_by_user = 01
data_too_big = 02
dim_mismatch_data = 03
dim_mismatch_sema = 04
dim_mismatch_vkey = 05
error_in_hkey = 06
error_in_sema = 07
file_open_error = 08
file_write_error = 09
inv_data_range = 10
inv_winsys = 11
inv_xxl = 12.
endform.
Message was edited by: Sharad Agrawal
11-10-2005 8:48 PM
I'm trying to export the internal table to excel and convert it into a pivot table. not creating the pivot table in sap. I use the function MS_EXCEL_OLE_STANDARD_DAT , but it give me error of communication. any help there!
11-10-2005 11:10 PM
That's exactly the code, I supplied to you, is doing. The <b>XXL_FULL_API</b> function module is to call <b>APIs of EXCEL</b>. It exports the data into excel and convert it into pivot table.
11-11-2005 1:30 AM
Hi Ervin,
Here is the sample code to create pivot table from an internal table. This code works good and tested, try this .
loop at it_vbak.
it_vbakp-vbeln = it_vbak-vbeln.
it_vbakp-fkimg = it_vbak-fkimg.
it_vbakp-netwr = it_vbak-netwr.
it_vbakp-stprs = it_vbak-stprs.
it_vbakp-stprs_pgi = it_vbak-stprs_pgi.
it_vbakp-vbeln_del = it_vbak-vbeln_del.
it_vbakp-name1 = it_vbak-name1.
it_vbakp-kunnr = it_vbak-kunnr.
it_vbakp-kunnr_ship = it_vbak-kunnr_ship.
it_vbakp-kunag = it_vbak-kunag.
it_vbakp-ernam = it_vbak-ernam.
it_vbakp-erdat = it_vbak-erdat.
it_vbakp-wadat_ist = it_vbak-wadat_ist.
it_vbakp-matnr = it_vbak-matnr.
it_vbakp-charg = it_vbak-charg.
it_vbakp-lgort = it_vbak-lgort.
it_vbakp-augru1 = it_vbak-augru1.
it_vbakp-boxid = it_vbak-boxid.
it_vbakp-aubel = it_vbak-aubel.
it_vbakp-xblnr = it_vbak-xblnr.
it_vbakp-kwmeng = it_vbak-kwmeng.
it_vbakp-netwr_rma = it_vbak-netwr_rma.
append it_vbakp.
clear it_vbakp.
endloop.
data: xmpl_header1 like gxxlt_p-text value 'Colour Corporation',
xmpl_header2 like gxxlt_p-text value 'Overall Business Figures'.
data begin of xmplt_o occurs 1.
include structure gxxlt_o.
data end of xmplt_o.
data begin of xmplt_p occurs 1.
include structure gxxlt_p.
data end of xmplt_p.
data begin of xmplt_h occurs 1.
include structure gxxlt_h.
data end of xmplt_h.
data begin of xmplt_v occurs 1.
include structure gxxlt_v.
data end of xmplt_v.
data begin of xmplt_s occurs 1.
include structure gxxlt_s.
data end of xmplt_s.
xmpl_header1 = 'Header 1'.
xmpl_header2 = 'Header 2'.
***********************
xmplt_h-col_no = 1 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Delivery-No.' .
append xmplt_h .
xmplt_h-col_no = 2 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Customer Name'.
append xmplt_h .
xmplt_h-col_no = 3 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Sold-to-party' .
append xmplt_h .
xmplt_h-col_no = 4 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Ship-to-party' .
append xmplt_h .
xmplt_h-col_no = 5 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Bill-to-party' .
append xmplt_h .
xmplt_h-col_no = 6 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Created By' .
append xmplt_h .
xmplt_h-col_no = 7 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Created On' .
append xmplt_h .
xmplt_h-col_no = 8 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Pgi-Date' .
append xmplt_h .
xmplt_h-col_no = 9 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Material No.' .
append xmplt_h .
xmplt_h-col_no = 10 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Batch No.' .
append xmplt_h .
xmplt_h-col_no = 11.
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Stor-Loc' .
append xmplt_h .
xmplt_h-col_no = 12 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Order Reason Text' .
append xmplt_h .
xmplt_h-col_no = 13 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Boxid' .
append xmplt_h .
xmplt_h-col_no = 14.
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Original S.O' .
append xmplt_h .
xmplt_h-col_no = 15.
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Invoice No.' .
append xmplt_h .
*----
xmplt_h-col_no = 16 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'RMA Qty' .
append xmplt_h .
xmplt_h-col_no = 17.
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'RMA Amt' .
append xmplt_h .
*********************************************************
xmplt_v-col_no = 1 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'RMA Number' .
append xmplt_v .
xmplt_v-col_no = 2 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'Act.Receipt.Qty' .
append xmplt_v .
xmplt_v-col_no = 3 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'Act.Receipt.Amt'.
append xmplt_v .
xmplt_v-col_no = 4 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'Std Cost Current'.
append xmplt_v .
xmplt_v-col_no = 5 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'Std Cost At PGI Date' .
append xmplt_v .
**************************************************
*Columns to display
************************************************
xmplt_s-col_no = 1 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 2 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 3 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 4 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 5 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 6 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 7 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 8 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 9 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 10 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 11.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 12.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 13.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 14.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 15.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 16.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 17.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 18.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 19.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 20.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 21 .
xmplt_s-col_typ = 'NUM' .
xmplt_s-col_ops = 'ADD' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 22 .
xmplt_s-col_typ = 'NUM' .
xmplt_s-col_ops = 'ADD' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
*****************************************************************
******************************************************************
call function 'XXL_FULL_API'
exporting
n_vrt_keys = 5
n_att_cols = 17
n_hrz_keys = 1
DATA_STARTING_AT = 5
DATA_ENDING_AT = 54
filename = ' '
header_1 = xmpl_header1
header_2 = xmpl_header2
sema_type = 'X'
no_dialog = space
tables
vkey = xmplt_v
hkey = xmplt_h
data = it_vbakp
sema = xmplt_s
online_text = xmplt_o
print_text = xmplt_p
exceptions
file_open_error = 71
file_write_error = 72
inv_winsys = 73
inv_xxl = 74
cancelled_by_user = 75
others = 99.
Thanks,
Nethaji.
11-11-2005 1:31 AM
Hi Ervin,
Here is the sample code to create pivot table from an internal table. This code works good and tested, try this .
loop at it_vbak.
it_vbakp-vbeln = it_vbak-vbeln.
it_vbakp-fkimg = it_vbak-fkimg.
it_vbakp-netwr = it_vbak-netwr.
it_vbakp-stprs = it_vbak-stprs.
it_vbakp-stprs_pgi = it_vbak-stprs_pgi.
it_vbakp-vbeln_del = it_vbak-vbeln_del.
it_vbakp-name1 = it_vbak-name1.
it_vbakp-kunnr = it_vbak-kunnr.
it_vbakp-kunnr_ship = it_vbak-kunnr_ship.
it_vbakp-kunag = it_vbak-kunag.
it_vbakp-ernam = it_vbak-ernam.
it_vbakp-erdat = it_vbak-erdat.
it_vbakp-wadat_ist = it_vbak-wadat_ist.
it_vbakp-matnr = it_vbak-matnr.
it_vbakp-charg = it_vbak-charg.
it_vbakp-lgort = it_vbak-lgort.
it_vbakp-augru1 = it_vbak-augru1.
it_vbakp-boxid = it_vbak-boxid.
it_vbakp-aubel = it_vbak-aubel.
it_vbakp-xblnr = it_vbak-xblnr.
it_vbakp-kwmeng = it_vbak-kwmeng.
it_vbakp-netwr_rma = it_vbak-netwr_rma.
append it_vbakp.
clear it_vbakp.
endloop.
data: xmpl_header1 like gxxlt_p-text value 'Colour Corporation',
xmpl_header2 like gxxlt_p-text value 'Overall Business Figures'.
data begin of xmplt_o occurs 1.
include structure gxxlt_o.
data end of xmplt_o.
data begin of xmplt_p occurs 1.
include structure gxxlt_p.
data end of xmplt_p.
data begin of xmplt_h occurs 1.
include structure gxxlt_h.
data end of xmplt_h.
data begin of xmplt_v occurs 1.
include structure gxxlt_v.
data end of xmplt_v.
data begin of xmplt_s occurs 1.
include structure gxxlt_s.
data end of xmplt_s.
xmpl_header1 = 'Header 1'.
xmpl_header2 = 'Header 2'.
***********************
xmplt_h-col_no = 1 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Delivery-No.' .
append xmplt_h .
xmplt_h-col_no = 2 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Customer Name'.
append xmplt_h .
xmplt_h-col_no = 3 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Sold-to-party' .
append xmplt_h .
xmplt_h-col_no = 4 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Ship-to-party' .
append xmplt_h .
xmplt_h-col_no = 5 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Bill-to-party' .
append xmplt_h .
xmplt_h-col_no = 6 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Created By' .
append xmplt_h .
xmplt_h-col_no = 7 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Created On' .
append xmplt_h .
xmplt_h-col_no = 8 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Pgi-Date' .
append xmplt_h .
xmplt_h-col_no = 9 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Material No.' .
append xmplt_h .
xmplt_h-col_no = 10 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Batch No.' .
append xmplt_h .
xmplt_h-col_no = 11.
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Stor-Loc' .
append xmplt_h .
xmplt_h-col_no = 12 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Order Reason Text' .
append xmplt_h .
xmplt_h-col_no = 13 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Boxid' .
append xmplt_h .
xmplt_h-col_no = 14.
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Original S.O' .
append xmplt_h .
xmplt_h-col_no = 15.
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'Invoice No.' .
append xmplt_h .
*----
xmplt_h-col_no = 16 .
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'RMA Qty' .
append xmplt_h .
xmplt_h-col_no = 17.
xmplt_h-row_no = 1 .
xmplt_h-col_name = 'RMA Amt' .
append xmplt_h .
*********************************************************
xmplt_v-col_no = 1 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'RMA Number' .
append xmplt_v .
xmplt_v-col_no = 2 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'Act.Receipt.Qty' .
append xmplt_v .
xmplt_v-col_no = 3 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'Act.Receipt.Amt'.
append xmplt_v .
xmplt_v-col_no = 4 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'Std Cost Current'.
append xmplt_v .
xmplt_v-col_no = 5 .
*xmplt_v-row_no = 2 .
xmplt_v-col_name = 'Std Cost At PGI Date' .
append xmplt_v .
**************************************************
*Columns to display
************************************************
xmplt_s-col_no = 1 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 2 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 3 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 4 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 5 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 6 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 7 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 8 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 9 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 10 .
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 11.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 12.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 13.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 14.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 15.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 16.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 17.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 18.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 19.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 20.
xmplt_s-col_typ = 'STR' .
xmplt_s-col_ops = 'DFT' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 21 .
xmplt_s-col_typ = 'NUM' .
xmplt_s-col_ops = 'ADD' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
xmplt_s-col_no = 22 .
xmplt_s-col_typ = 'NUM' .
xmplt_s-col_ops = 'ADD' .
xmplt_s-col_src = 0 .
xmplt_s-col_cur = 0 .
append xmplt_s .
*****************************************************************
******************************************************************
call function 'XXL_FULL_API'
exporting
n_vrt_keys = 5
n_att_cols = 17
n_hrz_keys = 1
DATA_STARTING_AT = 5
DATA_ENDING_AT = 54
filename = ' '
header_1 = xmpl_header1
header_2 = xmpl_header2
sema_type = 'X'
no_dialog = space
tables
vkey = xmplt_v
hkey = xmplt_h
data = it_vbakp
sema = xmplt_s
online_text = xmplt_o
print_text = xmplt_p
exceptions
file_open_error = 71
file_write_error = 72
inv_winsys = 73
inv_xxl = 74
cancelled_by_user = 75
others = 99.
Thanks,
Nethaji.
11-11-2005 6:19 AM
Hi Ervin Chang
Instead of 'MS_EXCEL_OLE_STANDARD_DAT'.I am Using 'SAP_CONVERT_TO_XLS_FORMAT'.which converts Data in Internal table to an Excel Sheet.You can specify the path of your Excel file in parameter <b>i_filename</b> of Function module <b>'SAP_CONVERT_TO_XLS_FORMAT'</b>.
Here is the Code:
-
REPORT ZVKRTEST.
DATA: BEGIN OF intab occurs 0,
mandt LIKE mara-mandt,
matnr LIKE mara-matnr,
ersda LIKE mara-ersda,
ernam LIKE mara-ernam,
laeda LIKE mara-laeda,
aenam LIKE mara-aenam,
END OF intab.
start-of-selection.
select mandt matnr ersda laeda aenam from mara
into corresponding fields
of table intab up to 30 rows.
loop at intab.
write:/ intab-matnr,intab-ersda,intab-ernam,intab-laeda,intab-aenam.
clear intab.
endloop.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ','
I_LINE_HEADER =
i_filename = 'c:\test123.xls'
I_APPL_KEEP = ' '
tables
i_tab_sap_data = intab.
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
-
Cheers,
Vijay Raheja
11-14-2005 4:37 PM
thank you guys! I'll try every one of it. thanks for the help. since I don't know which one works right now. I'll give everyone 2 for the help. I'll award after i finish the program. thanks again for all the suggestions.
ervin
11-14-2005 5:04 PM
Hi Ervin,
You can also use function module
<b>'ALV_XXL_CALL'</b>. Populate fieldcatalog as we do for ALV and pass to this function module.
So no need to do much coding to populate coulmn wise.
Hope this will help you.
Thanks & Regards,
Siri.
Kindly award points if the answer is useful.