Current Position:Home > REUSE_ALV_GRID_DISPLAY (column headings from ALV to EXCEL) Max please help

REUSE_ALV_GRID_DISPLAY (column headings from ALV to EXCEL) Max please help

Update:10-11Source: network consolidation
Advertisement
Hi Max,
If you remember in one of my last post I asked for changing the column headings in ALV display for example from 'Material' to 'Material used'.
I am using
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
      I_CALLBACK_PROGRAM                = repid
      IT_FIELDCAT                       = field_body
      I_SAVE                            = g_save
      IS_VARIANT                        = g_variant
      IT_EVENTS                         = events
    TABLES
      T_OUTTAB                          = itab.
And you suggested me the following way....
loop at field_body into field_wa.
case field_wa-fieldname.
  when 'Material'.
     field_wa-seltext_l = 'Material used'.
     field_wa-seltext_m = 'Material used'.
     field_wa-seltext_s = 'Material used'.
endcase.
modify field_body from field_wa.
endloop.
It is working well. In ALV display the column heading is changed to what I wanted. But the question is when I export the displayed ALV to Excel using ALV functionality, Export->Spreadsheet... I see that <b>I dont get the Column Heading into Excel as it was in the ALV display.</b>
I get in the Excel as 'Material u' or 'Mat. Used'. But when I add this line in the code.....
when 'Material'.
     field_wa-seltext_l = 'Material used'.
     field_wa-seltext_m = 'Material used'.
     field_wa-seltext_s = 'Material used'.
    <b> field_wa-outputlen = 20.</b>
Then I see that I get the complete heading in the Excel. But this way the columns with outputlen 20 are taking much space in ALV display.
Is there any fix for this. May be not mentioning the outputlen but still get the column headings into Excel as it was in ALV display.
Anyone with ideas please respond. Waiting for replies. Thanks

The Best Answer

Advertisement
Hi
The labels have a fixed size:
seltext_l is long   text: 20 char
seltext_m is medium text: 15 char
seltext_s is short  text: 10 char
The text 'Material used' is long 13 char so you should write:
field_wa-seltext_l = 'Material used'.
field_wa-seltext_m = 'Material used'.
field_wa-seltext_s = 'Mat. used'.
You can try to set the field colwidth_optimize of parameter IT_LAYOUT.
This field should optimize the width of the colunm
So
data layout type SLIS_LAYOUT_ALV.
layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
IT_LAYOUT   = layout       
IT_FIELDCAT = field_body
I_SAVE = g_save
IS_VARIANT = g_variant
IT_EVENTS = events
TABLES
T_OUTTAB = itab.
and you can decide which label has to be used:
field_wa-seltext_l = 'Material used'.
field_wa-seltext_m = 'Material used'.
field_wa-seltext_s = 'Mat. used'.
If you want to set the short text
field_wa-ddictxt   = 'S'.
...medium
field_wa-ddictxt   = 'M'.
...long
field_wa-ddictxt   = 'L'.
Max
  • REUSE_ALV_GRID_DISPLAY (column headings from ALV to EXCEL) Max please help Update:10-11

    Hi Max, If you remember in one of my last post I asked for changing the column headings in ALV display for example from 'Material' to 'Material used'. I am using CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'    EXPORTING       I_CALLBACK_PROGRAM            

  • Bring Color to  Column Headings of downloaded  ms-excel  file Update:11-30

    Hi, Iam downloading report output to MS-Excel sheet using  MS_EXCEL_OLE_STANDARD_DAT ...but what i want is how can i bring specific color to column heading of that downloaded Ms-excel file..using  ole  u  can  do it ... <b>just  copy  nad  paste  th

  • REUSE_ALV_GRID_DISPLAY, columns reorder when exporting to Excel Update:10-11

    I have a variable column output and am using "cl_alv_table_create=>create_dynamic_table" to create the field-symbol output table with correct number of columns in the exact order of the field catalog.  The field formatting also matches from t

  • How to export only selected columns of WD ALV to excel Update:10-11

    Hi, I have WD ALV report with EXPORT button (since standard button was not working properly i just hide that and added custom one) & standard dropdown to choose layout. Out of 20 columns user may choose n number of columns, the same number of columns

  • Change Column Headings in ALV Report Using OO Update:10-11

    Hi Friends, I am using OO to display a report with ALV Grid I tried to change the column names but it still takes the column names from the DDIC. My declaration is as  follows Data: num type dmbtr. TRY.             lr_column ?= lr_columns->get_column

  • ALV  download to EXCEL  with column headings etc. Update:10-11

    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'

  • How to download output data into Excel with all Column Headings Update:11-30

    Hi Experts, Please tell me How to download output data of ALV Grid into Excel file with all Column Headings and I want to do this using coding, please send me if any solution is available. Thanks & Regards, YogeshVERSION CONTROL (Most recent on top):

  • Column headings are missing in the output for ALV? Update:10-11

    Hi all, i have coded a small report in ALV mode. i am getting the data but the column headings are missing. iam not getting the column headings in the output. it is coming as blank. Could you all please help me out in this? below is the code of my pr

  • Column headings in a file extract to excel Update:10-11

    I am writing a program that will extract data and download it as a tab delimited file which will be input to excel. I need to put column headings on the file and I have attached an sample of the code that I am using. It is working fine but I am not s

  • ALV TO EXCEL PROBLEM? ( 90 COLUMNS ALV CAN'T EXPORT TO EXCEL NORMALLY) Update:10-11

    HI ABAPERS, anyone have a alv that have over 90 columns and want to export to excel have experienced abnormal formating (like the header row show only up to 60 column and the rest show up in next row) and the data show in separate line. anyway can ha