ALV / Download to Excel - columns transposed
A developer on my team has this problem:
We have a ALV report that gives the user the option to download to excel.
The report has columns.
A,B,C,D (for example)
but when the user exports to excel ("List > Export > Spreadsheet > Table")
they get
A, <b>C, B</b>, D
Dose anyone know why this happens? We have checked various sites and found OSS note 358644.
Are we on the right track? Or is there an easy answer to this.
Thanks in advance.
Hi Kyle,
I too faced the same problem lon back. But what we
found is for currency, date and amount fields it is
moving to last.
You also checl the standard program BCALV_GRID_01.
If you download you can see the same thing happens
here also.
Check in your case whether B is date, amout or numeric field.
Thanks & Regards,
Siri.
Kindly award points if the answer is useful.
Similar Messages
-
ALV Download to Excel Column Colors Problem
Hi Experts,
I've encountered a problem in downloading records from ALV display to excel file.
The file is downloaded SUCESSFULLY however. When I opened the downloaded file, some columns were filled up with color(yellow) and other fields are not.
Do anyone have an idea why?I have 21 Columns columns. The first 16 columns are filled with yellow colors...
-
Hi,
I have a problem with regards to the ALV download to excel. I have an ALV grid with 40 columns and i need to download the output to an excel file. But after downloading the ALV output, i noticed that some columns are already on the next line. i need to have all columns to be in the same line. Does anyone have an idea how to prevent columns to be printed in the next line?
Thanks in advance!
Kind regards,
MerriamLooks like Note 855314 has a workaround ... my be more.
Of course (yuk!), write you own download.
Best!
Jim -
How can I disenable the EXCEL field format when use ALV download to excel ?
Dear friends,
I have a problem with the ALV download to EXCEL. One field Value in ALV is like u2018-abcdeu2026u2019.the character u201C-u201Cis the first position in field value.when I download the value to EXCEL,the field value u2018-abcdeu2026u2019 changed u2018=-abcdeu2026u2019 in EXCEL.how can I remove u2018=u2019 in EXCEL when I down to excel used ALV.
I add a space in u2018 -abcdeu2026u2019,So this value can be download to Excel .
Have you any solve method?
User does not use excel logo button to download.
User use Local fileu2026 button to download
Thanks
Sunadd a single quote to the beginning of the field.
like: '-abcde
in excel it will be shown as : -abcde -
ALV download to EXCEL with column headings etc.
Getting data from a grid to EXCEL can be done in "List" mode vis system==>save etc but it's not particularly user friendly and in any case if you are displaying a nice ALV why should the user have to switch into LIST mode anyway.
Anyway here's a decent way to do it and it gives great formatted column headings etc etc.
1) in the ON_TOOLBAR method add this code
method ON_TOOLBAR.
type-pools icon.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EXCEL' TO ls_toolbar-function.
MOVE space TO ls_toolbar-disabled.
MOVE icon_xxl TO ls_toolbar-icon.
MOVE 'Excel' TO ls_toolbar-quickinfo.
MOVE 'EXCEL' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
2) In the ON_USER_COMMAND method add the following
(if you have a class defined with SE24 you don't need the commented code).
method ON_USER_COMMAND.
FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm
sender.
CASE e_ucomm.
....... other toolbar funcs if you have any
WHEN 'EXCEL'.
CALL METHOD me->download_to_excel.
ENDCASE.
endmethod.
3) code this method to download to EXCEL
method DOWNLOAD_TO_EXCEL.
FIELD-SYMBOLS:
<fs0> TYPE STANDARD TABLE,
<fs1> TYPE STANDARD TABLE.
ASSIGN g_outtab1->* TO <fs0>.
ASSIGN g_fldcat1->* TO <fs1>.
CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
EXPORTING
it_fieldcat_lvc = <fs1>
is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
IMPORTING
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
CLEAR lt_fieldcat_wa-tech_complete.
IF lt_fieldcat_wa-tabname IS INITIAL.
lt_fieldcat_wa-tabname = '1'.
MODIFY lt_fieldcat FROM lt_fieldcat_wa.
ENDIF.
l_tabname = lt_fieldcat_wa-tabname.
ENDLOOP.
CALL FUNCTION 'ALV_XXL_CALL'
EXPORTING
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
TABLES
it_outtab = <fs0>
EXCEPTIONS
fatal_error = 1
no_display_possible = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
endmethod.
You get nice column headings etc and decently formatted EXCEL spreadsheet.
For Office 2007 I think you need to apply a SAP note but it certainly works with OFFICE 2003 which is what we are still using.
Cheers
jimboGetting data from a grid to EXCEL can be done in "List" mode vis system==>save etc but it's not particularly user friendly and in any case if you are displaying a nice ALV why should the user have to switch into LIST mode anyway.
Anyway here's a decent way to do it and it gives great formatted column headings etc etc.
1) in the ON_TOOLBAR method add this code
method ON_TOOLBAR.
type-pools icon.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EXCEL' TO ls_toolbar-function.
MOVE space TO ls_toolbar-disabled.
MOVE icon_xxl TO ls_toolbar-icon.
MOVE 'Excel' TO ls_toolbar-quickinfo.
MOVE 'EXCEL' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
2) In the ON_USER_COMMAND method add the following
(if you have a class defined with SE24 you don't need the commented code).
method ON_USER_COMMAND.
FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm
sender.
CASE e_ucomm.
....... other toolbar funcs if you have any
WHEN 'EXCEL'.
CALL METHOD me->download_to_excel.
ENDCASE.
endmethod.
3) code this method to download to EXCEL
method DOWNLOAD_TO_EXCEL.
FIELD-SYMBOLS:
<fs0> TYPE STANDARD TABLE,
<fs1> TYPE STANDARD TABLE.
ASSIGN g_outtab1->* TO <fs0>.
ASSIGN g_fldcat1->* TO <fs1>.
CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
EXPORTING
it_fieldcat_lvc = <fs1>
is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
IMPORTING
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
CLEAR lt_fieldcat_wa-tech_complete.
IF lt_fieldcat_wa-tabname IS INITIAL.
lt_fieldcat_wa-tabname = '1'.
MODIFY lt_fieldcat FROM lt_fieldcat_wa.
ENDIF.
l_tabname = lt_fieldcat_wa-tabname.
ENDLOOP.
CALL FUNCTION 'ALV_XXL_CALL'
EXPORTING
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
TABLES
it_outtab = <fs0>
EXCEPTIONS
fatal_error = 1
no_display_possible = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
endmethod.
You get nice column headings etc and decently formatted EXCEL spreadsheet.
For Office 2007 I think you need to apply a SAP note but it certainly works with OFFICE 2003 which is what we are still using.
Cheers
jimbo -
ALV download to Excel onto desktop using OLE concept.
Hi Experts,
I requriement is , through my se38 program i need to download report output to excel.
i did this using OLE concepts code and excel is being downloaded good.
But problem is all columns data is dumped into First column. But in my ALV i have 20 columns. So i except data in excel sheet to be in 20 columns.
Below is the OLE code i used
CREATE OBJECT wa_excel 'EXCEL.APPLICATION'. "Create object for Excel
SET PROPERTY OF wa_excel 'VISIBLE' = 1. "In background Mode
CALL METHOD OF wa_excel 'WORKBOOKS' = w_workbook.
CALL METHOD OF w_workbook 'ADD'. "Create a new Workbook
SET PROPERTY OF wa_excel 'SheetsInNewWorkbook' = 3. "No of sheets
* Downloading header details to first sheet
PERFORM download_sheet TABLES i_final USING 1 'Master Material Details'.
GET PROPERTY OF wa_excel 'ActiveSheet' = w_worksheet.
* Protect the first worksheet with a password
CALL METHOD OF w_worksheet 'PROTECT
EXPORTING #1 = 'infy@123'.
* Save the Excel file
GET PROPERTY OF wa_excel 'ActiveWorkbook' = w_workbook.
CALL METHOD OF w_workbook 'SAVEAS'
EXPORTING #1 = p_infile.
FREE OBJECT: w_worksheet, wa_excel.
FORM download_sheet TABLES p_tab USING p_sheet TYPE i p_name TYPE string.
CALL METHOD OF wa_excel 'WORKSHEETS' = w_worksheet
EXPORTING
#1 = p_sheet.
CALL METHOD OF w_worksheet 'ACTIVATE'.
SET PROPERTY OF w_worksheet 'NAME' = p_name.
CALL METHOD OF wa_excel 'Range' = w_range
EXPORTING
#1 = 'A1'
#2 = 'D1'.
CALL METHOD OF w_range 'INTERIOR' = w_int.
SET PROPERTY OF w_int 'ColorIndex' = 6.
SET PROPERTY OF w_int 'Pattern' = 1.
* Initially unlock all the columns( by default all the columns are locked )
CALL METHOD OF wa_excel 'Columns' = w_columns.
SET PROPERTY OF w_columns 'Locked' = 0.
* Locking and formatting first column
CALL METHOD OF wa_excel 'Columns' = w_columns
EXPORTING
#1 = 1.
* Locking and formatting second column
CALL METHOD OF wa_excel 'Columns' = w_columns
EXPORTING
#2 = 2.
SET PROPERTY OF w_columns 'Locked' = 2.
SET PROPERTY OF w_columns 'NumberFormat' = '@'.
* Export the contents in the internal table to the clipboard
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = p_tab[]
CHANGING
rc = w_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
* Paste the contents in the clipboard to the worksheet
CALL METHOD OF w_worksheet 'Paste'.
* Autofit the columns according to the contents
CALL METHOD OF wa_excel 'Columns' = w_columns.
CALL METHOD OF w_columns 'AutoFit'.
FREE OBJECT: w_columns, w_range.
Please help me if there is any SET Property of WA_EXCEL with which i can handle ALV data into Diffrenet columns.
Regards,
jayant.hi nabheet,
we have implemnted this logic and it is workign fine. Bit it takes long time to download data in Excel sheet. Actually it is happening feild by field.
Please advice any perfomance tuning to this logic.
Rgs,
jayant -
Hi Experts,
Currently in my custom program I have an issue regarding downloading ALV to excel file where one of the fields in the report will output more than 400 characters which is in Chinese characters and this field already type to string. The problem is when i download it to excel only the 301 characters is only downloaded to the file.
Addtnl information:
The data in the output internal table is complete before going through the FM REUSE_ALV_GRID but when i tried to debug when downloading before it reaches to the GUI_DOWNLOAD it already has incomplete data so this means that this is not a problem for GUI_DOWNLOAD.
Question:
Is the problem a SAP ALV download limitation?
Is there an available solution for this?
Edited by: Ekitzv on Apr 8, 2011 6:21 AMFirst try to scroll down till the last page, then select all the column manually by putting curser and copy.
This will solve your issue. i usually do in ths way
Shayam -
Little problem ALV - Download to Excel
Hi Friends !
I have a little problem, when the user download the data which are in ALV, the positions of columns change .
Example:
In ALV.
1 - Column A
2 - Column B
3 - Column C
In Excel
1 - Column B
2 - Column A
3 - Column C
Regards !!!This sounds pretty weird. Are they just running ALV and then they do a download on the ALV screen using the Excel icon? Are they running it with some type of Excel template? Is it using a special layout - if so are they sure they saved the layout before they download? Never heard of or saw this one before. Also are you the Cesar I worked with a few years ago in Memphis? Just wondering - don't think this will help much but let me know.
-
ALV download to EXCEL -- probs with SAPGUI 6.40 and EXCEL 2007
I have a method in an ALV grid which performs a dowload to excel
Here's the method
method download_to_excel.
field-symbols:
<fs0> type standard table,
<fs1> type standard table.
assign g_outtab1->* to <fs0>.
assign g_fldcat1->* to <fs1>.
call function 'LVC_TRANSFER_TO_KKBLO'
exporting
it_fieldcat_lvc = <fs1>
is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
importing
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
loop at lt_fieldcat into lt_fieldcat_wa.
clear lt_fieldcat_wa-tech_complete.
if lt_fieldcat_wa-tabname is initial.
lt_fieldcat_wa-tabname = '1'.
modify lt_fieldcat from lt_fieldcat_wa.
endif.
l_tabname = lt_fieldcat_wa-tabname.
endloop.
call function 'ALV_XXL_CALL'
exporting
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
tables
it_outtab = <fs0>
exceptions
fatal_error = 1
no_display_possible = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endmethod.
Basically the method converts the GRID table I'm displaying into the format requred for FMOD ALV_XXL_CALL' -- the field catalog is slightly different but no big deal here.
This works fine when downloading to EXCEL 2003 but short dumps when trying to do the same thing for EXCEL 2007.
Workstation is running Windows XP / SP2 build 2600 in both cases.
Any fixes etc or should I stick with EXCEL 2003 until forced to upgrade.
Cheers
jimboHi all
Seems the problem disappeared after applying the latest patch to SAP_GUI 6.40.
I haven't tried SAP_GUI 7.0 yet.
Thanks anyway
Cheers
jimbo -
ALV downloaded to EXCEL -using standard button-how to modify the EXCEL ???
hey guys,
i have developed an ALV (with dynamic itnernal table,with HTML top of page,using FMs)
Now ,i ahd problems with downlaod to excel(which i partly overcame by using &XXL fcode button instead of other 'donwload to excel button' )..
now the data is downloading to excel fne..
but i need to customise the EXCEL with HEADING (with bold letters in colour).. and also adding a line in ALV COLOUMN HEADINGS part of EXCEL...Hi,
Kindly go through the below link to download a file in Excel format from ALV,
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bcheckbox%252bto%252bprocess%252bselected%252brecords%252bat%252bruntime
Note: In the function module ->GUI_DOWNLOAD
You have to give Field Separator as 'X'.
Hope it helps You.
Regards
Mansi -
Dear Gurus a problem in alv report downloading to excel:
on executing the report works fine but when downloading to excel there last digit of bpvno is getting truncated.
ex: actual bpvno:'4000010' but excel o/p shows as '400001'
I have declared a field in final internal table as:
data: bpvno as bseg-belnr,
(in field catalog)
fieldcatalog-fieldname = 'BPVNO'.
fieldcatalog-seltext_m = 'BPV No.'.
fieldcatalog-seltext_L = 'BPV No.'.
fieldcatalog-col_pos = I1.
fieldcatalog-emphasize = 'X'.
append fieldcatalog .
clear fieldcatalog.
I1 = I1 + 1.
but after specifying the REF_TABLENAME & REF_FIELDNAME the downloaded excel o/p is correct.
My questions is:
1) i want to know what all are mandatory fields to be specified in fieldcatalog & is it compulsory to specify REF_TABLENAME & REF_FIELDNAME .
if not complusory why the downloaded excel value is being truncated ???
plz dont send materilas on alv and answer specific to the question....Hi,
I wrote a small program, and for me it worked. My assumption about the seltext was wrong. And I also didn't use output lenght.
Here is the code.
REPORT ZALVTOEXCEL .
type-pools slis.
data : gt_fcat type slis_t_fieldcat_alv.
data fieldcatalog like line of gt_fcat.
types : begin of t_belnr,
bpvno like bseg-belnr.
types end of t_belnr.
data gt_belnr type table of t_belnr.
data gwa_belnr type t_belnr.
gwa_belnr-bpvno = '4000010'.
append gwa_belnr to gt_belnr.
fieldcatalog-fieldname = 'BPVNO'.
fieldcatalog-seltext_m = 'BPV No.'.
fieldcatalog-seltext_L = 'BPV No.'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'X'.
append fieldcatalog to gt_fcat.
clear fieldcatalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = gt_fcat
I_SAVE = 'A'
TABLES
t_outtab = gt_belnr
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,
Advait. -
ALV Download to excel truncating fields
Hi,
When I use the ALV download button to download to excel, it is truncating the last character of customer number.
ie customer 20011790 is showing as 2001179.
Any ideas how to fix this.
Thanks.Looks like Note 855314 has a workaround ... my be more.
Of course (yuk!), write you own download.
Best!
Jim -
ALV download to Excel--Problem with Column Headers
Hi,
I have created a dynamic internal table and displaying it as ALV using SALV classes. Problem is that when I download this ALV to Excel I'm not getting Column headings same as they are in ALV display.
I mean in Excel it is showing Column headings taken from domain or data element.
While creating dynamic table i'm passing short/ Medium & Long text too. Still it is not working.
Any kinda help is appreciated.
Thanks & Regards,
Vivek Gaur
Edited by: Vivek Gaur on Nov 4, 2009 2:04 PMLook I cant actually post the code as it is divided in some global classes and main program. But i can elaborate the steps little further:
1: I have created a field catalog for Dynamic internal table. In it i have passed every necessary field along with short/medium/Long texts.
2: I fill up this dynamic table with data.
3: I assign a field symbol to this dynamic internal table.
4: I pass this field symbol to the factory method of CL_SALV_TABLE Class.
Thats it buddy..Hope u have understood my problem. -
ALV Grid Download to Excel - Columns in wrong order
I'm using the object cl_gui_alv_grid to output an ALV grid to the screen. I've populated the field catalogue as follows:
wa_alvfieldcat-col_pos = 1.
wa_alvfieldcat-just = 'L'.
wa_alvfieldcat-reptext = 'Customer Name'.
wa_alvfieldcat-scrtext_s = 'Customer'.
wa_alvfieldcat-scrtext_m = 'Customer'.
wa_alvfieldcat-scrtext_l = 'Customer Name'.
wa_alvfieldcat-outputlen = 35.
wa_alvfieldcat-tabname = 'GTBL_REPORT'.
wa_alvfieldcat-fieldname = 'CUST_NO'.
The screen shows the table correctly in the order I've specified using COL_POS. But when I select the download function from the ALV grid it moves all the date fields to the end instead of using the order I wanted.
Any ideas?CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZCONTRACT_REPORT'
CHANGING
ct_fieldcat = tbl_alvfieldcat.
then
LOOP AT tbl_alvfieldcat INTO wa_alvfieldcat.
MOVE 'GTBL_REPORT' TO wa_alvfieldcat-tabname.
CASE wa_alvfieldcat-fieldname.
WHEN 'DATE_ORDER'.
wa_alvfieldcat-col_pos = 4.
wa_alvfieldcat-just = 'L'.
wa_alvfieldcat-reptext = 'Date Order'.
wa_alvfieldcat-scrtext_s = 'Date Order'.
wa_alvfieldcat-scrtext_m = 'Date Order'.
wa_alvfieldcat-scrtext_l = 'Date Order'.
wa_alvfieldcat-outputlen = 10. -
Doubt in ALV grid (OO ALV) download to Excel
Hi All,
I done Report using OOALV when down loading to Excel one row got automatically inserted to the ALV Excel downloaded sheet at the top and the row contains Sy datum , Dynamic list display , page no
my requirement is to delete that row. Is that possible. If so please suggest me how to handle that
Thanks
KiranHi,
Check this link:
Re: Digit missing in the alv export
Hope this helps.
Regards,
Satish Kanteti
Maybe you are looking for
-
J2EE server not coming up plz help me
Hi, I am new to EP.While deploying EAR into portal unkowingly entered 3 times wrong password for SDM. Now J2EE server is not coming up.I changed SDM password thru command line.I even changed admin password thru config tool . still server is not comi
-
Hello, I'm sorting through and organizing hundreds of photos. I cannot figure out the difference/purpose between tags and albums. For example, a trip to Disneyworld. I could create an album called "Disneyworld" and put them all there, and even put it
-
An unexpected and unrecoverable problem has occurred. Photoshop will now exit.
Attempted to launch Photoshop CS4 today and was welcomed by the following errors. The first error to pop up said: "An unexpected and unrecoverable problem has occurred because something prevented the text engine from being launched. Photoshop will no
-
App search on iPad iOS not working, App search on iPad iOS not working
Only had this one week, now unable to search in the App Store just getting white screen, the buffering Circle does it thing but just get white screen, WAS working fine till about 2 - 3 days ago, have tried reset and restart and signing in and out (on
-
Set Rule conditions for Determine Tax Applicability rules
Hi We are doing Tax setups In Release 12. We need to setup the Rule condition for Determine tax Applicability as Applicable. can you please tell me the Naivgation Path. Regards Venkateswaran R