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.

Similar Messages

  • ALV Grid Exporting to Excel - Columns out of order

    Hi,
    In my ALV grid everything is in order as it is in the structure. When however I export to excel from ALV grid, the columns are out of order. First it lists the string columns, then number columns and lastly date columns. Is there a way to make excel keep the same order as it is in ALV grid?
    Thanks,
    Sergiy

    I am not much of an ABAPer but I was able to set the column position during data declaration with
    gs_fcat_line-col_pos = 1, for example.
    That would put the column in the first position in ALV as well as the excel export.
    Thanks for your inputs.
    Sergiy

  • ALV grid Download to excel not working

    Hi All,
    I am displaying an Alv list using the function Module
    REUSE_ALV_GRID_DISPLAY.
    The report is getting displayed correctly..But when Iam trying to downlaod the same in excel.It does not get downloaded correctly.
    All the fields get downloaded into one column of excel sheet.
    CAn anyone tell me what's going wrong on this.
    Thanks
    GT

    Hi GT,
    try this way,
    save as local file this option available on the grid.
    and while giving the file name give the name what you want with extension .xls
    then check that file all the data will be opend in excel sheet.
    http://help.sap.com/saphelp_erp2004/helpdata/en/e3/41a138c4397a42e10000009b38f842/frameset.htm
    reward points for helpfull answers and close the thread if your question is solved.
    regards,
    venu.

  • Problem in ALV grid download to excel

    Hello Gurus,
    I have a ALV report which has 40 columns but at a time it will only display 100 records(max). when I am trying to download it into excel (by using standard funcationality) only headings are getting downloaded. I checked out standard table download like MARA,VBAK but they are downloading properly.
    what could be the reason..?
    Thanks in advance.
    Thanks and Regards,
    Saurabh Chhatre

    Hi,
    i am implementing alv by grid method using function module. By my previous experience u do not need to do anything to get the alv in excel format(std. funcationality is provided by SAP itself). But this is not working right now .. apart from headings nothing is coming in file download.
    thanks and regards,
    saurabh chhatre

  • Facing problem while downloading ALV grid Output into Excel

    Hi Guys,
    I am facing problem while downloading ALV grid Output into Excel.
    It is downloading into excel, but all character columns first and next all quantity columns it is displaying. But I need columns order as it is in the grid.
    If I take all columns as characters it works fine. But it will be problem for calculating total, subtotals of quantity columns
    Can someone help me regarding this
    thanks for your help

    Hi,
    Open up Excel on your desktop. Goto Tools > Macro > Security.
    Make sure that your security is set to Medium (or less). SAP uses OLE automation to run the Excel instance and in Office 2003 (for example), Microsoft has increased their default security setting to High. With the High setting, the output to Excel fails.
    Was this your problem? Don't forget those points, either.
    check with this wetther it is solved or not.
    Regards,
    sana.

  • ALV output download to excel with top of page

    Hi,
    i want to download ALV grid output to excel sheet including the top of page. i am using the icon in application tool bar. but only data's are download to excel sheet. i cannot download the top of page. with out write coding in program can we download it. if yes pls explain.
    thanks.

    I'm sorry but I can't find FM with DOWNLOAD_EXCEL_*.
    I want to know more detail thing.
    plz. give answer to me anytime.
    I'm waiting..
    Edited by: Kwang Seop Kim on Sep 26, 2008 6:57 AM

  • ALV grid export to Excel 2003-f.01

    Hi all,
    I have an issue with ALV grid export to excel 2003 ,when i tried to download with the option as local file > xls file ,the report downloads with page breaks which the user does not want , each break comeswith header .
    With the option of list>export>xml sheet - the report downloads with out page break but with no header information like the name of the report and reporting period .The tcode is f.01 and the system is ECC6.
    Can any one suggest  how to download the report with tiltle of the report with no page break ?
    Thanks
    ske

    Hi
    What happens if you use the export/local file option - does that help at all or can you change the layout? Haven't got access to your release to check.
    Cheers
    David
    Edited by: David Berry on Oct 28, 2010 9:38 PM

  • ALV GRID download truncates the last digit of invoice

    Hi Experts,
                     I am facing a production issue related to ALV grid download. When we click export to local file -> spread sheet,
    if it is downloaded to Excel file, invoice last digit is truncated.
    Can any body face this problem ?
    Please let me know if any body has clue to solve this strange issue.
    Thanks,
    Balaji.T.

    Hi,
    check the type of field used for invoice list. Make it type vbeln. Also try using EXit_alpha_output FM and modify the table for invoice numbers.
    Thanks,
    Sam.

  • Using download button in ALV to download to excel

    Hi,
    Please provide me the solution on using download button in Hierarchial List ALV to download to excel.I need to download the Header and Item details in a single line (in one line)in the Excel sheet.
    Please suggest the solution and sample code ASAP.
    Thanks and Regards,
    Latha.

    Hi Rames,
    my mail id : [email protected]
    Thanks and Regards,
    Vidyullatha.

  • Hi iam getting the alv grid data in excel format but iam facing one problem

    hi iam getting the alv grid data in excel format but iam facing one problem ,
    i.e., i want it read only  but iam getting it in edit mode i use layout default in excel iam getting in xl directly but in edit mode but i need it in read only mode
    what i have to do for that  and bdy knows reply me i need it urgently.

    there's always edit-mode if you choose excel-inplace - but noone can modify/rewrite the data
    A.

  • Save ALV grid to local excel-file in background

    Hi,
    i want to save a alv grid to an excel-file on a local fileshare using an background job..
    Does anybody know how this works?
    Thanks ahead

    DATA: file TYPE string VALUE `flights.dat`,
          wa   TYPE spfli.
    FIELD-SYMBOLS TYPE x.
    OPEN DATASET file FOR OUTPUT IN BINARY MODE.
    SELECT *
           FROM spfli
           INTO wa.
      ASSIGN wa TO CASTING.
      TRANSFER TO file.
    ENDSELECT.
    CLOSE DATASET file.
    <b>The binary data from database table SPFLI is transferred to a binary file flights.dat</b>

  • 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

  • ALV grid with 2 changable columns - need to update a non changable column

    I have an ALV Grid that has 2 columns that are editable (this works fine).  These two add to the total column which is not editable.  I need the total column to get updated when these two are changed.  (I have a pushbutton for the user to hit after the changes are made so it can go through the code). 
    I have check in debug mode and my internal table is getting changed.  Even until the container is check to see if it is build, the value is correct, however, once it goes into CALL METHOD GR_GRID->REFRESH_TABLE_DISPLAY, the old total comes up.  The new data in the two changable fields are there and correct.   I have tried deleting the container but that had not affect on the issue.
    I have tried freeing my table and repopulating it, calling the screen again (after setting screen to zero).  It seems the container has some sort of memory or buffer that it is getting the data from. 
    Any ideas how to make it think it is a new 1st time display?
    Thank you in advance.

    Good day Michelle,
    I had the same senario, but i did not use REFRESH_TABLE_DISPLAY instead
    do one thing that is add a save button to the alv grid and then after you change the
    data copy the changed data to an internal table.
    a sample code.
    METHOD handle_toolbar.
        DATA:
          lw_toolbar TYPE stb_button.
        CLEAR lw_toolbar.
        lw_toolbar-function = 'SAVE'.
        lw_toolbar-icon = 'ICON_DETAIL'.
        lw_toolbar-butn_type = '0'.
        lw_toolbar-text = 'SAVE'.
          APPEND lw_toolbar TO e_object->mt_toolbar.
    ENDMETHOD.
    METHOD handle_user_command.
        CASE e_ucomm.
          WHEN 'DETAIL'.
              IF t_emp1 IS NOT INITIAL.
                UPDATE zemp FROM TABLE t_emp1.
                MESSAGE 'Records changed' TYPE 'S'.
              ELSE.
                MESSAGE 'No records are changed' TYPE 'S'.
              ENDIF.
              REFRESH t_emp1.
            ENDIF.
        ENDCASE.
      ENDMETHOD.                    "handle_user_command
    T_EMP1 IS WHERE YOU STORE THE UPDATED RECORDS.
    Regards and Best wishes.

  • 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 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...

Maybe you are looking for