Download header data to excell

Hi guru,
I am using gui_download for downloading header data to excell.The probleam i am facing that the field length(so many descriptions) exceeds more than 256 char. so iam unable to download some of data .I want it should display in one line in the excell.
pl..this is my below code.I am only getting up to length 256 char..only.
form DOWNLOAD_COSTS .
TYPES:
BEGIN OF ty_xlhead,
  fld(1000) TYPE c,         "For header name
END OF ty_xlhead.
  DATA: l_name TYPE string.
      l_type type char10.
  l_name = wk_filename.
l_type = wk_filetype.
Data: l_filename    TYPE string,
      l_path        TYPE string.
l_filename = space.
DATA:
it_xlhead TYPE STANDARD TABLE OF ty_xlhead,
wa_xlhead TYPE ty_xlhead.
data:x_type type string.
data:x_type1 type string.
data:w_type type string.
data:x_tab like table of x_type.
concatenate 'MATERIAL' 'DESCRIPTION' 'STATUS(1)' 'TOTAL COST(1)'
'MATERIAL(1)'
'SUB CONTRACT(1)'
'FREIGHT(1)'
'DUTY(1)'
'MATERIAL HANDLING(1)'
'VOLUME SUPPLY(1)'
'SLIT LOSS(1)'
'SCRAP(1)'
'DIRECT LABOR(1)'
'VARIABLE OVERHEAD(1)'
'FIXED OVERHEAD(1)'
'STATUS(2)'
'TOTAL COST(2)'
'MATERIAL(2)'
'SUB CONTRACT(2)'
'FREIGHT(2)'
'DUTY(2)'
'MATERIAL HANDLING(2)'
'VOLUME SUPPLY(2)'
'SLIT LOSS(2)'
'SCRAP(2)'
'DIRECT LABOR(2)'
'VARIABLE OVERHEAD(2)'
'FIXED OVERHEAD(2)'
  into  x_type separated by ' '.
*append x_type to x_tab.
  CLEAR wa_xlhead.
  wa_xlhead-fld  = x_type.
  APPEND wa_xlhead TO it_xlhead.
CLEAR wa_xlhead.
wa_xlhead-fld  = x_type1.
APPEND wa_xlhead TO it_xlhead.
CALL method CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
  exporting
   WINDOW_TITLE         =
   DEFAULT_EXTENSION    =
    DEFAULT_FILE_NAME     = l_name
   WITH_ENCODING        =
   FILE_FILTER          =
   INITIAL_DIRECTORY    =
    prompt_on_overwrite  = 'X'
  CHANGING
    filename             = l_filename
    PATH                 = L_PATH
    fullpath             = l_name
   USER_ACTION          =
   FILE_ENCODING        =
  EXCEPTIONS
    cntl_error           = 1
    ERROR_NO_GUI         = 2
    not_supported_by_gui = 3
    OTHERS               = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL function 'GUI_DOWNLOAD'
  exporting
  BIN_FILESIZE                    =
    filename                        = l_name
    FILETYPE                        =  'ASC'
  APPEND                          = ' '
  WRITE_FIELD_SEPARATOR            = 'X'
  HEADER                          = '00'
  TRUNC_TRAILING_BLANKS           = ' '
  WRITE_LF                        = 'X'
  COL_SELECT                      = ' '
  COL_SELECT_MASK                 = ' '
  DAT_MODE                        = ' '
  CONFIRM_OVERWRITE               = ' '
  NO_AUTH_CHECK                   = ' '
  CODEPAGE                        = ' '
  IGNORE_CERR                     = ABAP_TRUE
  REPLACEMENT                     = '#'
  WRITE_BOM                       = ' '
  TRUNC_TRAILING_BLANKS_EOL       = 'X'
  WK1_N_FORMAT                    = ' '
  WK1_N_SIZE                      = ' '
  WK1_T_FORMAT                    = ' '
  WK1_T_SIZE                      = ' '
  WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
  SHOW_TRANSFER_STATUS            = ABAP_TRUE
IMPORTING
  FILELENGTH                      =
  tables
    data_tab                        = t_down
    FIELDNAMES                      = it_xlhead[]
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.

I think the only way to achieve this is via OLE (object link enabling).
Look at this:
[SAP OLE|http://help.sap.com/saphelp_nw70/helpdata/EN/59/ae3c98488f11d189490000e829fbbd/content.htm]
Edited by: Micky Oestreich on May 27, 2008 2:42 PM

Similar Messages

  • Download SAP data to Excel file in Presentation server

    Hi gurus,
    I need to download SAP data to excel file. for that im using SAP_CONVERT_TO_XLS_FORMAT   function module. I have to download with column header and also date should be in YYMMDD format. Im changing the format in ITAB but when populating to excel leading zero's were removed.(EX. 12102007 is converted to 071012 and it was populated as 71012). can someone explain how to use this function module or give someother solution for this....And if possible explain the parameters of the function module SAP_CONVERT_TO_XLS_FORMAT. Is there any function module for converting date as required format?
    Thanks,
    Amal

    Hi Amal...
    The Problem you are facing is because of Display properties of Microsoft Excel itself. I believe this can not be solver with in SAP. Instead I would suggest you to go for a .csv format. which can also be viewed in Excel.
    In any case if you get to find a different solution for this, I would appriciate if you can share it with me :).
    Santosh

  • Some problem of download BSP data into excel using  cl_bsp_utility= download

    Hello Experts,
    I have read the blog of thomas.jung for download bsp data into excel, and it's working correct, and after some try and error, now I can download the excel with multi sheets.It's all cool except one thing.....when I add a button on the standard screen of the supplier qualification of the slc to download the excel file, after the popinp up screen, the standard screen can't do any operation at all......there are no any error message and the downloaded file is all correct .
    Does any one know what can I do?

    any ideas?
    By the way, after some research, maybe the issue was caused by the setup of the button, but I don't know how to fix it...0rz
    the standard code for buttton is
    lv_id = mv_id && '>display'.
    lo_edit_display_button = cl_thtmlb_button=>factory( id       = lv_id
                                                       text     = lv_button_text
                                                   tooltip  = lv_button_text
                                                   enabled  = 'TRUE'
                                                  onclick  = lv_button_action ).
    WHILE io_page_context->element_process( element = lo_edit_display_button ) = if_bsp_element=>co_element_continue.
    ENDWHILE.
    so I copy it and modify like this:
    lv_id = mv_id && '>download'.
        lo_download_excel_button = cl_thtmlb_button=>factory( id       = lv_id
                                                            text     = w_text
                                                        tooltip  = w_text
                                                        enabled  = 'TRUE'
        onclick  = /srmsm/if_ql_ext_ui_c=>ZC_ACTION_DOWNLOAD_EXCEL
    WHILE io_page_context->element_process( element = lo_download_excel_button ) = if_bsp_element=>co_element_continue.
    ENDWHILE.

  • Downloading table data into Excel sheet - Webdynpro Java

    Hi All,
    We have developed a custom webdynpro application that executes an RFC and displays data in Table UI element. We have provided a button to download the data in excel sheet. When data is huge like, total number of rows filled up in the table are around 11,000 & columns are 32, and when user tries to download whole 11000 rows in excel sheet, the timeout occurs after 20 mins due to huge data. But when I apply filtering on the same table data and then try to download some 700 rows out of 11000 into excel, it took me around 3.36 mins.
    If anyone encountered such scenario in past, please guide in this regard to speed-up the download to excel functionality or suggest any other alternative.
    We are using 7.3 Portal and tableUtilities java class for export to excel functionality.
    Thanks,
    Amol.

    hi monica ,
    sorry im not able to understand properly ,
    The server don't restarts automatically when we uploading a huge data, onlly we open the file instead of save the file.
    If we save the file the problem is that when we try to open this, the process can take hours and sometimes excel is blocked
    you mean that after saving the file to your desktop , having huge data you are not able to open the file i.e the excel file. your file gets blocked or consumes more time to open the file ,
    or else when you are prompted for saving or opening , on click of opening  you are facing the problem ?
    let me be clear with your part , here your application deals with uploading the data from webdynpro table to excel sheet and allowing the end user to save or open the file  right .
    Regards
    Govardan Raj S

  • Download Header details to Excel

    Hi Experts,
    Can we download header text to excel?
    Regards
    Mani

    Hi Mani!
    You need extract this message with FM READ_TEXT and FM GUI_DOWNLOAD.
    Regards.

  • Downloading the data in excel format

    Hi All,
       I am downloading the data in excel format using FM CONVERT_SAP_TO_XLS_FORMAT and able to open the file in my machine since my machine is having EXCEL 2003 version. In some other machines i tried to download and open,  but after downloading the data in some machines we couldnt open the file since those machines are having the excel2007 versions. but my requirement is i need to open in 2007 version also, please tell me solution.
    With Regards,
    Prasad.

    Hi Lalit,
    Thank you for your information,
    but this function modules EXCEL_OLE_STANDARD_DAT, RH_START_EXCEL_WITH_DATA   cant help to solve my issue,  my requirement is i need to download sap data in excelformat, problem comes here, if i download internal table, in that any text that starts with double cotes and ending with not double cotes, the data is not downloading properly and all the data cramped into one cell. To solve this issue i have used functinal module SAP_CONVERT_TO_XLS_FORMAT and i am able to download without any problem,  but in clients machines they are able to download and they are not able to open as they are having EXCEL 2007 in their machines.
    if is there any solution, please update me.
    Thanks in Advance
    Prasad
    Edited by: bs prasad on Mar 28, 2009 8:03 AM
    Edited by: bs prasad on Mar 28, 2009 8:05 AM

  • Problem in Downloading the data in Excel..

    Hi all,
    In my report program iam getting output. In the output iam having one push button to download the data in excel-sheet.so here when i was download the data in excel sheet in one perticular column(assume D column) iam getting invoice text.
    ex: Invoice text: This is good.
    But that text is coming properly for some orders and for some orders it was not coming properly.(This is g).
    Can any body Please tell me the way..
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 21, 2008 1:05 PM

    Hi ,
    Here i told know for some orders iam getting the invoice text:This is g.
    when i click on this cell lots more data records all within that one cell. This is for only some orders.
    Is there any way to resolve this problem.

  • Download BSP data into Excel

    Hello all,
    I want create a BSP page, with 2 radio buttons,
    If 1st selected I want read 2 tables and display data other BSP page.
    If 2nd one selected I want download 2 tables data into excel file.
    Any one can help how to download data into excel file and display data into other bsp page.
    Thanks,
    Regards,
    Venkat

    For downloading to a spread sheet:
    Convert your fetched data to a string and convert to XSTRING format and finally download to a spread sheet.
    Sample: I selected data from vbak say vbeln and kunnr in an internal table.
    data : v_string type string, v_xstring type xstring.
    <header portion - to have the heading in the spread sheet>
    concatenate 'Order Number' 'Customer'
       cl_abap_char_utilities=>cr_lf into v_string
       separated by cl_abap_char_utilities=>horizontal_tab.
    <Line item entries from my internal table say i_vbak>
    loop at i_vbak into wa_vbak.
      concatenate v_string wa_vbak-vbeln wa_vbak-kunnr
       cl_abap_char_utilities=>cr_lf into v_string
       separated by cl_abap_char_utilities=>horizontal_tab.
    endloop.
    All the data is now in string format. Calling the FM to convert to XSTRING
      call function 'SCMS_STRING_TO_XSTRING'
        exporting
          text     = v_string
          mimetype = 'APPLICATION/MSEXCEL; charset=utf-16le' (probably create this in a variable and call here)
        importing
          buffer   = v_xstring.
    concatenate cl_abap_char_utilities=>byte_order_mark_little v_xstring into v_xstring in byte mode.
    Now we have it in XSTRING format - this can be downloaded to a spread sheet.
    v_appl = 'APPLICATION/MSEXCEL; charset=utf-16le'.
    runtime->server->response->set_header_field( name = 'content-type' value = v_appl ).
    Eliminating the cache problems when loading Excel Format
    runtime->server->response->delete_header_field( name = if_http_header_fields=>cache_control ).
    runtime->server->response->delete_header_field( name = if_http_header_fields=>expires ).
    runtime->server->response->delete_header_field( name = if_http_header_fields=>pragma ).
    Start excel in a separate window
    runtime->server->response->set_header_field( name = 'content-disposition' value = 'attachment; filename=Order_list.xls' ).
    Displaying the data in excel.
    v_len = xstrlen( v_xstring ).
    runtime->server->response->set_data( data = v_xstring length = v_len ).
    navigation->response_complete( ).
    All the above code can be written in onInputprocessing event (probably your loop/selection can be in a method of your appl class).
    I believe you are triggering the event based on a click (say radio button or a button after selecting the radiobutton).
    In the other screen you can use tableview to display your data - probably two sub screens(page fragment) to display each table.
    Regds,
    Krish

  • How to download output data into Excel with all Column Headings

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

    VERSION CONTROL (Most recent on top):                                *
      DATE(mm.dd.yyyy)    AUTHOR                                         *
      06.25.2007         Pattan Naveen                                   *
    Hi yogesh,,
    Go through this in this u find ur solution.
    report ZTEst_programe no standard page heading
                               line-size 100
                               line-count 50(5)
                               message-id zz.
    *--alv type declaration
    type-pools: slis.
    *--Tables:
    tables: anla,
            anlz,
            anlh,
            anlb,
            anlc.
    data: v_pos type i.
    data: v_ndjar type i.
    data: v_ndper type i,
          v_ndperndabp type i,
          v_ndjarndabp1 type i,
          v_ndjarndabp type i,
          value type i,
    date(10) type c value '2006.12.04'.
    data: c_0000(4) type c value '0000'.
    data: begin of it_final occurs 0,
             anlkl(8),
             bukrs(4),
             anln1 like anla-anln1,
             anln2 like anla-anln2,
             txt50 like anla-txt50,
             txa50 like anla-txa50,
             anlhtxt like anlh-anlhtxt,
             sernr like anla-sernr,
             invnr like anla-invnr,
             menge like anla-menge,
             meins like anla-meins,
             inken like anla-inken,
               ivdat like anla-ivdat,
             aktiv like anla-aktiv,
             gsber like anlz-gsber,
             kostl like anlz-kostl,
             kostlv like anlz-kostlv,
             werks like anlz-werks,
             stort like anlz-stort,
              raumn like anlz-raumn,
              txjcd like anlz-txjcd,
             ord41 like anla-ord41,
             ord44 like anla-ord44,
             gdlgrp like anla-gdlgrp,
             anlue like anla-anlue,
             lifnr like anla-lifnr,
             typbz like anla-typbz,
             aibn1 like anla-aibn1,
          aibn2 like anla-aibn2,
            aibdt like anla-aibdt,
             posnr like anla-posnr,
            vmgli like anla-vmgli,
            invzu like anla-invzu,
            ernam like anla-ernam,
            erdat like anla-erdat,
             afabe like anlb-afabe,
            afasl like anlb-afasl,
             ndjar like anlb-ndjar,
             ndper like anlb-ndper,
            afabg like anlb-afabg,
            ndabj like anlc-ndabj,
            ndabp like anlc-ndabp,
            andsj like anlc-andsj,
             andsp like anlc-andsp,
            safbg like anlb-safbg,
             umjar like anlb-umjar,
           inbda like anlb-inbda,
           kansw like anlc-kansw,
           knafa like anlc-knafa,
            kaafa like anlc-kaafa,
                     deakt like anla-deakt,
    kanza like anlc-kanza,
    kaufw like anlc-kaufw,
    kinvz like anlc-kinvz,
    ksafa like anlc-ksafa,
    kmafa like anlc-kmafa,
      end of it_final.
    data: begin of it_final_as91 occurs 0,
             anlkl(8),
             bukrs(4),
             anln1 like anla-anln1,
             anln2 like anla-anln2,
             txt50 like anla-txt50,
             txa50 like anla-txa50,
             anlhtxt like anlh-anlhtxt,
             sernr like anla-sernr,
             invnr like anla-invnr,
             menge like anla-menge,
             meins like anla-meins,
             inken like anla-inken,
             ivdat like anla-ivdat,
             aktiv like anla-aktiv,
             gsber like anlz-gsber,
             kostl like anlz-kostl,
             kostlv like anlz-kostlv,
             werks like anlz-werks,
             stort like anlz-stort,
             raumn like anlz-raumn,
             txjcd like anlz-txjcd,
             ord41 like anla-ord41,
             ord44 like anla-ord44,
             gdlgrp like anla-gdlgrp,
             anlue like anla-anlue,
             lifnr(10),
             typbz(15),
             aibn1 like anla-aibn1,
             aibn2 like anla-aibn2,
            aibdt like anla-aibdt,
             posnr like anla-posnr,
            vmgli like anla-vmgli,
            invzu like anla-invzu,
            ernam like anla-ernam,
            erdat like anla-erdat,
    end of it_final_as91.
    data: it_download_as91 like it_final_as91 occurs 0
                                              with header line."#EC NEEDED
    data: begin of it_final_as92 occurs 0,
             anlkl(8),
             bukrs(4),
             anln1 like anla-anln1,
             anln2 like anla-anln2,
             deakt like anla-deakt,
             ernam like anla-ernam,
             erdat like anla-erdat,
             afabe like anlb-afabe,
             afasl like anlb-afasl,
             ndjar like anlb-ndjar,
             ndper like anlb-ndper,
              afabg like date,
             ndabj(3) type c,
             ndabp(3) type c,
            kansw like anlc-kansw,
           knafa like anlc-knafa,
            kaafa like anlc-kaafa,
    kanza like anlc-kanza,
    kaufw like anlc-kaufw,
    kinvz like anlc-kinvz,
    ksafa like anlc-ksafa,
    kmafa like anlc-kmafa,
      end of it_final_as92.
    data: it_download_as92 like it_final_as92 occurs 0
                                              with header line."#EC NEEDED
    data: begin of it_values occurs 0,
             anlkl(8),
             bukrs(4),
             anln1 like anla-anln1,
             anln2 like anla-anln2,
             deakt like anla-deakt,
             afabe like anlb-afabe,
            afasl like anlb-afasl,
             ndjar like anlb-ndjar,
             ndper like anlb-ndper,
             afabg like date,
             ndabj(3) type c,
             ndabp(3) type c,
             afabe_02 like anlb-afabe,
             afasl_02 like anlb-afasl,
             ndjar_02 like anlb-ndjar,
             ndper_02 like anlb-ndper,
              afabg_02 like date,
             ndabj_02 like anlc-ndabj,
             ndabp_02 like anlc-ndabp,
            kansw01 like anlc-kansw,
           knafa01 like anlc-knafa,
            kaafa01 like anlc-kaafa,
              kansw02 like anlc-kansw,
           knafa02 like anlc-knafa,
            kaafa02 like anlc-kaafa,
              kansw03 like anlc-kansw,
           knafa03 like anlc-knafa,
            kaafa03 like anlc-kaafa,
              kansw04 like anlc-kansw,
           knafa04 like anlc-knafa,
            kaafa04 like anlc-kaafa,
              kansw05 like anlc-kansw,
           knafa05 like anlc-knafa,
            kaafa05 like anlc-kaafa,
           kansw06 like anlc-kansw,
           knafa06 like anlc-knafa,
           kaafa06 like anlc-kaafa,
           kansw07 like anlc-kansw,
           knafa07 like anlc-knafa,
           kaafa07 like anlc-kaafa,
           kansw08 like anlc-kansw,
           knafa08 like anlc-knafa,
           kaafa08 like anlc-kaafa,
           kansw09 like anlc-kansw,
           knafa09 like anlc-knafa,
           kaafa09 like anlc-kaafa,
    kanza01 like anlc-kanza,
    kaufw01 like anlc-kaufw,
    kinvz01 like anlc-kinvz,
    ksafa01 like anlc-ksafa,
    kmafa01 like anlc-kmafa,
      end of it_values.
    data: it_values_xls like it_values occurs 0
                                       with header line."#EC NEEDED
    data: begin of it_itab1 occurs 0,
           bukrs like anla-bukrs,
           anlkl like anla-anlkl,
           anln1 like anla-anln1,
             anln2 like anla-anln2,
           txt50 like anla-txt50,
           txa50 like anla-txa50,
           invnr like anla-invnr,
           ktogr like anla-ktogr,
           sernr like anla-sernr,
           menge like anla-menge,
           meins like anla-meins,
           ivdat like anla-ivdat,
           inken like anla-inken,
           aktiv like anla-aktiv,
           deakt like anla-deakt,
           zugdt like anla-zugdt,
           zujhr like anla-zujhr,
           zuper like anla-zuper,
           gdlgrp like anla-gdlgrp,
           anlue like anla-anlue,
           xafabch like anla-xafabch,
           aibn1 like anla-aibn1,
           aibn2 like anla-aibn2,
           aibdt like anla-aibdt,
           posnr like anla-posnr,
           ord41 like anla-ord41,
            ord44 like anla-ord44,
            vmgli like anla-vmgli,
             invzu like anla-invzu,
             typbz like anla-typbz,
             lifnr like anla-lifnr,
             ernam like anla-ernam,
             erdat like anla-erdat,
          end of it_itab1.
    data: begin of it_itab2 occurs 0,
            bukrs like anlz-bukrs,
            anln1 like anlz-anln1,
             anln2 like anla-anln2,
            bdatu like anlz-bdatu,
            werks like anlz-werks,
            gsber like anlz-gsber,
            kostl like anlz-kostl,
            kostlv like anlz-kostlv,
            stort like anlz-stort,
            raumn like anlz-raumn,
            txjcd like anlz-txjcd,
            ipsnr like anlz-ipsnr,
          end of it_itab2.
    data: begin of it_itab3 occurs 0,
            bukrs like anlh-bukrs,
            anln1 like anlh-anln1,
            anlhtxt like anlh-anlhtxt,
           end of it_itab3.
    data: begin of it_itab4 occurs 0,
            bukrs like anlb-bukrs,
            anln1 like anlb-anln1,
             anln2 like anla-anln2,
            afabe like anlb-afabe,
            bdatu like anlb-bdatu,
            afasl like anlb-afasl,
            ndjar like anlb-ndjar,
            ndper like anlb-ndper,
            afabg like anlb-afabg,
            ndurj like anlb-ndurj,
            ndurp like anlb-ndurp,
            umjar like anlb-umjar,
            safbg like anlb-safbg,
            zinbg like anlb-zinbg,
            inbda like anlb-inbda,
            end of it_itab4.
    data: begin of it_itab5 occurs 0,
           bukrs like anlc-bukrs,
           anln1 like anlc-anln1,
             anln2 like anla-anln2,
           gjahr like anlc-gjahr,
           afabe like anlc-afabe,
           zujhr like anlc-zujhr,
           zucod like anlc-zucod,
           ndabj like anlc-ndabj,
           ndabp like anlc-ndabp,
           kansw like anlc-kansw,
           knafa like anlc-knafa,
           kaafa like anlc-kaafa,
           ksafa like anlc-ksafa,
           andsj like anlc-andsj,
           andsp like anlc-andsp,
    kanza like anlc-kanza,
    kaufw like anlc-kaufw,
    kinvz like anlc-kinvz,
    kmafa like anlc-kmafa,
          end of it_itab5.
    ALV DECLARATIONS
    *--declarations for Xls sheet header field names
    data: begin of it_head occurs 0,
    column(70).
    data: end of it_head.
    data: begin of it_head1 occurs 0,
    column(70).
    data: end of it_head1.
    *--type declarations for field catalog for basic report
    data: it_fldcat_head  type slis_t_fieldcat_alv,
          wa_fldcat_head type slis_fieldcat_alv."#EC NEEDED
    data : w_field type slis_fieldcat_alv."#EC NEEDED
    data: it_fldcat_head1  type slis_t_fieldcat_alv,
          wa_fldcat_head1 type slis_fieldcat_alv."#EC NEEDED
    *--type declarations for layout design
    data: wa_layout type slis_layout_alv.
    *--type declarations for list header on grid
    *data: top_of_page type slis_t_listheader.
    *--declaration of variables
    data : w_repid like sy-repid.
    **selection-screen
    select-options: s_bukrs for anla-bukrs,
                    s_anln1 for anla-anln1.
    select-options: s_deakt for anla-deakt,
                    s_gjahr for anlc-gjahr obligatory,
                    s_anlkl for anla-anlkl,
                    s_date for anla-aktiv.
    *selection-screen
    selection-screen begin of block blk1 with frame title  text-022.
    selection-screen begin of line.
    parameters : r1 radiobutton group g1 default 'X'.
    selection-screen comment 20(50) text-020.
    selection-screen end of line.
    selection-screen begin of line.
    parameters : r2 radiobutton group g1.
    selection-screen comment 20(50) text-021.
    selection-screen end of line.
    selection-screen end of block blk1.
    selection-screen begin of block blk2 with frame title  text-023.
    select-options: s_ernam for anla-ernam,
                       s_erdat for anla-erdat .
    selection-screen end of block blk2.
    *--INITIALIZATION
    initialization.
      w_repid = sy-repid.
    at selection-screen.
      if r1 = 'X'.
        perform selection_screen_validation.
      endif.
      if r2 = 'X'.
        perform selection_screen_validation.
      endif.
    *--START-OF-SELCTION
    start-of-selection.
      if r1 = 'X'.
        perform populate-data.
        perform fill_finaldata.
       perform comment_build using top_of_page.
        perform xls_output.
        perform download.
      endif.
      if r2 = 'X'.
        perform populate-data.
        perform fill_finaldata.
        perform fill_as92data.
        perform putdata_horizontal.
        perform xls_output_as92.
        perform download_as92.
      endif.
    *--END-OF-SELCTION
    end-of-selection.
      if r1 = 'X'.
        perform build_layout.
        perform build_fieldcatalog.
       perform top_of_page.
        perform list-display.
      endif.
      if r2 = 'X'.
        perform build_layout.
        perform build_fieldcatalog1.
        perform list-display1.
      endif.
    *&      Form  SELECTION_SCREEN_VALIDATION
          text
    -->  p1        text
    <--  p2        text
    form selection_screen_validation.
    *--validating originating company code
      data: l_bukrs like anla-bukrs."#EC NEEDED
      if not s_bukrs[] is initial.
        select single bukrs from anla
               into l_bukrs
               where bukrs in s_bukrs.
        if sy-subrc <> 0.
          message e000 with text-001 .
        endif.
      endif.
    *--validating originating main asset no.
      data: l_anln1 like anla-anln1."#EC NEEDED
      if not s_anln1[] is initial.
        select single anln1 from anla
               into l_anln1
               where anln1 in s_anln1.
        if sy-subrc <> 0.
          message e000 with text-002 .
        endif.
      endif.
    *--validating originating Deactivation date
      data: l_deakt like anla-deakt."#EC NEEDED
      if not s_deakt[] is initial.
        select single deakt from anla
               into l_deakt
               where deakt in s_deakt.
        if sy-subrc <> 0.
          message e000 with text-004 .
        endif.
      endif.
    *--validating originating asset class.
      data: l_anlkl like anla-anlkl."#EC NEEDED
      if not s_anlkl[] is initial.
        select single anlkl from anla
               into l_anlkl
               where anlkl in s_anlkl.
        if sy-subrc <> 0.
          message e000 with text-006 .
        endif.
      endif.
    *--validating originating Date
      data: l_date like anla-aktiv."#EC NEEDED
      if not s_date[] is initial.
        select single aktiv from anla
               into l_date
               where aktiv in s_date.
        if sy-subrc <> 0.
          message e000 with text-007 .
        endif.
      endif.
    *--validating originating Fiscal year which first acquisition was posted
      data: l_gjahr like anlc-gjahr."#EC NEEDED
      if not s_gjahr[] is initial.
        select single gjahr from anlc
               into l_gjahr
               where gjahr in s_gjahr.
        if sy-subrc <> 0.
          message e000 with text-008.
        endif.
      endif.
      data: l_ernam like anla-ernam."#EC NEEDED
      if not s_ernam[] is initial.
        select single ernam from anla
               into l_ernam
               where ernam in s_ernam.
        if sy-subrc <> 0.
          message e000 with text-009.
        endif.
      endif.
      data: l_erdat like anla-erdat."#EC NEEDED
      if not s_erdat[] is initial.
        select single erdat from anla
               into l_erdat
               where erdat in s_erdat.
        if sy-subrc <> 0.
          message e000 with text-010.
        endif.
      endif.
    endform.                    " SELECTION_SCREEN_VALIDATION
    *&      Form  POPULATE-DATA
          text
    -->  p1        text
    <--  p2        text
    form populate-data.
      select bukrs
             anlkl
             anln1
             anln2
             txt50
             txa50
             invnr
             ktogr
             sernr
             menge
             meins
             ivdat
             inken
             aktiv
             deakt
             zugdt
             zujhr
             zuper
             gdlgrp
             anlue
             xafabch
             aibn1
             aibn2
             aibdt
             posnr
             ord41
             ord44
             vmgli
             invzu
             typbz
             lifnr
             ernam
             erdat
            from anla
                into table it_itab1
                where anlkl in s_anlkl and
                      anln1 in s_anln1 and
                      deakt in s_deakt and
                      bukrs in s_bukrs and
                      aktiv in s_date.
      if sy-subrc ne 0.
        message e000 with 'Data does not exist'(094).
      endif.
      if not it_itab1[] is initial.
        select bukrs
               anln1
               anln2
               bdatu
               werks
               gsber
               kostl
               kostlv
               stort
               raumn
               txjcd
               ipsnr
               from anlz
               into table it_itab2
               for all entries in it_itab1
               where bukrs = it_itab1-bukrs and
                     anln1 = it_itab1-anln1 and
                    anln2 = it_itab1-anln2.
                      anln2 = '0000'.
        if sy-subrc ne 0.
          message e000 with 'Data does not exist'(094).
        endif.
      endif.
      if not it_itab2[] is initial.
        select bukrs
               anln1
               anlhtxt
               from anlh
               into table it_itab3
        for all entries in it_itab2
        where bukrs = it_itab2-bukrs and
              anln1 = it_itab2-anln1.
        if sy-subrc ne 0.
          message e000 with 'Data does not exist'(094).
        endif.
      endif.
      if not it_itab1[] is initial.
        select bukrs
        anln1
        anln2
        afabe
        bdatu
        afasl
        ndjar
        ndper
        afabg
        ndurj
        ndurp
        umjar
        safbg
        zinbg
        inbda
        from anlb
        into table it_itab4
        for all entries in it_itab1
        where bukrs = it_itab1-bukrs and
              anln1 = it_itab1-anln1 and
             anln2 = it_itab1-anln2.
               anln2 = '0000'.
        if sy-subrc ne 0.
          message e000 with 'Data does not exist'(094).
        endif.
      endif.
      sort it_itab4  by bukrs anln1 anln2 afabe.
      if not it_itab4[] is initial.
        select bukrs
              anln1
              anln2
             gjahr
            afabe
            zujhr
            zucod
             ndabj
             ndabp
             kansw
             knafa
             kaafa
             ksafa
             andsj
             andsp
             kanza
    kaufw
    kinvz
    kmafa
             from anlc
             into table it_itab5
             for all entries in it_itab4
             where bukrs = it_itab4-bukrs and
                anln1 = it_itab4-anln1 and
               anln2 = it_itab4-anln2 and
                anln2 = '0000' and
                gjahr in s_gjahr.
        if sy-subrc ne 0.
          message e000 with 'Data does not exist'(094).
        endif.
      endif.
      sort it_itab5 by bukrs anln1 anln2 ndabj ndabp.
    endform.                    " POPULATE-DATA
    *&      Form  FILL_FINALDATA
          text
    -->  p1        text
    <--  p2        text
    form fill_finaldata.
      loop at it_itab5.
        loop at it_itab4 where bukrs = it_itab5-bukrs and
                            anln1 = it_itab5-anln1 and
                            anln2 = it_itab5-anln2 and
                            afabe = it_itab5-afabe.
          it_final-afabe = it_itab4-afabe.
          it_final-afasl = it_itab4-afasl.
          it_final-ndjar = it_itab4-ndjar.
          it_final-ndper = it_itab4-ndper.
          it_final-afabg = it_itab4-afabg.
          it_final-umjar = it_itab4-umjar.
          it_final-safbg = it_itab4-safbg.
          it_final-inbda = it_itab4-inbda.
          it_final-ndabj = it_itab5-ndabj.
          it_final-ndabp = it_itab5-ndabp.
          it_final-kansw = it_itab5-kansw.
          it_final-knafa = it_itab5-knafa.
          it_final-kaafa = it_itab5-kaafa.
          it_final-andsj = it_itab5-andsj.
          it_final-andsp = it_itab5-andsp.
          it_final-kanza = it_itab5-kanza.
          it_final-kaufw = it_itab5-kaufw.
          it_final-kinvz = it_itab5-kinvz.
          it_final-ksafa = it_itab5-ksafa.
          it_final-kmafa = it_itab5-kmafa.
          read table it_itab1 with key   bukrs = it_itab5-bukrs
                                      anln1 = it_itab5-anln1
                                      anln2 = it_itab5-anln2.
          if sy-subrc = 0.
            it_final-anlkl = it_itab1-anlkl.
            it_final-anln1 = it_itab1-anln1.
            it_final-anln2 = it_itab1-anln2.
            it_final-bukrs = it_itab1-bukrs.
            it_final-txt50 = it_itab1-txt50.
            it_final-txa50 = it_itab1-txa50.
            it_final-invnr = it_itab1-invnr.
            it_final-sernr = it_itab1-sernr.
            it_final-menge = it_itab1-menge.
            it_final-meins = it_itab1-meins.
            it_final-ivdat = it_itab1-ivdat.
            it_final-inken = it_itab1-inken.
            it_final-aktiv = it_itab1-aktiv.
            it_final-deakt = it_itab1-deakt.
            it_final-gdlgrp = it_itab1-gdlgrp.
            it_final-anlue = it_itab1-anlue.
            it_final-aibn1 = it_itab1-aibn1.
            it_final-aibn2 = it_itab1-aibn2.
            it_final-aibdt = it_itab1-aibdt.
            it_final-ord41 = it_itab1-ord41.
            it_final-ord44 = it_itab1-ord44.
            it_final-vmgli = it_itab1-vmgli.
            it_final-typbz = it_itab1-typbz.
            it_final-lifnr = it_itab1-lifnr.
            it_final-posnr = it_itab1-posnr.
            it_final-invzu = it_itab1-invzu.
          endif.
          read table it_itab2 with key   bukrs = it_itab5-bukrs
                                    anln1 = it_itab5-anln1
                                    anln2 = it_itab5-anln2.
          if sy-subrc = 0.
            it_final-werks = it_itab2-werks.
            it_final-gsber = it_itab2-gsber.
            it_final-kostl = it_itab2-kostl.
            it_final-kostlv = it_itab2-kostlv.
            it_final-stort = it_itab2-stort.
            it_final-raumn = it_itab2-raumn.
            it_final-txjcd = it_itab2-txjcd.
          endif.
          read table it_itab3 with key  bukrs = it_itab5-bukrs
                                     anln1 = it_itab5-anln1.
          if sy-subrc = 0.
            it_final-anlhtxt = it_itab3-anlhtxt.
          endif.
          append it_final.
          clear it_final.
        endloop.
      endloop.
      loop at it_final.
        move-corresponding it_final to it_final_as91.
        append it_final_as91.
        clear it_final_as91.
      endloop.
      delete adjacent duplicates from it_final_as91 comparing anlkl bukrs
      anln1 anln2.
      it_download_as91[] = it_final_as91[].
    endform.                    " FILL_FINALDATA
    *&      Form  BUILD_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    form build_layout.
      wa_layout-zebra = 'X'.
    endform.                    " BUILD_LAYOUT
    *&      Form  BUILD_FIELDCATALOG
          text
    -->  p1        text
    <--  p2        text
    form build_fieldcatalog.
      if it_fldcat_head is initial.
        v_pos = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'ANLKL'.
        wa_fldcat_head-seltext_l = 'Asset Class'(093).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'BUKRS'.
        wa_fldcat_head-seltext_l = 'Company'(092).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'ANLN1'.
        wa_fldcat_head-seltext_l = 'Asset No'(091).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'ANLN2'.
        wa_fldcat_head-seltext_l = 'Asset Sub No'(090).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'TXT50'.
        wa_fldcat_head-seltext_l = 'Asset Des.'(089).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'TXA50'.
        wa_fldcat_head-seltext_l = 'Asset Des.'(088).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'ANLHTXT'.
        wa_fldcat_head-seltext_l = 'Asset main no txt'(087).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'SERNR'.
        wa_fldcat_head-seltext_l = 's.no/Expl no.'(086).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'INVNR'.
        wa_fldcat_head-seltext_l = 'Inv No'(085).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'MENGE'.
        wa_fldcat_head-seltext_l = 'Qtty'(084).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'MEINS'.
        wa_fldcat_head-seltext_l = 'Units'(083).
        append wa_fldcat_head to it_fldcat_head.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'INKEN'.
        wa_fldcat_head-seltext_l = 'Inv indi.'(082).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'IVDAT'.
        wa_fldcat_head-seltext_l = 'Last inv date'(081).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'AKTIV'.
        wa_fldcat_head-seltext_l = 'Asset Capital date'(080).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'GSBER'.
        wa_fldcat_head-seltext_l = 'Busin. Area'(079).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'KOSTL'.
        wa_fldcat_head-seltext_l = 'cost centre'(078).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'KOSTLV'.
        wa_fldcat_head-seltext_l = 'CC respon.for asset'(077).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'WERKS'.
        wa_fldcat_head-seltext_l = 'Plant'(076).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'STORT'.
        wa_fldcat_head-seltext_l = 'Asset location'(075).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'RAUMN'.
        wa_fldcat_head-seltext_l = 'Room'(074).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'TXJCD'.
        wa_fldcat_head-seltext_l = 'Tax. Jur.'(073).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'ORD41'.
        wa_fldcat_head-seltext_l = 'Evaluation Grp 1'(072).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'ORD44'.
        wa_fldcat_head-seltext_l = 'Evaluation Grp 4'(071).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'GDLGRP'.
        wa_fldcat_head-seltext_l = 'Evalu. group 5'(070).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'ANLUE'.
        wa_fldcat_head-seltext_l = 'Asset Super No'(069).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'LIFNR'.
        wa_fldcat_head-seltext_l = 'Vendor Acct. No.'(068).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'TYPBZ'.
        wa_fldcat_head-seltext_l = 'Reference no'(067).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'AIBN1'.
        wa_fldcat_head-seltext_l = 'Original Asset Trans.'(066).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'AIBN2'.
        wa_fldcat_head-seltext_l = 'Original Asset Trans.'(065).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'AIBDT'.
        wa_fldcat_head-seltext_l = 'Trans. Asset'(064).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'POSNR'.
        wa_fldcat_head-seltext_l = 'WBS Elt. Invt. Proj.'(063).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'VMGLI'.
        wa_fldcat_head-seltext_l = 'Property clas.key'(062).
        append wa_fldcat_head to it_fldcat_head.
       V_POS = 0.
        v_pos = v_pos + 1.
        w_field-col_pos = v_pos.
        wa_fldcat_head-tabname = 'it_FINAL_AS91'.
        wa_fldcat_head-fieldname = 'INVZU'.
        wa_fldcat_head-seltext_l = 'suppl.inv spec.'(061).
        append wa_fldcat_head to it_fldcat_head.
      endif.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  COMMENT_BUILD
          text
         -->P_TOP_OF_PAGE  text
    *form comment_build using top_of_page type slis_t_listheader.
    data: ls_line type slis_listheader.
    ****Header
    clear : ls_line.
    ls_line-typ = 'H'.
    LS_LINE-KEY: not used for this type
    ls_line-info = 'ASSET MASTER DATA LIST'.
    append ls_line to top_of_page.
    ****Selection
    clear ls_line.
    ls_line-typ = 'S'.
    ls_line-key = 'Key 1'.
    ls_line-info = 'Asset Records'.
    append ls_line to top_of_page.
    ****Action
    clear ls_line.
    ls_line-typ = 'A'.
    LS_LINE-KEY: not used for this type
    ls_line-info = 'for AS91'.
    append ls_line to top_of_page.
    *endform. "comment_build
          FORM top_of_page                                              *
    *form top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
          exporting
               i_logo             = 'ENJOYSAP_LOGO'
               it_list_commentary = top_of_page.
    *endform. "top_of_page
    *&      Form  LIST-DISPLAY
          text
    -->  p1        text
    <--  p2        text
    form list-display.
    wa_layout-colwidth_optimize = 'X'.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program     = w_repid
               i_callback_top_of_page = 'TOP_OF_PAGE'
                is_layout              = wa_layout
                it_fieldcat            = it_fldcat_head
               i_background_id        = 'ALV_BACKGROUND'
           tables
                t_outtab               = it_final_as91
           exceptions
                program_error          = 1
                others                 = 2.
      if sy-subrc <> 0.
    write:/'No Top of Page'(098).
      endif.
    endform.                    " LIST-DISPLAY
    *&      Form  DOWNLOAD
          text
    -->  p1        text
    <--  p2        text
    form download.
      perform setup_header.
      call function 'DOWNLOAD'
           exporting
                filetype                = 'DAT'
           tables
                data_tab                = it_download_as91
                fieldnames              = it_head
           exceptions
                invalid_filesize        = 1
                invalid_table_width     = 2
                invalid_type            = 3
                no_batch                = 4
                unknown_error           = 5
                gui_refuse_filetransfer = 6
                customer_error          = 7
                others                  = 8.
      if sy-subrc <> 0.
    write:/'Error in file Type'(097).
      endif.
    endform.                    " DOWNLOAD
    *&      Form  setup_header
          text

  • Downloading the data into excel sheet , how can i maintain page numbers

    I need some information. In output screen pagenumber is displayed.
    when i am downloading the data from se38 into excel sheet.
    How can i write the code to display the page number in excel sheet . waiting for your response

    Hi
    Please see below code for ur requirement.
    DATA: BEGIN OF li_field OCCURS 0,
              field(16) TYPE c,
           END OF li_field.
      CLEAR li_field[].
      REFRESH li_field.
      li_field-field = text-t01.
      APPEND li_field.
      CLEAR  li_field.
      li_field-field = text-006.
      APPEND li_field.
      CLEAR  li_field.
      li_field-field = text-t04.
      APPEND li_field.
      CLEAR  li_field.
      li_field-field = text-t05.
      APPEND li_field.
      CLEAR  li_field.
      CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
        EXPORTING
          file_name                 = file_path
        TABLES
          data_tab                  = data_table
          fieldnames                = li_field
        EXCEPTIONS
          file_not_exist            = 1
          filename_expected         = 2
          communication_error       = 3
          ole_object_method_error   = 4
          ole_object_property_error = 5
          invalid_pivot_fields      = 6
          download_problem          = 7
          OTHERS                    = 8.
    please reward points if helpful

  • Download the data into excel sheet

    hello experts,
    I am using the GUI_DOWNLOAD fm to download the data in to excell sheet on to the desktop but here i am getting some problem
    For some of the fields i put constant values like '004' or '001' when it is downloaded the data into to .xls its removing the leading zeros.. and just downloading the values as 4 or 1
    can anyone guide me how to hold those leading zeros
    its bit urgent plz

    These are XL Issue ,you can use diffrenet logic
    Check the below logic :
    REPORT ZTEST3 line-size 400.
    <b>DATA : V_CHAR(1) TYPE C VALUE ''''.</b>
    data : v_field(12) type c.
    data : begin of itab occurs 0,
           fld1(12) type c,
           end of itab.
    start-of-selection.
    v_field = '0000012345'.
    CONCATENATE V_CHAR  V_FIELD  INTO V_FIELD.
    itab-fld1 = v_field.
    append itab.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE                  = ' '
      CODEPAGE                      = ' '
        FILENAME                      =
        'C:\Documents and Settings\smaramreddy\Desktop\fff.xls'
       FILETYPE                      = 'ASC'
      MODE                          = ' '
      WK1_N_FORMAT                  = ' '
      WK1_N_SIZE                    = ' '
      WK1_T_FORMAT                  = ' '
      WK1_T_SIZE                    = ' '
      COL_SELECT                    = ' '
      COL_SELECTMASK                = ' '
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      TABLES
        DATA_TAB                      = itab
      FIELDNAMES                    =
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_WRITE_ERROR              = 2
       INVALID_FILESIZE              = 3
       INVALID_TYPE                  = 4
       NO_BATCH                      = 5
       UNKNOWN_ERROR                 = 6
       INVALID_TABLE_WIDTH           = 7
       GUI_REFUSE_FILETRANSFER       = 8
       CUSTOMER_ERROR                = 9
       OTHERS                        = 10
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    I have used one field here ,i am not sure for many fields in internal table.
    Thanks
    Seshu

  • ALV -Excel download -header & data comming in Different columns

    Hi,
    I have an ALV report with FM.When I download it to excel through LIST/EXPORT/LOCALFILE some columns are getting messed up (ex: header is in one column and data is comming in different column).
    When i do with LIST/EXPORT/SPREADSHEET option it is working fine.
    but users want to use the first option only.
    I am use FM's in this report.
    Regards
    Praveen

    Hi
    What is the statement you used to dowload data .Check the field catalog that u are passing to downloaad function module.
    or check in the debuging mode..
    change these options in excel sheet and checkout if it can help u
    1. Go to Tools -> Macro -> Security in Excel
    2. Select the ‘Trusted Sources’ tab and ensure that the checkbox titled ‘Trust access to Visual Basic Project’ is ticked.
    3. With the feature switched on, the data is passed to Excel.
    check this sample one
    TABLES : MAST , "Material to BOM Link
    STKO , "BOM Header
    MARA . "General Material Data
    * Types Begin with TY_ *
    TYPES : BEGIN OF TY_MASTER ,
    MATNR TYPE MAST-MATNR , "Material Number
    WERKS TYPE MAST-WERKS , "Plant
    STLAN TYPE MAST-STLAN , "BOM Usage
    STLNR TYPE MAST-STLNR , "Bill of material
    STLAL TYPE MAST-STLAL , "Alternative BOM
    ANDAT TYPE MAST-ANDAT , "Date record created on
    AEDAT TYPE MAST-AEDAT , "Date of Last Change
    AENAM TYPE MAST-AENAM , "Name of Person Who Changed Object
    STLST TYPE STKO-STLST , "BOM status
    ZPLP1 TYPE MBEW-ZPLP1 , "Future Planned Price 1
    DWERK TYPE MVKE-DWERK , "Delivering Plant (Own or External)
    END OF TY_MASTER .
    TYPES : MY_TYPE(20) TYPE C.
    * Constants Begin with C_ *
    * Internal tables Begin with IT_ *
    DATA : IT_MASTER TYPE STANDARD TABLE OF TY_MASTER,
    WA_MASTER TYPE TY_MASTER .
    DATA : IT_HEADER TYPE TABLE OF MY_TYPE.
    * Data Begin with W_ *
    DATA : W_PTH TYPE RLGRAP-FILENAME.
    DATA : W_FILE TYPE RLGRAP-FILENAME.
    * Field Symbols Begin with FS_ *
    * Select Options Begin with SO_ *
    * Parameter Begin with PR_ *
    * I N I T I A L I Z A T I O N *
    *--- Add Header Fields to Header Table ---
    APPEND 'Material Number' TO IT_HEADER .
    APPEND 'Plant' TO IT_HEADER .
    APPEND 'BOM Usage' TO IT_HEADER .
    APPEND 'Bill Code' TO IT_HEADER .
    APPEND 'Alternative BOM' TO IT_HEADER .
    APPEND 'Created On' TO IT_HEADER .
    APPEND 'Changed On' TO IT_HEADER .
    APPEND 'Changed By' TO IT_HEADER .
    APPEND 'BOM Status' TO IT_HEADER .
    APPEND 'Planned Price' TO IT_HEADER .
    APPEND 'Delivery Plant' TO IT_HEADER .
    IF SY-MANDT = '700'.
    W_PTH = '\lkdb01ISDISSoftware DevelopmentsDevelopmentsData FilesSAP DumpsBOM_Available'.
    ELSE.
    W_PTH = 'C:'.
    ENDIF.
    * A T S E L E C T I O N S C R E E N *
    * s t a r t o f s e l e c t i o n
    START-OF-SELECTION.
    *--- Load Data to Internal Table ---
    * SELECT MAST~MATNR MAST~WERKS MAST~STLAN MAST~STLNR MAST~STLAL MAST~ANDAT MAST~AEDAT MAST~AENAM STKO~STLST
    * INTO TABLE IT_MASTER
    * FROM MAST
    * INNER JOIN STKO ON STKO~STLNR EQ MAST~STLNR
    * AND STKO~STLAL EQ MAST~STLAL
    * INNER JOIN MARA ON MARA~MATNR EQ MAST~MATNR
    * WHERE MARA~MTART LIKE 'ZFG%'
    * AND STKO~LKENZ NE 'X'
    * AND STKO~LOEKZ NE 'X'
    * AND STKO~STLST EQ '1'.
    SELECT MAST~MATNR MAST~WERKS MAST~STLAN MAST~STLNR MAST~STLAL MAST~ANDAT MAST~AEDAT MAST~AENAM STKO~STLST MBEW~ZPLP1 MVKE~DWERK
    INTO TABLE IT_MASTER
    FROM MAST
    INNER JOIN STKO ON STKO~STLNR EQ MAST~STLNR
    AND STKO~STLAL EQ MAST~STLAL
    INNER JOIN MARA ON MARA~MATNR EQ MAST~MATNR
    INNER JOIN MBEW ON MBEW~MATNR EQ MAST~MATNR
    AND MBEW~BWKEY EQ MAST~WERKS
    INNER JOIN MVKE ON MVKE~MATNR EQ MAST~MATNR
    WHERE MARA~MTART LIKE 'ZFG%'
    AND STKO~LKENZ NE 'X'
    AND STKO~LOEKZ NE 'X'
    AND STKO~STLST EQ '1'.
    IF SY-SUBRC <> 0.
    MESSAGE I014(ZLOAD).
    ENDIF.
    *--- Set Path to Function Module ---
    CONCATENATE W_PTH SY-DATUM ' - ' 'BOM_AVAILABLE_PLANT.XLS' INTO W_FILE.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
    FILENAME = W_FILE
    FILETYPE = 'DAT'
    TABLES
    DATA_TAB = IT_MASTER
    FIELDNAMES = IT_HEADER
    EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_WRITE_ERROR = 2
    INVALID_FILESIZE = 3
    INVALID_TYPE = 4
    NO_BATCH = 5
    UNKNOWN_ERROR = 6
    INVALID_TABLE_EIDTH = 7
    GUI_REFUSE_FILETRANSFER = 8
    CUSTOMER_ERROR = 9
    OTHERS = 10.
    IF SY-SUBRC = 0.
    SUBMIT ZI005_MARA_DUMP_SOLIDEAL_N.
    MESSAGE I023(ZLOAD) WITH text-001.
    ELSE.
    MESSAGE I022(ZLOAD) WITH W_FILE. "Errors while downloading.
    ENDIF.
    END-OF-SELECTION.
    SUBMIT ZI005_MARA_DUMP_SOLIDEAL_N.
    Reward all helpfull answers
    Regards
    Pavan
    Message was edited by:
            Pavan praveen

  • Downloading HTML data as excel spreadsheets

    I am encountering an issue where tabular HTML data needs to be downloaded onto a user's desktop in MS Excel format.
    Basically, the download link opens the data in a new JSP, which has the response contentType set to application/vnd.ms-excel.
    However, when the pop-up asks me to save the file it saves it as a *.jsp* file.
    Could anyone please suggest why this may be happening?

    Roman-S wrote:
    Basically, the download link opens the data in a new JSP, which has the response contentType set to application/vnd.ms-excel.Terrible approach. But OK, that's another story, I am not in a mood to explain it all again. Google and you'll find.
    However, when the pop-up asks me to save the file it saves it as a *.jsp* file.You forgot the filename in the content disposition header and/or you're using Microsoft Internet Explorer.
    Could anyone please suggest why this may be happening?Add the filename to the content disposition header and/or use a decent webbrowser or append the filename as last part of the request URL path.

  • Download Table Data into Excel with Less Size

    Hi All,
    In OBIEE 11.1.1.5, following are my finding of the File Sizes using Various Export Options.
    I have used Default SampleAppLite RPD and Webcat , Order Details Report
    No.of Records : 2000
    Export Excel 2003+ (mht) : 3,812 KB
    Export Power Point 2003+ : 8,901 KB
    Export Power Point 2007 : 478 KB
    Export Data CSV : 205 KB
    Export Data Tab Delimited : 409 KB
    When the viewscontrolmessages.xml is modified to from "Format=mht" to "Format=excel" for the Download to Excel option,
    the filw size was reduced to
    Export Excel (xls) : 2,748 KB
    By observing the drastic reduction of file size in the Export to Power Point options between Version 2003 and 2007.
    we are expecting that a Version Change in Excel might also reduce the Download Size to around 700 KB
    But somehow we are not able to achieve this.
    So please Suggest
    Note: CSV is not an Option, as we loose all Formatting like Grand and Sub Totals and other data level formatting.

    Hi All,
    In OBIEE 11.1.1.5, following are my finding of the File Sizes using Various Export Options.
    I have used Default SampleAppLite RPD and Webcat , Order Details Report
    No.of Records : 2000
    Export Excel 2003+ (mht) : 3,812 KB
    Export Power Point 2003+ : 8,901 KB
    Export Power Point 2007 : 478 KB
    Export Data CSV : 205 KB
    Export Data Tab Delimited : 409 KB
    When the viewscontrolmessages.xml is modified to from "Format=mht" to "Format=excel" for the Download to Excel option,
    the filw size was reduced to
    Export Excel (xls) : 2,748 KB
    By observing the drastic reduction of file size in the Export to Power Point options between Version 2003 and 2007.
    we are expecting that a Version Change in Excel might also reduce the Download Size to around 700 KB
    But somehow we are not able to achieve this.
    So please Suggest
    Note: CSV is not an Option, as we loose all Formatting like Grand and Sub Totals and other data level formatting.

  • Settings for download of data to excel file.

    Hi
    I am trying to download the report from the classical drill down report to excel file. But it not coming in appropriate format. The whole data is coming in a single row. Is there any settings that i have to do in order to download the file in apporpriate format.
    Earlier it was coming in proper format of rows and columns, but now the data is coming in only single row.
    Please help or tell me is there any settings that i have to check.
    The same i have check for FBL3N also and for S_ALR_87012277
    Regards
    IPS Narang
    Edited by: IPS Narang on Jan 29, 2009 7:59 PM

    Hello,
    Please note that your GL short text is not expected to have a "," (COMMA) or unallowable symbol.
    If that is there in any on of the GL Account description, from that row, the whole report will come into a single cell.
    Therefore, please check the report, is there any unallowable symbols in the description and correct your master records of GL.
    It will solve your issue.
    Regards,
    Ravi

Maybe you are looking for