cancel
Showing results for 
Search instead for 
Did you mean: 

.xlsx file upload in abap webdynpro

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.