Want to export output of alv grid to excel automatically
hi friends.............
i want to export output of alv grid without displaying on screen to excel file .......................
how i m able to do it ..............................
in the same way as after alv grid display click on LOCAL FILE-> SPREADSHEET-> ........................
plz rply me soon if anyone of u know abt that.................
thanks allot.............
actually in output through 'REUSE_ALV_GRID_DISPLAY' some title is also there through TOP_OF_PAGE how can download it also and data table in excel sheet ...................
actually when an alv output is displayed then some title data is also displayed in alv grid then we can download it by clicking on icon 'local file--> spreadsheet........and soon ' ..........
my req. is download it automatically without doing this process and without displaying it on screen......... it means i want to interrupt to alv grid output to only download without displaying it in output screen............
if u clear my question then reply me.............
Similar Messages
-
Total problem in Exporting ALV GRID to Excel
Hi all,
I have manipulated the Total of ALV Grid by using GET_SUBTOTALS and REFRESH method of CL_GUI_ALV_GRID. The ALV Output is also correct. When i export to Excel,only the Original total is displaying not the calculated one. How to download the exact output which is displaying in the ALV Grid to Excel.
Please help me out to solve this.
Thanks,
RameshDEAR,
AS U WANT UPLOAD WITH THE SUB TOTAL YOU TRY THIS.
FIRST to get subtotal in ALV output you select at least one column of total and then press ctrl + F6 . u will see the sub total .
and now how to download it so press ctrl + shift + F9 .
now screen appears and select second option ie spreadsheet and press enter
now a screen appear in wich u have to give file name.
so double click on search button of file name . click on desktop give ur file name as u want suppose zreport u have given.
and save type = excel file.
now save it and then generate it your output bytes will be transmitted .
now u can see in your desktop in your file name . ur output with subtotal.
regards
navin -
Selecting a row in the output of alv grid
hi,
how do i select a row in the output of alv grid?plz help...
regards,
sheeba.Hi,
Please refer the code below:
*& Report ZDEMO_ALVGRID_SELROW *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display capture each row a user has *
*& selected *
REPORT zdemo_alvgrid_selrow .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
SEl, "stores which row user has selected
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-box_fieldname = 'SEL'.
"set field name to store row selection
gd_layout-edit = 'X'. "makes whole ALV table editable
gd_layout-zebra = 'X'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
* i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
* IT_EVENTS = GT_XEVENTS
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 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.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into corresponding fields of table it_ekko.
endform. " DATA_RETRIEVAL
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
WHEN '&DATA_SAVE'. "user presses SAVE
loop at it_ekko into wa_ekko.
if wa_ekko-sel EQ 'X'.
* Process records that have been selected
endif.
endloop.
ENDCASE.
ENDFORM.
Thanks,
Sriram Ponna. -
Wan to add push button in the output of ALV Grid display.
Hi Friends,
I wan to add a Push button in the output of ALV GRID display with STANDARD ikons.
How to copy standard ikons of GRID output.
How to apply the copied status into my code.
Regards,
VijiHi,
Goto SE41, create a pf-status for your alv report program.
On the next screen, click menu EXTRAS --> click option ADJUST TEMPLATES and select radiobutton LIST VIEWER --> you will get all standard buttons of alv in the pf-status.
Delete the unwanted buttons and also you can add new buttons if reqd.
Activate pf-status --> and apply in alv program.
Now to apply this pf-status in your alv report follow code:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_rep_id " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
it_sort = it_sort " sort info
TABLES
t_outtab = it_final " internal table
EXCEPTIONS
program_error = 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.
*& Form pf
* SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
* ON WHICH THE ALV GRID IS DISPLAYED
* -->RT_EXTAB
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_STAT'. "<--pass pf-status name here
ENDFORM. "pf
*& Form USER_COMMAND
* SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
* AND EXECUTE THE APPROPIATE CODE
* -->LV_OKCODE used to capture the function code
* of the user-defined push-buttons
* -->L_SELFIELD text
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
lv_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE lv_okcode.
WHEN '<function_code>'. "<--to handle user actions
ENDCASE.
ENDFORM. "USER_COMMAND
Hope this helps you.
Regards,
Tarun -
ALV grid to excel (.XLS) format issue
im trying to export an ALV grid to excel file using FM 'GUI_DOWNLOAD'.
the output is located at the link below:
http://img393.imageshack.us/my.php?image=excelproblemjt4.jpg
some how the fields arent inside the individual boxes..
can anyone provide me with the solution? thanks
below are the codes of how i implement the 'GUI DOWNLOAD' FM
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file " C:\filename.xls
write_field_separator = 'X'
IMPORTING
filelength = lv_size
TABLES
data_tab = ltt_dataREPORT test0012 .
INCLUDE test_top.
INCLUDE test_f01.
INCLUDE test_alv.
START OF SELECTION
START-OF-SELECTION.
PERFORM get_data.
PERFORM process_data.
END-OF-SELECTION.
IF tt_output IS NOT INITIAL.
PERFORM prepare_excel_data.
Download CSV file to local
IF c_loc = 'X'.
PERFORM convert_to_xls.
PERFORM download_local.
ENDIF.
ELSE.
Show Message when no records selected
MESSAGE I016 WITH TEXT-005.
ENDIF.
PERFORM f_alv_disp.
*& Include test_TOP *
TABLES: vbrk, vbrp, vbak, vbap, kna1.
DATA: total_value TYPE p DECIMALS 2 LENGTH 15.
DATA: total TYPE c LENGTH 5 VALUE 'total'.
TYPE-POOLS
TYPE-POOLS: slis, truxs.
-ALV----
DATA:
wa_alv_layout TYPE slis_layout_alv,
tt_alv_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
tt_alv_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE,
tt_alv_events TYPE slis_t_event WITH HEADER LINE,
wa_sort TYPE slis_sortinfo_alv,
tt_sort TYPE slis_t_sortinfo_alv,
v_pagno TYPE sy-pagno,
s_keyinfo TYPE slis_keyinfo_alv.
TYPES
TYPES: BEGIN OF vbrk,
vbeln TYPE vbrk-vbeln,
fkdat TYPE vbrk-fkdat,
vkorg TYPE vbrk-vkorg,
vtweg TYPE vbrk-vtweg,
spart TYPE vbrk-spart,
kunag TYPE vbrk-kunag,
END OF vbrk,
BEGIN OF vbrp,
vbeln TYPE vbrp-vbeln,
aubel TYPE vbrp-aubel,
vgbel TYPE vbrp-vgbel,
aupos TYPE vbrp-aupos,
END OF vbrp,
BEGIN OF vbak,
vbeln TYPE vbak-vbeln,
auart TYPE vbak-auart,
bstnk TYPE vbak-bstnk,
END OF vbak,
BEGIN OF vbap,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
netwr TYPE vbap-netwr,
mwsbp TYPE vbap-mwsbp,
END OF vbap,
BEGIN OF kna1,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
END OF kna1,
BEGIN OF output,
fkdat TYPE vbrk-fkdat,
vkorg TYPE vbrk-vkorg,
vtweg TYPE vbrk-vtweg,
spart TYPE vbrk-spart,
kunag TYPE vbrk-kunag,
name1 TYPE kna1-name1,
auart TYPE vbak-auart,
bstnk TYPE vbak-bstnk,
aubel TYPE vbrp-aubel,
vgbel TYPE vbrp-vgbel,
total LIKE total_value,
END OF output.
Type for download to excel use.
TYPES: BEGIN OF ty_excel,
col1(20), sp01,
col2(25), sp02,
col3(23), sp03,
col4(14), sp04,
col5(15), sp05,
col6(23), sp06,
col7(13), sp07,
col8(25), sp08,
col9(20), sp09,
col10(30), sp10,
col11(13),
END OF ty_excel.
DATA: wa_vbrk TYPE vbrk,
wa_vbrp TYPE vbrp,
wa_vbak TYPE vbak,
wa_vbap TYPE vbap,
wa_kna1 TYPE kna1,
wa_output TYPE output,
tt_vbrk TYPE STANDARD TABLE OF vbrk,
tt_vbrp TYPE STANDARD TABLE OF vbrp,
tt_vbak TYPE STANDARD TABLE OF vbak,
tt_vbap TYPE STANDARD TABLE OF vbap,
tt_kna1 TYPE STANDARD TABLE OF kna1,
tt_output TYPE STANDARD TABLE OF output.
Table for download to excel use.
DATA: tt_excel TYPE STANDARD TABLE OF ty_excel,
wa_excel LIKE LINE OF tt_excel,
tt_excel_output TYPE truxs_t_text_data.
wa_excel type ty_excel.
Data Declaration for CSV file use
CONSTANTS : c_comma TYPE c VALUE ','.
Selection-Screen
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
SELECT-OPTIONS: s_fkdat FOR vbrk-fkdat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b01.
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
PARAMETERS: p_vkorg TYPE vbrk-vkorg OBLIGATORY.
SELECT-OPTIONS: s_vtweg FOR vbrk-vtweg,
s_spart FOR vbrk-spart.
SELECTION-SCREEN END OF BLOCK b02.
SELECTION-SCREEN BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
SELECT-OPTIONS: s_kunag FOR vbrk-kunag.
SELECTION-SCREEN END OF BLOCK b03.
SELECTION-SCREEN BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
PARAMETERS: c_loc AS CHECKBOX,
p_file LIKE rlgrap-filename DEFAULT 'C:\filename.txt'.
SELECTION-SCREEN END OF BLOCK b04.
*& Include test_F01 *
FORM get_data
FORM get_data.
DATA: lt_vbrk TYPE STANDARD TABLE OF vbrk,
lt_vbrp TYPE STANDARD TABLE OF vbrp.
SELECT vbeln fkdat vkorg vtweg spart kunag
FROM vbrk
INTO TABLE tt_vbrk
WHERE fkdat IN s_fkdat
AND vkorg = p_vkorg
AND vtweg IN s_vtweg
AND spart IN s_spart
AND kunag IN s_kunag.
lt_vbrk[] = tt_vbrk[].
SORT lt_vbrk BY vbeln.
IF lt_vbrk[] IS NOT INITIAL.
SELECT vbeln aubel vgbel aupos
FROM vbrp
INTO TABLE tt_vbrp
FOR ALL ENTRIES IN lt_vbrk
WHERE vbeln = lt_vbrk-vbeln.
ENDIF.
lt_vbrp[] = tt_vbrp[].
SORT lt_vbrp BY aubel.
IF lt_vbrp[] IS NOT INITIAL.
SELECT vbeln auart bstnk
FROM vbak
INTO TABLE tt_vbak
FOR ALL ENTRIES IN lt_vbrp
WHERE vbeln = lt_vbrp-aubel.
ENDIF.
lt_vbrp[] = tt_vbrp[].
SORT lt_vbrp BY aubel aupos.
IF lt_vbrp[] IS NOT INITIAL.
SELECT vbeln posnr netwr mwsbp
FROM vbap
INTO TABLE tt_vbap
FOR ALL ENTRIES IN lt_vbrp
WHERE vbeln = lt_vbrp-aubel
AND posnr = lt_vbrp-aupos.
ENDIF.
lt_vbrk[] = tt_vbrk[].
SORT lt_vbrk BY kunag.
IF lt_vbrk[] IS NOT INITIAL.
SELECT kunnr name1
FROM kna1
INTO TABLE tt_kna1
FOR ALL ENTRIES IN lt_vbrk
WHERE kunnr = lt_vbrk-kunag.
ENDIF.
ENDFORM. "get_data
*& Form process_data
FORM process_data.
LOOP AT tt_vbrk INTO wa_vbrk.
wa_output-fkdat = wa_vbrk-fkdat.
wa_output-vkorg = wa_vbrk-vkorg.
wa_output-vtweg = wa_vbrk-vtweg.
wa_output-spart = wa_vbrk-spart.
wa_output-kunag = wa_vbrk-kunag.
read table tt_vbrp into wa_vbrp with key vbeln = wa_vbrk-vbeln.
if sy-subrc = 0.
wa_output-aubel = wa_vbrp-aubel.
wa_output-vgbel = wa_vbrp-vgbel.
endif.
READ TABLE tt_kna1 INTO wa_kna1 WITH KEY kunnr = wa_vbrk-kunag BINARY SEARCH.
IF sy-subrc = 0.
wa_output-name1 = wa_kna1-name1.
ENDIF.
LOOP AT tt_vbrp INTO wa_vbrp WHERE vbeln = wa_vbrk-vbeln.
wa_output-aubel = wa_vbrp-aubel.
wa_output-vgbel = wa_vbrp-vgbel.
READ TABLE tt_vbak INTO wa_vbak WITH KEY vbeln = wa_vbrp-aubel BINARY SEARCH.
IF sy-subrc = 0.
wa_output-auart = wa_vbak-auart.
wa_output-bstnk = wa_vbak-bstnk.
ENDIF.
READ TABLE tt_vbap INTO wa_vbap WITH KEY vbeln = wa_vbrp-aubel
posnr = wa_vbrp-aupos BINARY SEARCH.
wa_output-total = wa_vbap-netwr + wa_vbap-mwsbp.
APPEND wa_output TO tt_output.
ENDLOOP. "endloop tt_vbrp
wa_output-total = wa_vbap-netwr + wa_vbap-mwsbp.
append wa_output to tt_output.
CLEAR wa_output.
ENDLOOP. "endloop vbrk
ENDFORM. "process_data
*& Form APPEND_EXCEL
FORM append_excel .
wa_excel-sp01 = wa_excel-sp02 = wa_excel-sp03 =
wa_excel-sp04 = wa_excel-sp05 = wa_excel-sp06 =
wa_excel-sp07 = wa_excel-sp08 = wa_excel-sp09 =
wa_excel-sp10.
APPEND wa_excel TO tt_excel. CLEAR wa_excel.
ENDFORM. " APPEND_EXCEL
*& Form PREPARE_EXCEL_DATA
FORM prepare_excel_data .
List's Header for excel file
WRITE 'Billing Date' TO wa_excel-col1.
WRITE 'Sales Organization' TO wa_excel-col2.
WRITE 'Distribution Channel' TO wa_excel-col3.
WRITE 'Division' TO wa_excel-col4.
WRITE 'Sold-to Party' TO wa_excel-col5.
WRITE 'Name of Sold-to Party' TO wa_excel-col6.
WRITE 'Order Type' TO wa_excel-col7.
WRITE 'Customer PO Number' TO wa_excel-col8.
WRITE 'Sales Order Number' TO wa_excel-col9.
WRITE 'Delivery Order Number' TO wa_excel-col10.
WRITE 'Total Value' TO wa_excel-col11.
PERFORM append_excel.
Item data for excel file.
LOOP AT tt_output INTO wa_output.
WRITE wa_output-fkdat TO wa_excel-col1.
WRITE wa_output-vkorg TO wa_excel-col2.
WRITE wa_output-vtweg TO wa_excel-col3.
WRITE wa_output-spart TO wa_excel-col4.
WRITE wa_output-kunag TO wa_excel-col5.
WRITE wa_output-name1 TO wa_excel-col6.
WRITE wa_output-auart TO wa_excel-col7.
WRITE wa_output-bstnk TO wa_excel-col8.
WRITE wa_output-aubel TO wa_excel-col9.
WRITE wa_output-vgbel TO wa_excel-col10.
WRITE wa_output-total TO wa_excel-col11.
PERFORM append_excel.
ENDLOOP.
List's Header for excel file
CONCATENATE '"' 'Billing Date' '"' INTO WA_EXCEL-COL1.
CONCATENATE '"' 'Sales Organization' '"' INTO WA_EXCEL-COL2.
CONCATENATE '"' 'Distribution Channel' '"' INTO WA_EXCEL-COL3.
CONCATENATE '"' 'Division' '"' INTO WA_EXCEL-COL4.
CONCATENATE '"' 'Sold-to Party' '"' INTO WA_EXCEL-COL5.
CONCATENATE '"' 'Name of Sold-to Party' '"' INTO WA_EXCEL-COL6.
CONCATENATE '"' 'Order Type' '"' INTO WA_EXCEL-COL7.
CONCATENATE '"' 'Customer PO Number' '"' INTO WA_EXCEL-COL8.
CONCATENATE '"' 'Sales Order Number' '"' INTO WA_EXCEL-COL9.
CONCATENATE '"' 'Delivery Order Number' '"' INTO WA_EXCEL-COL10.
CONCATENATE '"' 'Total Value' '"' INTO WA_EXCEL-COL11.
PERFORM APPEND_EXCEL.
Item data for excel file.
LOOP AT TT_output INTO WA_output.
CONCATENATE '"' WA_OUTPUT-FKDAT '"' INTO WA_EXCEL-COL1.
CONCATENATE '"' WA_OUTPUT-VKORG '"' INTO WA_EXCEL-COL2.
CONCATENATE '"' WA_OUTPUT-VTWEG '"' INTO WA_EXCEL-COL3.
CONCATENATE '"' WA_OUTPUT-SPART '"' INTO WA_EXCEL-COL4.
CONCATENATE '"' WA_OUTPUT-KUNAG '"' INTO WA_EXCEL-COL5.
CONCATENATE '"' WA_OUTPUT-NAME1 '"' INTO WA_EXCEL-COL6.
CONCATENATE '"' WA_OUTPUT-AUART '"' INTO WA_EXCEL-COL7.
CONCATENATE '"' WA_OUTPUT-BSTNK '"' INTO WA_EXCEL-COL8.
CONCATENATE '"' WA_OUTPUT-AUBEL '"' INTO WA_EXCEL-COL9.
CONCATENATE '"' WA_OUTPUT-VGBEL '"' INTO WA_EXCEL-COL10.
CONCATENATE '"' total '"' INTO WA_EXCEL-COL11.
PERFORM APPEND_EXCEL.
ENDLOOP.
ENDFORM. " PREPARE_EXCEL_DATA
*& Form Convert_to_xls
*form Convert_to_xls.
LOOP AT TT_EXCEL INTO WA_EXCEL.
MOVE WA_EXCEL TO LTT_DATA-TEXT.
APPEND LTT_DATA. CLEAR LTT_DATA.
ENDLOOP.
LV_FILE = P_FILE.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ';'
I_LINE_HEADER =
i_filename = lv_file
I_APPL_KEEP = ' '
tables
i_tab_sap_data = LTT_DATA
CHANGING
I_TAB_CONVERTED_DATA = tt_excel_output
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.
*endform.
*& Form DOWNLOAD_LOCAL
FORM download_local .
TYPES:
BEGIN OF lty_data,
text(800),
END OF lty_data.
DATA:
lv_file TYPE string,
lv_size TYPE i,
lv_msg TYPE bapi_msg,
ltt_data TYPE STANDARD TABLE OF lty_data WITH HEADER LINE.
LOOP AT tt_excel INTO wa_excel.
MOVE wa_excel TO ltt_data-text.
APPEND ltt_data. CLEAR ltt_data.
ENDLOOP.
lv_file = p_file.
CONCATENATE LV_FILE 'file.csv' INTO LV_FILE.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file
write_field_separator = 'X'
FILETYPE = 'ASC'
IMPORTING
filelength = lv_size
TABLES
data_tab = ltt_data
EXCEPTIONS
OTHERS = 1.
IF sy-subrc EQ 0.
"File &1 downloaded successfully - &2 bytes transferred
MESSAGE e419(3e) WITH lv_file lv_size INTO lv_msg. "#EC *
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_msg.
ENDIF.
WRITE LV_MSG.
ENDFORM. " DOWNLOAD_LOCAL
*ENDIF.
*& Include test_ALV *
FORM build_layout .
wa_alv_layout-zebra = 'X'.
wa_alv_layout-colwidth_optimize = 'X'.
wa_alv_layout-window_titlebar = sy-title.
ENDFORM. " build_layout
*& Form f_build_event
text
--> p1 text
<-- p2 text
FORM f_build_event .
REFRESH tt_alv_events.
tt_alv_events-name = slis_ev_top_of_page.
tt_alv_events-form = slis_ev_top_of_page.
APPEND tt_alv_events.
CLEAR tt_alv_events.
tt_alv_events-name = slis_ev_top_of_list.
tt_alv_events-form = slis_ev_top_of_list.
APPEND tt_alv_events.
CLEAR tt_alv_events.
ENDFORM. " f_build_event
*& Form f_alv_disp
text
--> p1 text
<-- p2 text
FORM f_alv_disp.
DATA lv_repid TYPE sy-repid.
REFRESH: tt_alv_fieldcat, tt_alv_events.
PERFORM build_layout.
PERFORM f_build_event.
lv_repid = sy-repid.
PERFORM f_build_fieldcat_summary.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = lv_repid
is_layout = wa_alv_layout
it_fieldcat = tt_alv_fieldcat[]
I_GRID_TITLE = 'Billing Due List Report'
it_sort = tt_sort
i_save = 'A'
it_events = tt_alv_events[]
TABLES
t_outtab = tt_output
EXCEPTIONS
program_error = 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.
ENDFORM. " f_alv_disp
*& Form f_build_fieldcat_SUMMARY
text
--> p1 text
<-- p2 text
FORM f_build_fieldcat_summary .
do_sum no_out outputlen
PERFORM f_fieldcat USING:
'tt_output' 'FKDAT' text-c01 ' ' ' ' '10' ,
'tt_output' 'VKORG' text-c02 ' ' ' ' '10',
'tt_output' 'VTWEG' text-c03 ' ' ' ' '10' ,
'tt_output' 'SPART' text-c04 ' ' ' ' '10' ,
'tt_output' 'KUNAG' text-c05 ' ' ' ' '10' ,
'tt_output' 'NAME1' text-c06 ' ' ' ' '10' ,
'tt_output' 'AUART' text-c07 ' ' ' ' '10' ,
'tt_output' 'BSTNK' text-c08 ' ' ' ' '10' ,
'tt_output' 'AUBEL' text-c09 ' ' ' ' '10' ,
'tt_output' 'VGBEL' text-c10 ' ' ' ' '10' ,
'tt_output' 'TOTAL' text-c11 ' ' ' ' '15' .
ENDFORM. "
*& Form f_fieldcat
FORM f_fieldcat USING pv_a TYPE any
pv_b TYPE any
pv_c TYPE any
pv_d TYPE any
pv_e TYPE any
pv_f TYPE any.
tt_alv_fieldcat-tabname = pv_a.
tt_alv_fieldcat-fieldname = pv_b.
tt_alv_fieldcat-reptext_ddic = pv_c.
tt_alv_fieldcat-do_sum = pv_d.
tt_alv_fieldcat-no_out = pv_e.
tt_alv_fieldcat-outputlen = pv_f.
APPEND tt_alv_fieldcat.
CLEAR tt_alv_fieldcat.
ENDFORM. " f_fieldcat -
Alv Grid to Excel Sheet Downloading problem for Bank account Number(CHAR18)
Hi every one,
I am downloading Alv grid to excel using local file---> spreadsheet
but, the bank account no is populating as like ''11+E213". When press F2 in that column then only its showing the correct value.
If i do download directly from ctrlshiftF7 , its down loading perfectly but my user Needs the Header of the ALV also, Buecause HEader Consists of Payment Date and all details.
I have checked the same from the Satandard table also its also populating in the same way as in the report,
So if any body have valueble suggestions, Please reply soon,
Thanks & Regards,
Raj SHi Lalit,
Thanks for Ur promt reply,
I ahve alraedy Changed the lenght to 25 but it doesnot effect,
But when i concatenate the same number with any one character in front of the A/C No. Its generating perfectly,
But i cant do so as its an account No.
Thanks,
Raj S -
Facing a Problem while downloading the data from ALV Grid to Excel Sheet
Hi Friends,
Iam facing a problem while downloading the data from ALV Grid to excel sheet. This is working fine in Development server , when comes to Quality and Production servers I have this trouble.
I have nearly 11 fields in ALV Grid and out of which one is PO number of length 10 , all the ten numbers are visible in the excel sheet if we download it from development server but when we download it from Quality or Production it is showing only 9 numbers.
Can any one help me out in this case.hi...
if this problems happens dont display the same internal as u finally got.
just create new internal table without calling any standard data elements and domains... but the new internal table s similar like ur final internal table and move all the values to new int table.
for eg.
ur final internal int table for disp,
data : begin of itab occur 0,
matnr like mara-matnr,
end of itab.
create new like this,
data : begin of itab occur 0,
matnr(12) type N,
end of itab. -
Hello, I have a report with an selection screen with a few input parameters. This results in an alv grid being displayed. The users downloads the alv grid to excel. This works fine.
I'd like to include the input parameters as the top row in the downloaded excel, on top of the result set. Is this possible? How do you do it?
Best regards /OttoThis data would have to be included in the ALV grid itself(assuming that you are using the standard excel functionality embedded into the ALV grid).
There are others ways to get around this. You could add a new button to the applicatoin toolbar, where then you would handle the building of the excel file in your custom code.
REgards,
Rich Heilman -
Want to export columns (from a pdf) to excel. Can't find Adobe doco on it. Anyone know how to do this?
Hold the alt key as you select a block of text. There is also a column select option if the table has tabs that mark it as such. With a table, a table icon should show up as you pass over the table if it is properly marked as a table. Without the tabs, you might get strange results with the column select. The information on copying text is in the manual (in my AA8 it is under "Select and copy text").
-
Regarding downlaod the output from ALV grid format
Hi
i want to download the output ALV grid format into excel sheet .
but condition is when ever user press the button (&ZDL) the should be downloaded.
and also how to convert the output into CSV format.hi,
when '&ZDL'.
use this condition
check this one for down loading
try to download an ALV report in excel format using (list ->export -> local file-> soread sheet )
Re: advantages of alv reports
Excel Download to ALV report
hi this is full program
REPORT ZCR_BOMPLANT_DOWNLOAD.
TABLES : MAST , "Material to BOM Link
STKO , "BOM Header
MARA . "General Material Data
TYPES : BEGIN OF TY_MASTER ,
MATNR TYPE MAST-MATNR , "Material Number
WERKS TYPE MAST-WERKS , "Plant
STLAN TYPE MAST-STLAN , "BOM Usage
STLNR TYPE MAST-STLNR , "Bill of material
STLAL TYPE MAST-STLAL , "Alternative BOM
ANDAT TYPE MAST-ANDAT , "Date record created on
AEDAT TYPE MAST-AEDAT , "Date of Last Change
AENAM TYPE MAST-AENAM , "Name of Person Who Changed Object
STLST TYPE STKO-STLST , "BOM status
ZPLP1 TYPE MBEW-ZPLP1 , "Future Planned Price 1
DWERK TYPE MVKE-DWERK , "Delivering Plant (Own or External)
END OF TY_MASTER .
TYPES : MY_TYPE(20) TYPE C.
DATA : IT_MASTER TYPE STANDARD TABLE OF TY_MASTER,
WA_MASTER TYPE TY_MASTER .
DATA : IT_HEADER TYPE TABLE OF MY_TYPE.
DATA : W_PTH TYPE RLGRAP-FILENAME.
DATA : W_FILE TYPE RLGRAP-FILENAME.
*--- Add Header Fields to Header Table ---
APPEND 'Material Number' TO IT_HEADER .
APPEND 'Plant' TO IT_HEADER .
APPEND 'BOM Usage' TO IT_HEADER .
APPEND 'Bill Code' TO IT_HEADER .
APPEND 'Alternative BOM' TO IT_HEADER .
APPEND 'Created On' TO IT_HEADER .
APPEND 'Changed On' TO IT_HEADER .
APPEND 'Changed By' TO IT_HEADER .
APPEND 'BOM Status' TO IT_HEADER .
APPEND 'Planned Price' TO IT_HEADER .
APPEND 'Delivery Plant' TO IT_HEADER .
IF SY-MANDT = '700'.
W_PTH = '
lkdb01\ISD\IS\Software Developments\Developments\Data Files\SAP Dumps\BOM_Available\'.
ELSE.
W_PTH = 'C:\'.
ENDIF.
START-OF-SELECTION.
*--- Load Data to Internal Table ---
SELECT MASTMATNR MASTWERKS MASTSTLAN MASTSTLNR MASTSTLAL MASTANDAT MASTAEDAT MASTAENAM STKO~STLST
INTO TABLE IT_MASTER
FROM MAST
INNER JOIN STKO ON STKOSTLNR EQ MASTSTLNR
AND STKOSTLAL EQ MASTSTLAL
INNER JOIN MARA ON MARAMATNR EQ MASTMATNR
WHERE MARA~MTART LIKE 'ZFG%'
AND STKO~LKENZ NE 'X'
AND STKO~LOEKZ NE 'X'
AND STKO~STLST EQ '1'.
SELECT MAST~MATNR MAST~WERKS MAST~STLAN MAST~STLNR MAST~STLAL MAST~ANDAT MAST~AEDAT MAST~AENAM STKO~STLST MBEW~ZPLP1 MVKE~DWERK
INTO TABLE IT_MASTER
FROM MAST
INNER JOIN STKO ON STKO~STLNR EQ MAST~STLNR
AND STKO~STLAL EQ MAST~STLAL
INNER JOIN MARA ON MARA~MATNR EQ MAST~MATNR
INNER JOIN MBEW ON MBEW~MATNR EQ MAST~MATNR
AND MBEW~BWKEY EQ MAST~WERKS
INNER JOIN MVKE ON MVKE~MATNR EQ MAST~MATNR
WHERE MARA~MTART LIKE 'ZFG%'
AND STKO~LKENZ NE 'X'
AND STKO~LOEKZ NE 'X'
AND STKO~STLST EQ '1'.
IF SY-SUBRC <> 0.
MESSAGE I014(ZLOAD).
ENDIF.
*--- Set Path to Function Module ---
CONCATENATE W_PTH SY-DATUM ' - ' 'BOM_AVAILABLE_PLANT.XLS' INTO W_FILE.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = W_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_MASTER
FIELDNAMES = IT_HEADER
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_EIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
IF SY-SUBRC = 0.
SUBMIT ZI005_MARA_DUMP_SOLIDEAL_N.
MESSAGE I023(ZLOAD) WITH text-001.
ELSE.
MESSAGE I022(ZLOAD) WITH W_FILE. "Errors while downloading.
ENDIF.
END-OF-SELECTION.
SUBMIT ZI005_MARA_DUMP_SOLIDEAL_N. -
Leading Zeros Missing - When exporting data from ALV grid display to Excel
Hi,
Am exporting the data from ALV GRID DISPLAY to Excel sheet using standard toolbar icon 'Local file'
the leading zeros displayed in the ALV output is missing in the EXCEL sheet.
(eg) in ALV o/p - 0029.
in Excel - Only 29 is appearing.
As per the requiement i have to show the leading zeros in excel also.
Pls help on this issue.
Thanks in advance..Hi ,
Please set the property :
wa_fieldcat-lzero = 'X' .
when you are creating field catalog for display alv data .
your prob will solved .
Regards ,
Nilesh Jain -
Problem: User has problems to export ALV Grid to Excel...
Hello experts,
I have a very strange problem with an single user: when she tries to export ALV Grid data from SAP into Excel by List/Export/Spreadsheet, she's only able to export this to an xml-based file on her local client, every other user gets the popup to choose the spreadsheet format (XXL...).
What I did so far:
- Look up Excel Makro Security --> the same as on other desktops
- SAP GUI Patch Level --> the same as on other desktops
- Test with an different user on her desktop on SAP Report S_ALR_87012284 --> it worked perfectly
- User parameters are the same as for the test user
- Security regarding ALV is the same (S_GUI ACTVT = 61...)
Has there ever been a similar problem to anyone else?
Many thanks in advance for your feedback!Hi ,
This problem looks very weired. Just try running that FM from SE37 from the same system and see that what is happening there.... if the problem is similar then it is not the problem of your report and some patch may be missing in that system. -
Exporting content of ALV grid in Web Dynpro for ABAP
Hello Experts
I have a following request which seems to be giving some headaches.
I need to export results from one of the Web Dynpro reports (ABAP) I have developed to the Excel spreadsheet. Results are stored on ALV component. Request is to add header to export file with additional information like report title, selection criteria, date when report has been executed. By default export file contains only column names and data. I have set the header for ALV grid with all extra information I need to be passed to Excel file but it does not seem to be transferred at all.
At the moment I see 2 possible solutions: 1) write my own Excel export 2) use PDF export where it is possible to set header/footer text. None of these solutions are ideal, I'd rather set header in standard Excel export. Is that even possible? Please help.
Regards
Michael
Edited by: Soltuion Manager on Apr 20, 2009 10:08 AM
Edited by: Soltuion Manager on Apr 20, 2009 10:26 AMHello Michael,
I haven't tried using the builtin functionality of ALV to achieve a similar fnctionality as yours but can suggest you a workaround for that. As how you might be already knowing you can try using the CL_WD_RUNTIME_SERVICES=>attach_file_to_response to download the contents into Excel/notepad/word. So just can modify the internal table to contain the extra information that you need. You can use the approach below for using the attach_file_to_response method:
1) First read the table's data into an internal table.
2) Convert the internal table data to STRING format.
3) Now convert it into tab separated format as how desired.
4) Convert this STRING format to XSTRING format
5) Make use of the attach_file_to_response method.
Regards,
Uday
METHOD onactionon_submit .
DATA: lv_node TYPE REF TO if_wd_context_node,
lt_mara TYPE if_main=>elements_mara,
wa_mara TYPE if_main=>element_mara,
lead_selection_index TYPE i,
mara_string TYPE string,
mara_xstring TYPE xstring.
lv_node = wd_context->get_child_node( name = 'MARA' ).
CALL METHOD lv_node->get_static_attributes_table
IMPORTING
table = lt_mara.
LOOP AT lt_mara INTO wa_mara.
CONCATENATE mara_string
wa_mara-matnr
wa_mara-ersda
wa_mara-ernam
wa_mara-matkl
wa_mara-meins
cl_abap_char_utilities=>cr_lf INTO mara_string
SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
ENDLOOP.
** Now you need to add the column headers & the desired extra information through coding to
** mara_string
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = mara_string
IMPORTING
buffer = mara_xstring.
CL_WD_RUNTIME_SERVICES=>attach_file_to_response( i_filename = 'TEMP.XLS'
i_content = mara_xstring
i_mime_type = 'EXCEL' ).
ENDMETHOD. -
hi all,
there is a very typicall requirement to be achieved in ALV grid display.
i need to display the subtotal of a field for which line item should not be shown.
In this case "Number of Purchase orders" should not have any line itme but it should get poplulated with the total number of Purchase order ducument number for a vendor.
here is the required ouput format
vendor number Purchase order document number Number of Purchase orders
32915 1999009090
1999009091
SUM 2
32916 1999009092
SUM 1
SUM total 2
the value to be displayed has been calculated ina variable. the problem is how to display it.
please help.Hi,
Try like this....
TYPE-POOLS slis.
TYPES : BEGIN OF ta ,
d1(10) TYPE c,
d2 TYPE i,
d3 TYPE i,
line_color(4),
END OF ta .
DATA : it TYPE STANDARD TABLE OF ta,
wa TYPE ta,
it1 TYPE STANDARD TABLE OF ta,
wa1 TYPE ta,
n TYPE i,
N1 TYPE I.
DATA : it_layout TYPE STANDARD TABLE OF slis_layout_alv WITH HEADER LINE,
wa_fcat TYPE slis_fieldcat_alv,
it_fcat TYPE slis_t_fieldcat_alv.
DATA : it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE,
count TYPE i.
wa-d1 = 1.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 1.
wa-d2 = 13.
APPEND wa TO it.
wa-d1 = 1.
wa-d2 = 14.
APPEND wa TO it.
wa-d1 = 1.
wa-d2 = 15.
APPEND wa TO it.
wa-d1 = 2.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 2.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 2.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 3.
wa-d2 = 12.
APPEND wa TO it.
wa-d1 = 3.
wa-d2 = 12.
APPEND wa TO it.
SORT it BY d1.
LOOP AT it INTO wa .
count = count + 1.
n = n + 1.
n1 = n1 + 1.
IF count = 1.
wa-d1 = wa-d1.
ELSE.
wa-d1 = ' '.
ENDIF.
wa1-d1 = wa-d1.
wa1-d2 = wa-d2.
APPEND wa1 TO it1.
AT END OF d1.
CLEAR count.
wa1-d1 = 'SUM'.
wa1-d2 = n.
* wa1-d3 = n.
wa1-line_color = 'C400' . "'C300'.
APPEND wa1 TO it1.
CLEAR : n .
CLEAR wa1-line_color.
ENDAT.
ENDLOOP.
wa1-d1 = 'GRAND SUM'.
wa1-d2 = n1.
wa1-line_color = 'C511'.
APPEND wa1 TO it1.
it_layout-info_fieldname = 'LINE_COLOR'.
DEFINE macro4fcat.
wa_fcat-col_pos = &1.
wa_fcat-fieldname = &2.
wa_fcat-tabname = &3.
wa_fcat-seltext_l = &4.
wa_fcat-do_sum = &5.
append wa_fcat to it_fcat.
clear wa_fcat.
END-OF-DEFINITION.
macro4fcat '1' 'D1' 'IT1' 'First' ' ' .
macro4fcat '2' 'D2' 'IT1' 'Amount' ' ' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = it_layout
it_fieldcat = it_fcat
i_save = 'A'
TABLES
t_outtab = it1
EXCEPTIONS
program_error = 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.
Regards
Debarshi -
Converting ME2N Output to ALV Grid
Hello,
Is there any Class or Function Module which converts the output of ME2N into ALV Grid.
Thanks and Regards,
Prabhjot SinghHi Prabhjot Singh,
you can select ALV Output in parameter "scope of list" within ME2n
Regards
REA
Maybe you are looking for
-
Return to vendor process from backend
Could anyone of you please share the plsql pseudocode or full process code for return to vendor process ? Regards, Kumar Edited by: 857804 on May 10, 2011 6:20 AM
-
Print AR invoice from FB70.
Is it possible to print a Smartform AR invoice output from FB70? I see that there is a standard credit memo SapScript output which can be triggered from fb12 for invoice. Is there something similar that I can do to print AR invoice output from this t
-
Trigger a work flow for VL32N or VL31N
Hi I need to trigger a workflow for T code VL32N i.e. inbound delivery. I've found a business object BUS2015 but it has got no event by which a workflow can be triggered when inbound delivery is changed or created. Is there any class which can help ?
-
Query Def. Filter Value Selection
Hello, We upgraded our BW Dev application from 3.0(b) to 3.5 When I go into Bex Query Designer and I want to see the values for my InfoObject: 0FISCPER, I see old values Low Value: Period 15 2001 02/015/2001 High Value: Period 16 2005 02/016/2
-
Hi Guys, lets say we have TABLE1 (CHAR(1 BYTE)) TABLE2 (CHAR(1 CHAR)) The TABLE1 is clear, we store 20 records, it actual data will take up 20 bytes. What about the TABLE2? Given the same data as TABLE1, will it still take up 20 bytes. One thing for