cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

uploading a excel file using abap webdynpro

Former Member
0 Kudos
927

Dear exports

I want to upload a excel file and display the data in broswer using abap webdynpro. My excel file format is .XLSX . But I am not able to upload it because when I browse the file and click on upload button an error raised. And I am a fresher in this platform so I have no much knowledge to solave this error. Can anyone kindly help me to solve the error.

I have create the application by using the following steps.

1. I have create a webdynpro component using SE80.

2. Withen the context tab of view I have create 1 node with 2 attribute(name, age) and another attribute(datasource)

3. withen the layout tanb of the view i have create 3 UI Elements like

4. Withen the method "ONACTION_UPLOAD" I have put the following codes.

   TYPES : BEGIN OF str,
          name(10) TYPE c,
          age(10) TYPE c,
          END OF str.

DATA : t_table1 TYPE STANDARD TABLE OF str,
         i_data TYPE STANDARD TABLE OF string,
         lo_nd_data TYPE REF TO if_wd_context_node,
         lo_el_data TYPE REF TO if_wd_context_element,
         l_string TYPE string,
         fs_table TYPE str,
         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.

wd_context->get_attribute(
    EXPORTING
      name `DATASOURCE`
    IMPORTING
      value = l_xstring ).

   CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    FILENAME                      = l_xstring
    I_BEGIN_COL                   = 1
    I_BEGIN_ROW                   = 2
    I_END_COL                     = 2
    I_END_ROW                     = 10
  TABLES
    INTERN                        = i_data
* EXCEPTIONS
*   INCONSISTENT_PARAMETERS       = 1
*   UPLOAD_OLE                    = 2
*   OTHERS                        = 3
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

    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.
  ENDLOOP.

lo_nd_data = wd_context->get_child_node( 'DATA_TAB' ).
lo_nd_data->bind_table( t_table1 ).

5. Now I have Save and acivate the component

6. When I have run the application by uploading the excel file  an error raised.

and the erroe screenshot is

Can anyone please help me to solve this problem. If i am not able to solve it then I can't uplode excel file which contains customer master data of my organisation.

So Please help me to solve my issue.

Thanks and regards

Rashmita Parida 

View Entire Topic
0 Kudos

You can try:

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,

         lo_nd_sflight TYPE REF TO if_wd_context_node,

         lo_el_sflight TYPE REF TO if_wd_context_element,

         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=>element_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 THE 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.

   ENDLOOP.

   lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ) .

   lo_nd_sflight->bind_table( t_table1 ) .

ENDMETHOD.

UweFetzer_se38
Active Contributor
0 Kudos

Just out of plain curiosity:

  • why you are answering to a two year old question, where the original poster is not really interested in an answer?
  • why you are copy/pasting a one year old answer without additional information?
0 Kudos

I am very new to SCN SAP. I could not understand. I shall be familiar with the site very soon. And I am not copying and pasting other's answers. Thank you.

UweFetzer_se38
Active Contributor
0 Kudos

A warm "Welcome"

(your answer looked exactly like )

0 Kudos

Thank you..