cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload/Download buttons in Table UI

Former Member
0 Kudos

Dear Experts,

I want to give file upload and download buttons in the columns of the Table UI element. I'm not able to achieve upload file with browse functionality on the click and Download file with ws_execute functionality.

If anybody can throw some light, it would be of great help.

I'm sort of a intermediate level developer in WD for ABAP.

Regds,

Aryan.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member628395
Active Participant
0 Kudos

Hi guys,

I am using the same code , but it is downloading only one line.

here is the code:

DATA: lv_node TYPE REF TO if_wd_context_node,

lead_selection_index TYPE i,

ITAB TYPE TABLE OF ZGOODSRECEIPT,

WA1 LIKE LINE OF ITAB,

STRING1 TYPE STRING,

string3 type TABLE OF string ,

STRING2 TYPE XSTRING,

QUANTITY TYPE STRING.

lv_node = wd_context->get_child_node( name = 'ZGOODS_RECEIPT' ).

CALL METHOD lv_node->get_static_attributes_table

IMPORTING

table = ITAB.

LOOP AT ITAB INTO WA1.

MOVE WA1-MENGE TO QUANTITY.

CONCATENATE WA1-EBELN WA1-BEDAT WA1-MBLNR WA1-BUDAT WA1-GJAHR WA1-WERKS WA1-DELNOTE QUANTITY

WA1-MEINS WA1-MATNR WA1-MAKTX WA1-LGORT

cl_abap_char_utilities=>newline INTO STRING1

SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

ENDLOOP.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = string1

IMPORTING

buffer = string2.

WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(

I_FILENAME = 'Excel.xls'

I_CONTENT = STRING2

I_MIME_TYPE = 'EXCEL' ).

Former Member
0 Kudos

Hi Sagar,

In your case, Please check the cardinality of the node. it should be either 1..n or 0..n

Also please check the check box for Initialise Leadselection set for your node.

If the cardindality is 1..1 or 0..1, then the only node selected, gets into the Excel sheet.

Please check and confirm.

Good day!

Thank you,

Regards.

Shashikanth. D

uday_gubbala2
Active Contributor
0 Kudos

Hi Aryan,

In order to get the download functionality. Create an button in the Table toolbar and put the below coding into it. You need to basically do the following tasks:

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 delimited format.

4) Convert this STRING format to XSTRING format

5) Make use of the attach_file_to_response method.

Regards,

Uday

You can also go through this [link|http://saptechnical.com/Tutorials/WebDynproABAP/Export/toexcel.htm] for a similar example.

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=>newline INTO mara_string
                                        SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
  ENDLOOP.
 
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text   = mara_string
    IMPORTING
      buffer = mara_xstring.
 
 
  wdr_task=>client_window->client->attach_file_to_response(  i_filename  = 'TEMP.DOC'
                                                             i_content   = mara_xstring
                                                             i_mime_type = 'WORD' ).
ENDMETHOD.

The above is the code to export the Internal Table to Word Document. You can proceed as shown below for Excel & NOTEPAD formats.

To Export the Internal Table to Text File:

WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(
    I_FILENAME    = 'WDP.txt'
    I_CONTENT     =  mara_xstring
    I_MIME_TYPE   = 'NOTEPAD' ).

To Export the Internal Table to Excel File:

WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(
    I_FILENAME    = 'Excel.xls'
    I_CONTENT     =  mara_xstring
    I_MIME_TYPE   = 'EXCEL' ).