cancel
Showing results for 
Search instead for 
Did you mean: 

upload excel file to internal table in web dynpro program

Former Member
0 Kudos

Hi friend's

In web dynpro program how to upload excel file into internal table and finally data will be save Y table.

Accepted Solutions (0)

Answers (4)

Answers (4)

KiranJ
Active Participant
0 Kudos

Hai,

when u are uploading the file u change the file type as XLS to .CSV .

and follow the sample code...

create the attribute as xstring type.

DATA : s_table TYPE string_table,

s_string TYPE string.

IF lv_data IS NOT INITIAL .

CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'

EXPORTING

im_xstring = lv_data

IMPORTING

ex_string = out_string.

SPLIT out_string AT cl_abap_char_utilities=>cr_lf INTO TABLE s_table.

LOOP AT s_table INTO s_string.

SPLIT s_string AT cl_abap_char_utilities=>horizontal_tab INTO v_po_no

ls_s0_f1

ls_s0_f2

ls_s0_f3

ls_s0_f4

ls_s0_f5

ls_s0_f6

.

APPEND ls_data TO lt_data.

Former Member
0 Kudos

Please check the below thread

[]

The input file to this has to a .CSV document and not .XLS.

rameshkumar_ramasamy2
Participant
0 Kudos

hi,

See the properties of File Upload UI element..

Link: [http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/732f0510d83ff6e10000000a42189c/frameset.htm]

Goto References -> User Interface Elements -> Integration Category -> File upload..

After creating the 'FILE UPLOAD' element in a view.. Bind a datasource(a context attribute with STRING) with the data property..

Double click on ONACTION_UPLOAD method. Write a code as given below.


METHOD onactionon_upload . 
 TYPES :   BEGIN OF str_itab,
       name(10) TYPE c,
       age(10) TYPE c,
       END OF str_itab.  DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
         i_data TYPE STANDARD TABLE OF string,
         l_string TYPE string,
         fs_table TYPE str_itab,
         l_xstring TYPE xstring,
         fields TYPE string_table,
         lv_field TYPE string. 
 DATA : t_table TYPE if_main=>elements_data_tab,
         data_table TYPE if_main=>elements_data_tab.
* get single attribute  
wd_context->get_attribute(   
 EXPORTING     
 name =  `DATASOURCE`   
 IMPORTING     
 value = l_xstring ).
  CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
    EXPORTING
      in_xstring = l_xstring
    IMPORTING
      out_string = l_string.  
SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
* Bind With table Element. 
 LOOP AT i_data INTO l_string.
    SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields. 
   READ TABLE fields INTO lv_field INDEX 1.
    fs_table-name = lv_field.   
 READ TABLE fields INTO lv_field INDEX 2.
    fs_table-age = lv_field.    
APPEND fs_table TO t_table1.     "Append to  the internal  table
  ENDLOOP.

Edited by: Rameshkumar Raamasamy on Feb 9, 2010 9:39 AM

Former Member
0 Kudos

Hi,

Found this helpful link [http://www.scribd.com/doc/13290757/Uploading-Excel-Files-Using-WebDynpro-for-ABAP|http://www.scribd.com/doc/13290757/Uploading-Excel-Files-Using-WebDynpro-for-ABAP]

Try following the way mentioned there, i'll also try creating a sample app.

Regards

Manas Dua

Former Member
0 Kudos

Hi,

I tried creating a sample app for the same with above mentioned code snippet ( same is in my link as well ) but the problem lies in with conversion of data from .XLS format to String format

For more information - follow thomas reply in this thread -

Regards

Manas Dua