Pronlem while downloading ALV grid to excel

Hi Experts,
My ALV report is working fine, but problem is that when i am downloading it to excel some data is missing from some coloum
like MATNR is 0000234567 in display but after downloading to excel it comes only 23456
last digit is missing in all the rows of matnr after downloading.

- First perform [the Consistency Check|http://help.sap.com/saphelp_sm32/helpdata/EN/d6/23253963143e6ae10000000a11402f/frameset.htm] of your ALV, even if the display is fine (use shift+double click right on a free surface of the ALV)
- Look at [ Note 1075315 - Excel download: last character missing|https://service.sap.com/sap/support/notes/1075315]
- Look at [Note 358644 - ALV Export Excel: Recommendations and known errors|https://service.sap.com/sap/support/notes/358644]
Regards,
Raymond

Similar Messages

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

  • Problem while downloading ALV GRID Output to Local Spreadsheet(Excel) File.

    Hi,
    I am displaying output in ALV GRID. While downloading the output to Excel file using "Local File" option provided by ALV.
    But while downloading the columns and their respective values are coming in single column vertially of excel file instead of horizontal.
    e.g. Grid output is as follows.
    F1 F2
    V1 V2
    (F represents Field Title, and V represent Value)
    Downloaded Excel File content:-
    F1
    F2
    V1
    V2
    Please help.

    Hi ,
    Please use below FM :
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename = 'C:\Documents and Settings\akshayr2403\Desktop\docs\rep.xls'
    FILETYPE = 'WK1'
    WRITE_FIELD_SEPARATOR = 'X'
    tables
    data_tab = it_vbak
    EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH = 2
    GUI_REFUSE_FILETRANSFER = 3
    INVALID_TYPE = 4
    NO_AUTHORITY = 5
    UNKNOWN_ERROR = 6
    HEADER_NOT_ALLOWED = 7
    SEPARATOR_NOT_ALLOWED = 8
    FILESIZE_NOT_ALLOWED = 9
    HEADER_TOO_LONG = 10
    DP_ERROR_CREATE = 11
    DP_ERROR_SEND = 12
    DP_ERROR_WRITE = 13
    UNKNOWN_DP_ERROR = 14
    ACCESS_DENIED = 15
    DP_OUT_OF_MEMORY = 16
    DISK_FULL = 17
    DP_TIMEOUT = 18
    FILE_NOT_FOUND = 19
    DATAPROVIDER_EXCEPTION = 20
    CONTROL_FLUSH_ERROR = 21
    OTHERS = 22
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Also, if your problem still persist, please refer SAP's demo code on ALV "BCALV_FULLSCREEN_DEMO".
    There are many sample codes available, what you need to do is just go to SE38 and put BCALV* and do F4.
    I hope this will help you.
    Regards,
    Rahul Mahajan

  • Dump in prodcution server while downloading ALV report to excel sheet

    HI ALL,
    ALV report is working fine in bother DEV and PROD servers....but in production while downloading report to excel sheet it is going to dump.
    "dump is below:
    Short text
    Field symbol has not yet been assigned.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "SAPLKKBL" had to be terminated because it has
        come across a statement that unfortunately cannot be executed. "
    But in development this problem is not there, iam able to download ALV report to EXCEL sheet.
    Any help experts......
    Thanks in advance
    Ram

    Hi,
    I had the same problem,
    Run a consistency check for your ALV and you will find out. See if you havent passed any unnecessary parameter to FM.
    /people/rainer.hbenthal/blog/2009/09/25/sos--my-alv-report-is-not-working
    Dump while printing ALV (field symbol not assigned)
    Sumit

  • Error while downloading ALV grid o/p list  into local file

    Hello friends,
       I have developed an ALV report and desplaying it using
    'REUSE_ALV_GRID_DISPLAY, function module .While downloading the output list into excel format I am geeting an error "The current statement only supports character-type data objects.
    Error Analysis-
    In statement
       "STRLEN( obj )..."
    the argument "obj" can only take a character-type data object.
    In this case, the operand "obj" has the non-character type "P".
      I have set the import parameter i_save values as 'A'
    But still not able to download and facing the same error.
    Please help me out ....
    Thanking you....
    Regards,
    Rajesh Akarte
    Message was edited by:
            Rajesh Akarte

    Hi,
      following is the dump code..Is there any problem due to date and currency fields..?
    Error in ABAP application program.
    The current ABAP program "SAPLKKBL " had to be terminated because one of the
    statements could not be executed.
    038350       endif.
    038360       gs_out-hlplen = strlen( gs_out-hlpchar ).
    038370     elseif gs_fc-tech_form = 11.                              "INS TECH
    038380   *   Min. Ausgabelänge für ein Datum ist immer 8
    038390       if gs_fc-datatype = 'DATS'.                             "INS TECH
    038400         gs_out-hlplen = 8.                                    "INS TECH
    038410   *    Min. Ausgabelänge für eine Uhrzeit ist immer 6
    038420       elseif gs_fc-datatype = 'TIMS'.                         "INS TECH
    038430         gs_out-hlplen = 6.                                    "INS TECH
    038440       endif.                                                  "INS TECH
    038450     elseif gs_fc-tech_form = 1 or gs_fc-tech_form = 90.
    038460   *   Überführung int. in ext. Format via Konvertierungsexit
    038470       if not gs_fc-convexit is initial or                     "INS TECH
    038480          not gs_fc-inttype ca 'CN'.
    038490   *   elseif not gs_fc-convexit is initial.            "DEL TECH11
    038500         write Y9CK034230

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

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

  • How to download alv grid output(with field catalog) into excel file format

    Hi all,
    How to download alv grid output(with field catalogs) into excel file format and same file has to download to application server.
    Please help.
    Regards,
    Satya.

    Hi,
    On list where alv is displayed, select export icon( green color -> ),select spread sheet.
    This will display records in Excel sheet.

  • Problem in downloading ALV output in excel

    Dear Abapers,
                           I am facing a problem while downloading alv output in spreadsheet. Report headers and data headings are coming in excle but contents are missing instead of that No Data is displaying on excel sheet. I have debug that and observed the deep structure name T_OUTTAB using by the FM ALV_DATA_EXPORT is empty, It should contain the contents of my output data.
    Below I am giving my code. 
    ***********************************************declaration****************
          BEGIN OF d_file_out,
            index           TYPE i,                      "Index no
            msg             TYPE string,              "Message
            msgtyp(1)       TYPE c,                 "Message type
           END OF d_file_out,
    DATA:t_file_out       TYPE TABLE OF d_file_out.
    DATA:wa_file_out          TYPE d_file_out.
    Display Error Logs
    PERFORM display_logs USING text-006.
    FORM display_logs USING p_text TYPE string.
      CONSTANTS:  c_count    TYPE char5 VALUE 'INDEX',
                  c_mestyp   TYPE char6 VALUE 'MSG',
                  c_message  TYPE char7 VALUE 'MSGTYP'.
    *Field catalog
      PERFORM: z_field_catalog USING c_count   text-010,  "Record number
               z_field_catalog USING c_mestyp  text-011,  "Message type
               z_field_catalog USING c_message text-012.  "Message
    *Top of page event
      PERFORM z_event USING t_events.
    wa_layout-colwidth_optimize = c_x.
    ALV grid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
         i_buffer_active          = 'X'
           i_callback_program = sy-repid
         is_layout          = wa_layout
         I_STRUCTURE_NAME   = wa_file_out
          it_fieldcat        = t_field
          it_events          = t_events
        TABLES
          t_outtab           = t_file_out
        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.
    ***********************************Fieldcatalog**********************************************
    FORM z_field_catalog USING p_field TYPE any
                                                p_name  TYPE any.
      wa_field-fieldname = p_field.
      wa_field-seltext_l = p_name.
      IF p_field = 'INDEX'.
        wa_field-outputlen = '14'.
        wa_field-col_pos = 1.
      ELSEIF p_field = 'MSG'.
        wa_field-outputlen = '120'.
        wa_field-col_pos = 2.
      ELSEIF p_field = 'MSGTYP'.
        wa_field-outputlen = '08'.
        wa_field-col_pos = 3.
      ENDIF.
      APPEND wa_field TO t_field.
      CLEAR wa_field.
    ENDFORM. 
    Here I have given my code, which contain the building of field catalog and Calling ALV Grid. I have already checked the excel micros settings. Other programs are working fine on my system and downloading in excel is also working.
    Hope to get reply soon.
    Regards,
    Himanshu

    Hi ,
    use this to down load to xcel
    v_file = lv_file.
      DATA:  BEGIN OF s_head OCCURS 0,
             head(40) TYPE c ,
             END OF s_head.
      s_head-head = text-015."'Sales price'.   * for header
      APPEND s_head.
      s_head-head = text-016."'Purchase price'.   * for header
      APPEND s_head.
      s_head-head = text-017."'Listing Procedure'.   * for header
      APPEND s_head.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_file
         filetype                        = 'ASC'
         write_field_separator           = '#'
        TABLES
          data_tab                        = it_output1[]
          fieldnames                      = s_head[]
       EXCEPTIONS
         file_write_error                = 1
         no_batch                        = 2
         gui_refuse_filetransfer         = 3
         invalid_type                    = 4
         no_authority                    = 5
         unknown_error                   = 6
         header_not_allowed              = 7
         separator_not_allowed           = 8
         filesize_not_allowed            = 9
         header_too_long                 = 10
         dp_error_create                 = 11
         dp_error_send                   = 12
         dp_error_write                  = 13
         unknown_dp_error                = 14
         access_denied                   = 15
         dp_out_of_memory                = 16
         disk_full                       = 17
         dp_timeout                      = 18
         file_not_found                  = 19
         dataprovider_exception          = 20
         control_flush_error             = 21
         OTHERS                          = 22
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • 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,
    Ramesh

    DEAR,
    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

  • Alv grid to excel question

    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 /Otto

    This 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

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

    REPORT  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

  • Download ALV output to excel with formatting

    Hi All,
    i want to download ALV output to excel sheet and the uneditable fields in ALV oputput should be locked (uneditable) in excel also.
    Can you please tell me approach to achieve this functionality?
    Thanks in advance.

    Thanks Vamsi. Your Suggestion was helpful.
    I have used excel integration and used SET PROPERTY OF (COLUMN) 'LOCKED' = 1.
    For more details refer below mentioned link.
    http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B(Password%2Bprotected)%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in (http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B%28Password%2Bprotected%29%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in

  • Hide some cells while displaying ALV GRID !

    Hi guyz!
        Back with lill query,
        While displaying ALV GRID using REUSE_ALV_GRID... FMs ,i need to hide
        some cells by default, when the lists is generated.But those cells should
        be  availble to be displayed by the user from ALV layout settings.
        Please advise
    Thanks
    jahan

    Hi, Check for fm documentation.
    Only relevant if layout parameter
    LAYOUT-GET_SELINFOS of IMPORTING structure IS_LAYOUT is set.
    Complex type for modifying information displayed on the selection dialog box:
    mode:              'R' = Only entries passed in internal table
                              IS_SEL_HIDE-T_ENTRIES are output on
                              the dialog box. Selection information
                              obtained by the list tool by reading the
                              selection screen again (only if the report
                              is called with selection screen) are
                              replaced by the entries passed.
                       'S' = The selection information obtained by the
                              list tool by reading the selection screen
                              of the calling report again, are modified
                              by the entries of table
                              IS_SEL_HIDE-T_ENTRIES.
    t_entries:         Table with selection information
    t_entries-mode:   'A' = Display selection information of the current
                             table row on the information dialog box.
                      'D' = Do not display selection information of the
                             the Select option or of parameter SELNAME
                             on the dialog box.
    t_entries-selname: (required only if t_entries-mode = 'D')
                       name of Select option or parameter
    The following table fields are only required if t_entries-mode = 'A'. They contain the selection information to be added.
    t_entries-field:  DDIC field name of the field for which selection
                       information is to be displayed
    t_entries-table:  DDIC table name of t_entries-field.
    t_entries-stext:  Field description on the information dialog box.
                      If t_entries-field and t_entries-table were
                      filled, this text is taken from the DDIC.
    t_entries-valuf:  Selection condition from-value (external format)
    t_entries-valut:  Selection condition to-value (external format)
    t_entries-sign0:  (I)nclusive (E)xclusive
    t_entries-optio:  All values of the option field of the Select
                      option are allowed.
    The remaining fields are used internally and are irrelevant to the caller.
    aRs

  • Material num truncated while downloading the data into excel in ALV GRID

    Hi,
    I developed a report with ALV GRID display. The reoport is having Material number as one of the column. The report shows the total 10 digit material number. When i tried to downlaod the report into an excel sheet or a TXT file, material number in the text file shows only the last two digits.
    Please let me know if you have any solution for this.
    URGENT

    Hi,
    I developed a report with ALV GRID display. The reoport is having Material number as one of the column. The report shows the total 10 digit material number. When i tried to downlaod the report into an excel sheet or a TXT file, material number in the text file shows only the last two digits.
    Please let me know if you have any solution for this.
    URGENT

Maybe you are looking for

  • Regarding Standard function

    Hi I am getting 6 digit number from the source. ex 103924 in the target i want 1039.24 Please tell me is there any standard function for this and tell me how to use it. regards venkat.

  • Tablet rejected as not in database

    I was trying to turn in my Ainol NovoElfII at store number 1782.  I was trying to get the promotion for the 50 dollar gift card and the 50 dollar samsung tab offer.  This is a full working android tablet and not an e reader or nook.  I was told at th

  • How Does the scheduler works with ODI engine

    Hi All, I am new to the ODI and I was going through the documents over the web regarding the scheduling. Can anyone please let me know how does the Scheduler in ODI is coupled with the ODI engine. How does the internal scheduler works and how does th

  • More than 1 ipod shuffle

    I AM ABOUT TO PURCHASE A SECOND I POD SHUFFLE,SO CAN ANYONE TELL ME IF THERE ARE ANY PROBLEMS USING 2 IPODS IN 1 PC IE:: WILL THE PC BE ABLE TO IDENTIFY THE 2 DIFFERNT I PODS??

  • Settings get changed although no system update or manual change

    I changed some settings in Gnome under Settings>>Preferences>>Keyboard and all was working fine. I enjoyed the new settings for a few days, then today I just noticed that the settings are back to default, but I haven't performed a system update or ch