Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

OO ALV Output in Excel Incorrect

Former Member
0 Kudos
588

Hi experts,

I have developed a report showing data in OO ALV grid. The Output is correct with all columns and rows intact but when I try to download this to an excel file using the standard Download functionality and clicking on Local File-> Spreadsheet....i get an excel sheet created but with all columns in the correct order whereas the rows displayed are missing and only one last column's values are copied to a single row.

I have used the following code:

TYPES: BEGIN OF ty_outtab_main,
       kunnr TYPE vbak-kunnr,  "Customer number
       name1 TYPE adrc-name1,  "Customer Name
       country TYPE adrc-country, " Customer Country
       vbeln TYPE vbak-vbeln, " Contract Number
       gueen TYPE vbak-guebg, "Contract Expiry date
       matnr TYPE vbap-matnr, " Material Number
       arktx TYPE vbap-arktx, " Material Description
       zmeng TYPE vbap-zmeng, " Contract Quantity
       zieme TYPE vbap-zieme, " Unit of Measure
       vbelv TYPE vbfa-vbeln, " Sales Order Number
       rfmng_flo TYPE vbfa-rfmng,  " Sales Order Quantity
       vrkme TYPE vbfa-vrkme, " Unit of Measure
       gbsta_bez TYPE vbstt-gbsta_bez, "Sales order status
END OF ty_outtab_main.

DATA: gt_outtab_main TYPE TABLE OF ty_outtab_main.
DATA: lt_fcat             TYPE lvc_t_fcat.


 CALL METHOD gr_grid_d0100->set_table_for_first_display
*      EXPORTING
*    i_buffer_active               =
*    i_bypassing_buffer            =
*    i_consistency_check           =
*        i_structure_name              =  lv_structure_name
*    is_variant                    =
*    i_save                        =
*    i_default                     = 'X'
*    is_layout                     =
*    is_print                      =
*    it_special_groups             =
*    it_toolbar_excluding          =
*    it_hyperlink                  =
*    it_alv_graphics               =
*    it_except_qinfo               =
*    ir_salv_adapter               =
      CHANGING
        it_outtab                     =  gt_outtab_main
        it_fieldcatalog               =  lt_fcat
*    it_sort                       =
*    it_filter                     =
*  EXCEPTIONS
*    invalid_parameter_combination = 1
*    program_error                 = 2
*    too_many_lines                = 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.

I have populated lt_fcat in the traditional manner.

Does it have anything to do with QUAN field in the data?

Your help will be appreciated.

Regards,

Garima.

Edited by: Thomas Zloch on Oct 19, 2010 10:47 AM - please use code tags

1 ACCEPTED SOLUTION

Former Member
109

Hi

I think the problem is with your fieldcatlog

define your fieldcatlog like this:

WA_FCAT-TABNAME = '<TABLE NAME>'. " INT. TABLE NAME.

WA_FCAT-COL_POS = '1'. " COLUMN POSITION.

WA_FCAT-FIELDNAME = '<FIELD NAME>'. " FIELD NAME.

WA_FCAT-REPTEXT = <COLUMN HEADING>. " COLUMN HEADING.

APPEND WA_FCAT TO I_FCAT.

Define the table name for every field in your fieldcatlog, means if you have 6 fields in your fieldcatlog table then mention the table name for every field (all the 6 fields).

I hope this way you will get the correct out put in your excel file when you will transfer the data via ALV.

Thanks

Lalit Gupta

1 REPLY 1

Former Member
110

Hi

I think the problem is with your fieldcatlog

define your fieldcatlog like this:

WA_FCAT-TABNAME = '<TABLE NAME>'. " INT. TABLE NAME.

WA_FCAT-COL_POS = '1'. " COLUMN POSITION.

WA_FCAT-FIELDNAME = '<FIELD NAME>'. " FIELD NAME.

WA_FCAT-REPTEXT = <COLUMN HEADING>. " COLUMN HEADING.

APPEND WA_FCAT TO I_FCAT.

Define the table name for every field in your fieldcatlog, means if you have 6 fields in your fieldcatlog table then mention the table name for every field (all the 6 fields).

I hope this way you will get the correct out put in your excel file when you will transfer the data via ALV.

Thanks

Lalit Gupta