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: 

ALV to Excel Download when using cl_salv_table=>factory

Former Member
0 Kudos

Hi Experts,

I have a issue when downloading the ALV output to an Excel file, where it is getting moved to next line, have seen many discussions but it did not help me. Can any one help me out in this please?

Regards,

Siva

7 REPLIES 7

Former Member
0 Kudos

Hi Siva

Please try the below code

PARAMETERS : vbeln TYPE vbak-vbeln.
  types : begin of struct,
    vbak type  vbak,
    vbap type  vbap,
    end of struct.

    data : itab type TABLE OF struct,
          wa type struct.

    data obj TYPE REF TO cl_Salv_table.
    data REF_FUNC TYPE REF TO CL_SALV_FUNCTIONS.

    select * from vbak into CORRESPONDING FIELDS OF TABLE itab where vbeln = vbeln.

      try.
        call method cl_salv_table=>factory
*       *  exporting
*         *   list_display   = IF_SALV_C_BOOL_SAP=>FALSE
*         *    r_container    =
*         *    container_name =
          importing
            r_salv_table   = obj
          changing
            t_table        = itab     .
       catch cx_salv_msg .
       endtry.

       REF_FUNC = obj->GET_FUNCTIONS( ).
       REF_FUNC->SET_ALL( ABAP_TRUE ).

       obj->display( ).

Regards,

Suganya

0 Kudos

Hi Suganya,
Still it is not working.

Former Member
0 Kudos

hi,

     try this samlple code.

     4. Enable the global settings

*   4.1 Get the ALV Function object
     LR_FUNCTIONS = CH_ALV->GET_FUNCTIONS( ).

*   4.2. Set all the standard ALV Functions
*    LR_FUNCTIONS->SET_DEFAULT( ).
     LR_FUNCTIONS->SET_ALL( ABAP_TRUE ).
     LR_DISPLAY = CH_ALV->GET_DISPLAY_SETTINGS( ).

*   4.3. Set the stripped ALV Pattern
     LR_DISPLAY->SET_STRIPED_PATTERN( ABAP_TRUE ).

     After in inserting this code , the icon will appear on the application tool bar.

     Reward points if answer is helpful.

     Regards,

     PRABHAKARAN

Moderator message - Please read the forum Rules of Engagement (RoE) before posting

Message was edited by: Suhas Saha

0 Kudos

Hi Prabhakaran,

I have the Icon already, the issue is when downloading to Excel sheet the Comments field is displayed in many lines where in ALV it is in single line for a record

0 Kudos

Hi Siva,

I know that this is an old issue, but it may help others. The same was happening to me when the content of my cell contained the character ".

Try replacing the character " with space in the cell content and see what happens.

Best regards.

Former Member
0 Kudos

Hi try this code

PARAMETERS : vbeln TYPE vbak-vbeln.

types : begin of struct,

  vbak type  vbak,

  vbap type  vbap,

  end of struct.

data : itab type TABLE OF struct,

       wa type struct.

data obj TYPE REF TO cl_Salv_table.

data REF_FUNC TYPE REF TO CL_SALV_FUNCTIONS.

select * from vbak into CORRESPONDING FIELDS OF TABLE itab where vbeln = vbeln.

try.

call method cl_salv_table=>factory

*  exporting

*    list_display   = IF_SALV_C_BOOL_SAP=>FALSE

*    r_container    =

*    container_name =

  importing

    r_salv_table   = obj

  changing

    t_table        = itab

    .

catch cx_salv_msg .

endtry.

REF_FUNC = obj->GET_FUNCTIONS( ).

REF_FUNC->SET_ALL( ABAP_TRUE ).

obj->display( ).

Former Member
0 Kudos

Dear Siva,
Yes, while working with CL_SALV_TABLE, the program fails to find the correct template.

In such situation, you can follow below work around.
First click on Print preview:

In the next screen, you shall be able to use spreadsheet option to get the desired result.

Certainly it can also be achieved by additional code in even handling.

BR
Satish

-------------