Skip to Content
author's profile photo Former Member
Former Member

.xlsx file upload in abap webdynpro

Dear exports

Previously I have put the same blog and I got some answer but I have not solve my problem using those blog. So again i am putting the same blog with another dump which I am facing now.

THis is the code for method upload button:

method ONACTIONON_UPLOAD .

TYPES : BEGIN OF str,
Name(10) TYPE c,
Age(10) TYPE c,
END OF str.

DATA : t_table1 TYPE STANDARD TABLE OF str,

fs_table TYPE str,

i_data TYPE STANDARD TABLE OF ALSMEX_TABLINE,

l_string TYPE string,
lo_nd_data TYPE REF TO if_wd_context_node,
lo_el_data TYPE REF TO if_wd_context_element,
l_xstring TYPE xstring,

fields TYPE string_table,

lv_field TYPE string.

data: l_data TYPE RLGRAP-FILENAME.

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_data ).

**** CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'******** EXPORTING***** FROM_CODEPAGE = '8500'**** IN_XSTRING = l_xstring********* OUT_LEN =**** IMPORTING**** OUT_STRING = l_string.
**CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = l_data
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = 2
I_END_ROW = 6
TABLES
INTERN = i_dataEXCEPTIONS
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.

*cl_abap_char_utilities is a class interface which is used for character processing.
* SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.
* Bind With table Element.
LOOP AT i_data INTO l_string." loop between the tntrnal tab and wa of flat file
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 ).
endmethod.

And when I test the application a dump arises and that is

Why this error comes. Here .xlsx file contains only 2 columns with column name is Name and Age with 6 rows. I am not able to solve the dump..

Kindly anyone can help me to solve this dump please. It is a orgent one. Please help me.

Regards

Rashmita

a23.png (23.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 11, 2012 at 03:35 AM

    Hi,

    I dont think we can use the FM you have used to upload excel data.

    http://wiki.sdn.sap.com/wiki/display/WDABAP/Excel+File+Upload+And+Display+Data+Using+Web+DynPro+ABAP

    Use this link.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2013 at 06:42 PM

    Hello Rashmita,

    You can use cl_fdt_xl_spreadsheet standard class for .xlsx file upload. You can refer to my content for the same through the given link.

    http://scn.sap.com/docs/DOC-45719

    Please award points if useful.

    Thanks and Regards,

    Devesh Singh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 02, 2013 at 02:43 PM

    Hi ,

    The problem is related to the function module

    'ALSM_EXCEL_TO_INTERNAL_TABLE' which is giving your error.

    Instead of using in binary mode try using in text mode....

    or use this FM

    'HR_KR_XSTRING_TO_STRING'


    Thanks

    Vijay Vikram

    Message was edited by: Vijay Vikram

    Message was edited by: Vijay Vikram

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Vikram,

      Function module HR_KR_XSTRING_TO_STRING gives junk values when used for .xlsx upload.

      Please refer to my content previously posted for reference.

      Thanks and Regards,

      Devesh Singh

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.