cancel
Showing results for 
Search instead for 
Did you mean: 

Problem: Excel Export from Webdynpro

Former Member
0 Kudos

Hi Experts,

I am facing problem in excel export functionality of webdynpro abap.

On button click to export table content, browser starts downloading a file but all of sudden pop-up gets vanished without further prompt.

Same functionality is working for some users system but for others it is not working..

All users have IE 7.0 or above version with no pop-up blocked as well as file download is enabled in security for all the systems.

Any suggestion on this?

Thanks

Depesh

Accepted Solutions (0)

Answers (5)

Answers (5)

0 Kudos

method ONACTIONEXPORT_TO_EXCEL .

   DATA lo_nd_vbap TYPE REF TO if_wd_context_node.

   DATA lo_el_vbap TYPE REF TO if_wd_context_element.

   DATA lt_vbap TYPE table of vbap.

   DATA ls_vbap TYPE vbap.

   DATA text   TYPE string.

   DATA xtext  TYPE xstring.

* navigate from <CONTEXT> to <SFLIGHT> via lead selection

   lo_nd_vbap = wd_context->get_child_node( name = 'VBAP' ).

* get all declared attributes

   lo_nd_vbap->get_static_attributes_table(

     IMPORTING

       table = lt_vbap ).

   LOOP AT lt_vbap INTO ls_vbap.

     CONCATENATE text ls_vbap-MATNR

LS_VBAP-VBELN

ls_vbap-POSNR

ls_vbap-matnr

ls_vbap-matwa

ls_vbap-charg

ls_vbap-matkl

ls_vbap-meins

cl_abap_char_utilities=>newline INTO text SEPARATED BY

cl_abap_char_utilities=>horizontal_tab.

   ENDLOOP.

   CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

     EXPORTING

       text   = text

     IMPORTING

       buffer = xtext.

   wdr_task=>client_window->client->attach_file_to_response(

**path to the Excel file

i_filename = 'VBAP.xlsx'

* String Variable

i_content =  xtext

* File Type

i_mime_type = 'EXCEL' ).

endmethod.

Former Member
0 Kudos

Thanks

Former Member
0 Kudos

Hi Depesh,

I am facing a similar issue in Export to Excel functionality in Webfynpro for Java.

But as you said, some users are able to download the excel while for some the pop up opens and closes itself without giving an excel file.

Could you find any browser settings which allow the excel download??

Please help if you could get the solution.

Regards,

Juhi

Former Member
0 Kudos

Do the following settings in IE

NOTE :Please ensure to change the local settings in your Internet Explorer as mentioned below before trying to download the excel file

~~> Enable Automatic prompting for file download through IE -> Tools -> Internet options -> Security -> Custom Level -> Automatic prompting for file download

~~> Turn ON the pop-up blocker through IE -> Tools -> Internet options -> Privacy -> Turn on Pop-up blocker

I did this after a long struggle. Its working fine for me.

Regards

Virkly

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Is it the export button of alv table or the normal button which you have created for export is the problem.

Priya

Former Member
0 Kudos

Hi All,

It is a custon buton that I have created on a view.

Coding is perfect as there is no error because I am able to download a file if I use some other guys system.

The problem in downloading happening for few of the users and rest others can download it very well.

While executing at my system, Browser opens up a downloading pop-up and all of sudden tht pop-up goes away with no response further.

Is it some setting issue in IE?

Thanks

Depesh

anand_nidamanuru
Active Participant
0 Kudos

Hi Depesh,

The option "Close when download finishes" might have been set for IE. You can use the advanced properties of IE to uncheck this option.

Please check if it has downloaded to the path you have given.

Thanks,

Anand

Former Member
0 Kudos

Hi Anand,

I did not fiind option saying "Close when download finishes".

Could you tell the path... is it there in security custom level or Intenet option->advanced as I have checked both the places but no such option?????

Thanks

Depesh

anand_nidamanuru
Active Participant
0 Kudos

Hi Depesh,

Try using Tools > Internet Options > Advanced Tab> under settings> Browsing, Option "Notify when downloads complete"

"close when download finishes", comes only while IE is downloading something, in that small popup where it shows the progress of download.

Thanks,

Anand

Edited by: Anand Nidamanuru on Nov 26, 2009 11:32 AM

Former Member
0 Kudos

Hi Anand,

Yeah I have set that option too but no result. Even I have checked to location where it is supposed to be downloaded.

In fact, What I need is on click of button, the excel file containing table content should get open automatically and rest of on the user to save or it just close it.

I read in one of the forum that IE6 had an issue that it downloads a file and delete automatically itself without prompting user action but mentioned that IE 7 and above has no such issue.

Any other suggestion?

Thanks

Depesh

Former Member
0 Kudos

hi Depesh ,

hru exporting the internal table contents :

1 First read the table's data into an internal table.

2 Convert the internal table data to STRING format.

3 Now convert it into tab separated format as how desired.

4 Convert this STRING format to XSTRING format using SCMS_STRING_TO_XSTRING

5 Make use of the attach_file_to_response method.

refer the related thread for radhika's reply :


METHOD onactionon_submit .
  DATA: lv_node TYPE REF TO if_wd_context_node,
        lt_mara TYPE if_main=>elements_mara,
        wa_mara TYPE if_main=>element_mara,
        lead_selection_index TYPE i,
 
        mara_string  TYPE string,
        mara_xstring TYPE xstring.
 
  lv_node = wd_context->get_child_node( name = 'MARA' ).
  CALL METHOD lv_node->get_static_attributes_table
    IMPORTING
      table = lt_mara.
 
  LOOP AT lt_mara INTO wa_mara.
    CONCATENATE mara_string
                wa_mara-matnr
                wa_mara-ersda
                wa_mara-ernam
                wa_mara-matkl
                wa_mara-meins
                cl_abap_char_utilities=>cr_lf INTO mara_string
                                        SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
  ENDLOOP.
 
** Now you need to add the column headers & the desired extra information through coding to 
** mara_string
 
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text   = mara_string
    IMPORTING
      buffer = mara_xstring.
 
 
  CL_WD_RUNTIME_SERVICES=>attach_file_to_response(  i_filename  = 'TEMP.XLS'
                                                    i_content   = mara_xstring
                                                    i_mime_type = 'EXCEL' ).
ENDMETHOD.

It works fine

rgds,

amit

Former Member
0 Kudos

Hello,

Thank you for this post. I would like to know if this code can be modified to export the data in to .xlsx format and also if it can be formatted to have the column headers and proper date formats.

I read in some posts that xml tags will have to be added to the code but I don't know how to go about this as I'm new to coding in ABAP.

Is there any way you can help?

Former Member
0 Kudos

Can you check if your file is getting downloaded to the location where you are saving it?