Export ALV Grid Header to spread sheet
Hi,
I created ALV report using OO ABAP where i splitted the container into 3 parts , one for header , one for Grid and the other for Footer. When i export it to a spred sheet , i could not able to get the header and footer into the Spread sheet. I want the header and the footer to be exported to the spred sheet. Can any one of you help me out in this.
Thanks,
Kishore.
Use the events PRINT_TOP_OF_PAGE and PRINT_END_OF_PAGE for printing the Header and Footer.
Sample routine for the method PRINT_TOP_OF_PAGE is given below:
METHOD M_HANDLE_TOP_OF_PAGE.
*Local variables declaration
DATA:
V_TEXT TYPE SDYDO_TEXT_ELEMENT, " Text
V_DATE TYPE CHAR10, " Date
V_TIME TYPE CHAR10, " Time
V_TEXT2 TYPE CHAR30.
*To display Current Date
WRITE SY-DATUM TO V_DATE.
WRITE SY-UZEIT TO V_TIME.
CONCATENATE 'Current Date :'(076)
V_DATE
V_TIME
INTO V_TEXT2 SEPARATED BY SPACE.
WRITE:/ V_TEXT2.
*To print Report Date
CLEAR: V_DATE, V_TEXT2.
WRITE P_CURDT TO V_DATE.
CONCATENATE 'Report Date :'(077)
V_DATE
INTO V_TEXT2 SEPARATED BY SPACE.
WRITE:/ V_TEXT2.
ENDMETHOD. " M_HANDLE_TOP_OF_PAGE
If you are satisfied, please give points to my reply.
Regards,
Sumanth.
Similar Messages
-
Problem while exporting ALV column header to excel sheet.
Hi,
I am able to export an ALV grid details to an excel sheet. But the ALV column headers when exported to excel sheet are getting truncated.
For eg: if my column header in ALV grid is displayed as 'Material' then the column header in excel sheet is 'Mater' only. Remaining portion is getting truncated.
How can I view the entire column header text?
Kindly assist.
Thanks.I have the same problem with you, when user export to excel. I fixed it by using
w_layo-colwidth_optimize = 'X'. <<<<<<<<<<<<This
perform generate_fcat_reftab
using 'PRUEFLOS' 'T_INPUT' '' '' 'Inspection Lot' 0.
form generate_fcat_reftab using p_fieldname
p_tabname
p_ref_tabname
p_ref_fieldname
p_output_text
p_output_lenght.
clear w_fcat.
w_fcat-fieldname = p_fieldname.
w_fcat-tabname = p_tabname.
w_fcat-ref_fieldname = p_ref_fieldname.
w_fcat-ref_tabname = p_ref_tabname.
w_fcat-seltext_s = p_output_text.
w_fcat-seltext_m = p_output_text.
w_fcat-seltext_l = p_output_text.
w_fcat-outputlen = p_output_lenght.
w_fcat-ddictxt = 'L'. <<<<<<<<<<<<<<<<<<This
append w_fcat to t_fcat.
endform. -
Exporting ALV Grid output to Excel sheet
Hi All,
How can i export the output displayed using Grid to an Excel sheet. I tried with default option from list->export->excel sheet/local file but i am not getting complete data and the data which i am getting also notin proper format. Please help me in this regard.
Best Regards,
SunilCheck out the ALV grid toolbar for export options.
Regards
Raja -
Taking download into excel from ALV Grid - header is printing in two lines
Hi All,
I have a scenario where I am taking the download from ALV grid to an excel sheet. Now the header of the ALV (column names) is appearing in two lines in the downloaded excel sheet while items (records of the ALV table) are getting displayed in a single line.
This download is taken from the standard download to local file (spreadsheet) button provided by SAP for ALVs.
I am using function module "Reuse_alv_grid_display" for the purpose.
Can somebody provide an idea how I can avoid the header printing in two lines and keep the length as it is.
Thanks in Advance,
ChandanHi..
1. Pass header name in internal table appned first line.
2. after that pass u r data .
3. Use FM. WS_DOWNLOAD
Salil ......
Edited by: salil chavan on Nov 26, 2008 11:07 AM -
Page No in ALV GRID Header disply ?
Hi,
How to display the page No in ALV GRID Header display.
Thanks & Regards,
Amir.hai
I think u can use this funtion... Using this funtion u can find som solution for ur problem
*& Form BUILD_EVENTTAB
text
-->P_EVENTS[] text *
form build_eventtab using p_events type slis_t_event.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_events.
read table p_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move formname_top_of_page to ls_event-form.
append ls_event to p_events.
endif.
endform. " BUILD_EVENTTAB
*& Form BUILD_COMMENT
text
-->P_HEADING[] text *
form build_comment using p_heading type slis_t_listheader.
data: hline type slis_listheader,
text(60) type c,
test_date TYPE string,
test_date1 TYPE string,
sep(20) type c.
clear: hline, text.
hline-typ = 'H'.
write: text-101 to text+23.
hline-info = text.
append hline to p_heading.
clear text.
write: 'User: ' to text,
sy-uname to text+6,
'Date: ' to text+25,
sy-datum to text+31,
'Page: ' to text+50,
sy-pagno to text+56.
hline-info = text.
append hline to p_heading.
endform. " BUILD_COMMENT
FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading.
endform.
regard
nawa -
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. -
Runtime Error during export ALV Grid to Local File and Print Priview
Hi all,
While Exporting ALV grid to local file using menu List->export->local file , I m getting following runtime error,
Field Symbol has not yet been assigned.
Details of Errors:
Program : SAPLKKBL
Include : LKKBLF99
Module Type : (FORM)
module name : GEN_FIELD_OUT2
So. pls Suggest any good solution.
Thanks & Regards,
Sandip Sonar.hi
this is happening just because you might have declared that your ALV list should have a checkbox, but defined no field as "checkbox" into your internal table.
and one more thing to check up is that before you call the REUSE_ALV_GRID_DISPLAY, you need to fill a few parameters for instance is_layout. This one has a field box_fieldname, in which you have to enter the name of the field of the internal table that will store the 'X' as and when the checkbox is checked.
hope this helps
regards
Aakash Banga -
Hi..all.
I have a question.
Is there any method to make dual header?
For example,
table name 1
table name 2
fld1
fld2
fld3
fld4
fld1
fld2
fld3
fld4
record
end of list.
I found some materials and Dev.class slis but I couldn't find the method.
Is this possible? If I can't do this, what I can use as an alternative.
Ilook forward your answer.
Thanks.Hi,
In ALV Grid this is not possible but with ALV List this is possible as elaborated below.
For displaying two headers in ALV, you have to use the following process...
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_bypassing_buffer = c_x
i_callback_program = lv_repid
is_layout = wa_layout
it_fieldcat = it_fieldcat
it_events = it_events
i_save = c_a
TABLES
t_outtab = it_final
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.
For setting layout use the following form -
*& Form F_SET_LAYOUT
* text
* --> p1 text
* <-- p2 text
FORM f_set_layout .
wa_layout-zebra = c_x.
wa_layout-colwidth_optimize = c_x.
ENDFORM. " F_SET_LAYOUT
Similarly for events use -
*& Form F_CALL_EVENT
* Defining events which have to triggered
* --> p1 text
* <-- p2 text
FORM f_call_event .
wa_events-name = slis_ev_top_of_page.
wa_events-form = c_top.
APPEND wa_events TO it_events.
CLEAR wa_events .
ENDFORM. " F_CALL_EVENT
where c_top is defined as -
c_top TYPE slis_formname VALUE 'TOP_OF_PAGE'
Also u have to define a form (mentioned below) with the same name which can be called from f_call_event form automaticaly...
*& Form TOP_OF_PAGE
* Defining the column's main heading
FORM top_of_page.
FORMAT COLOR COL_HEADING.
WRITE : / sy-uline(255).
WRITE : / sy-vline,
(10)c_space,
sy-vline,
(2) c_space,
sy-vline,
(8) c_space,
sy-vline,
(17)c_space,
sy-vline,
(18)c_space,
sy-vline,
(18)c_space,
sy-vline,
(26)c_space,
sy-vline,
(31)c_space,
sy-vline,
(12)c_space,
sy-vline,
(41)c_jan CENTERED,
sy-vline,
(41)c_feb CENTERED,
sy-vline,
(41)c_mar CENTERED,
sy-vline,
(41)c_apr CENTERED,
sy-vline,
(41)c_may CENTERED,
sy-vline,
(41)c_jun CENTERED,
sy-vline.
FORMAT COLOR OFF.
ENDFORM. "top_of_page
In this you can define the 1st column headings along with the position.
This will help you add 2 headers to each column viz....
1st Heading from the top of the page form
and
2nd heading from the field catalog you have defined.
Let me know in case any further detail is needed.
Thanks. -
ALV Grid Header Problem.
Hi All,
I want to display the header of the ALV Grid as:
Material 111/11823
Plant/Usage/Alt 2845/3/5
Description ABI CAB
Base Qty. 23.000
The values are to be taken from variables
Please suggest how to do this.
Thanks*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report with grand total *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
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.
perform top-of-page.
*& 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-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
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 table it_ekko.
endform. " DATA_RETRIEVAL
Form TOP-OF-PAGE *
ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
i_logo = 'ideas'.
endform. -
ALV grid to protected Excel sheet
Hi ABAP gurus,
I Have developed an ALV report using OO concept and from the application toolbar i am able to change the GRID output to Excel output using View -> Excel inplace. Belows are my requirement now.
1. I need to change the standard template with my template for this particular ALV report or Transaction. PLease provide me with steps details to do it.
2. The Excel sheet should be in protected mode and user should be able to only take print out from the excel sheet without modifying any columns .
If there is no standard way we can add an additional appliaction menu and code it to download the ALV output into an Excel sheet and display it . However again the User should not be able to modify the sheet. please provide me with sample code to do it.
PLease suggest solution for this . Point will be awarded for all valuable answers.
Please it is very urgent for me ...
Thanks in advance.
Iftekhar AlamHi ABAP gurus,
I Have developed an ALV report using OO concept and from the application toolbar i am able to change the GRID output to Excel output using View -> Excel inplace. Belows are my requirement now.
1. I need to change the standard template with my template for this particular ALV report or Transaction. PLease provide me with steps details to do it.
2. The Excel sheet should be in protected mode and user should be able to only take print out from the excel sheet without modifying any columns .
If there is no standard way we can add an additional appliaction menu and code it to download the ALV output into an Excel sheet and display it . However again the User should not be able to modify the sheet. please provide me with sample code to do it.
PLease suggest solution for this . Point will be awarded for all valuable answers.
Please it is very urgent for me ...
Thanks in advance.
Iftekhar Alam -
Alv Grid download to xl sheet: Column position mismatching
Hi All,
As we know that while downloading the alv grid report data into xl sheet the date cloumn and might some other column positon get shifted to extreme right.
My problem is with five columns in my grid report that got shifted to extreme right while downloading to the xl sheet. They have the data type CURR and DEC. As both the types are basically packed.
I tried to convert one of them into character, but had short dumpfor this conversion.I
Please suggest me to resolve this issue. I shall be greatful to the valuable answer.
Note: My internal table fields order and fields order in fieldcatalog are same.
Thnaks in advance.Answer is to convert it to CHAR .
Conversion error could you post..
Might be the size was not enough to accomodate the DEC/CURR value .
Or the field was not able to recognise the negative/positive signs .
Other option is to play with excel and manually convert all fields to Text by formatting the column in excel. -
ALV Grid -- Heading in each and every page while printing
Hello!!!!
How to display heading in ALV Grid in each and every page while printing?
Thanks in Advance!!!!!!Hi nitesh,
<b>data: lt_list_commentary type slis_t_listheader.
perform build_comment using
lt_list_commentary.
form build_comment using
pt_list_commentary type slis_t_listheader.
data: ls_line type slis_listheader.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = 'SREEKANTH REDDY'.
append ls_line to pt_list_commentary.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = 'HEADER1'.
append ls_line to pt_list_commentary.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = 'HEADER2TEXT'.
append ls_line to pt_list_commentary.
clear ls_line.
endform.
</b>In Function module REUSE_ALV_COMMENTARY_WRITE , give the parameter as
<b>it_list_commentary = lt_list_commentary </b>
Here ls_line-typ = 'H'. you can use options like 'H' , 'A' , 'S'. -
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 -
Hi
I need to have two level of heading for my ALV grid. The first level will have two columns that is supposed to span for say 3 columns. The next header will have 6 columns headings for each of the six columns.
For example
1-1-2004 | 1-1-2005
A | B | C | D | E | F |
I hope i made my self clear.Hi,
Check this link,
<u>http://www.sap-img.com/fu037.htm</u>
Kindly reward points if u find it useful.
Thanks,
Ruthra -
Hi all,
I m displaying records using ALV Grid , I want to export that ALV Grid to Local File ,
using Menu->List->Export->Local File.
I m able to export it in spreadsheet using option List-> Export->Spreadsheet, but while exporting to local file i m getting short dump with error *Field Symbol Has not yet been Assigned*.
Pls, Suggest any good Solution.
Thanks & Regards ,
Sandip Sonar.hi,,,,
In your output are there any empty Columns, Because field Symbol Not assigned generally occurs if any one of your Internal table column is Blank, Just remove that Blank Column and then try it.
Thanks
Saurabh
Maybe you are looking for
-
Problems after upgrade from SCVMM 2012 Sp1 to SCVMM 2012 R2
I did a in-place (uninstall VMM2012 Sp1, retain the database, and install VMM2012 R2 point to old database) upgrade. All the steps work fine. The only problem (so far) is that when I create a new VM using a custom template (for example, Windows 2008
-
Image Viewer skips first photo
Hi please help me I got a small problem. I created a Image Viewer with Macromedia Dreamweaver 8. The Image Viewer is a slide where you can show Photos. My problem is when i am scrolling trough my uploaded images, it does not show the first photo agai
-
Is it possible to go full screen with the DVD player?
I have a 21" IMac. When trying to play a DVD, I cannot get the movie to go to full screen. I can expand the screen to a larger size, but there are still a sizable margin left over. Very annoying and distracting when trying to watch a movie. I can
-
Trouble Syncing Ipod Touch 2G?
My daughter has had an Ipod Touch 2G for quite some time now. I sync it with Itunes every few months. I tried during Christmas however the computer is not recognizing it. On the Itunes webpage, it appears that it is now compatable with iOS 4.3.3, and
-
Premiere Pro verus Premiere Elements
I am going to be copying in and editing a large amount of old VHS tapes. I mainly want to delete out blanks, merge clips together and especially try to improve brightness, contrast etc. like I do in Photoshop for stills. I wanted to know if Premier