cancel
Showing results for 
Search instead for 
Did you mean: 

Export / Import on internal tables in Webdynpro

Former Member
0 Kudos

Hello All,

I have requirement where i have to export the internal table onto presentation server ( excel or xml etc) in webdynpro when a button is clicked or using Filedownload UI element. I have to import the same into the internal table when File upload is used or button is clicked.

Your help will be appreciated and points awarded.

Thanks in Advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi prasad.....

you can upload a .csv file into an internal table and tehn to a table in web dynpro using the file upload ui element.



      begin of wa,                                   " structure of the node/file
         mandt type mandt,
         matnr type matnr,
        end of wa,
       itab like table of wa,
       rows         type standard table of string ,   " will hold the entire contents
       wa_rows(300) type c .
  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
DATA lv_contents LIKE ls_context-contents.
* get element via lead selection
lo_el_context = wd_context->get_element(  ).
* get single attribute
  lo_el_context->get_attribute(
    EXPORTING
      name =  `CONTENTS`
    IMPORTING
      value = lv_contents ).
DATA : loc_conv   TYPE REF TO cl_abap_conv_in_ce,
       var_string TYPE string,                      " holds the string value of the file       
       inst       type ref to CL_SWF_UTL_CONVERT_XSTRING,
       inst1      type ref to cl_abap_conv_in_ce.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
 input = lv_contents
 encoding = 'UTF-8'
 replacement = '?'
 ignore_cerr = abap_true
RECEIVING
 conv = loc_conv.
CALL METHOD loc_conv->read
IMPORTING
data = var_string.
SPLIT var_string AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE ROWS.
LOOP AT ROWS INTO WA_ROWS .
 split wa_rows at ',' into wa-mandt wa-matnr.
 append wa to itab.
ENDLOOP.
  DATA lo_nd_table TYPE REF TO if_wd_context_node.
  DATA lo_el_table TYPE REF TO if_wd_context_element.
  DATA ls_table TYPE wd_this->element_table.
* navigate from <CONTEXT> to <TABLE> via lead selection
  lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
* get element via lead selection
  lo_el_table = lo_nd_table->get_element(  ).
   lo_nd_table->bind_table( itab ).

for downloading you can use file download ui element.

---regards,

alex b justin

Former Member
0 Kudos

Hi Alex,

Thanks a lot for the code.

Could you please let me know can we import deep strucuture and also export deep structure ?

Also can u send me code for both.

Thanks in Advance.