on 05-07-2012 1:28 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please refer below links for .xlsx upload/download.
http://scn.sap.com/docs/DOC-45719
http://scn.sap.com/docs/DOC-46001
Award points if useful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In the exporting parameters u have to use l_xstring as type string not xstring.
Regards,
Vineesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Rashmita,
here is the sample code plz try this
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=>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.
ENDLOOP.
lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
lo_nd_sflight->bind_table( t_table1 ).
thanks & regards,
Meenachi.R
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Rashmita,
Refer following link,It may help to resolve your issue.
http://www.saptechnical.com/Tutorials/WebDynproABAP/Upload/Page1.htm
Katrice
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Venkatesh,
Every web dynpro application has its own understandable excel format, which is specific to it only.
Now when ever you are uploading any excel , if the format not matches with the format of the web dynpro application , it will show you dump values in the output .
You can very well overcome this issue by allowing the user first download a blank template from the application its self and then ask him to fill it and upload back to application.
This way you can make sure that the both the formats will remain always same in any case irrespective of the system
For more details and explanation on this you can refer the below document.
"Rectifying the garbage value problem, while uploading excel in web Dynpro application "
Link :
http://scn.sap.com/thread/3314346
Hope this will resolve the issue.
Thanks,
Gejo john
The Problem is with the i_data.
it should be of
data : i_data LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rashmita Parida ,
Please save as the xlsx file to Text(Tab Delimited) *.txt format ,then upload it willsurly work.
Regards,
Ragupathi.T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rashmita,
the reason for this error is a type conflict in the function module interface (passed parameters don't have the same type as declared in the function module).
But: you cannot use this function module in Webdynpro environment because it uses GUI_UPLOAD but Webdynpro applications don't have a SAPGUI connection.
Please search in the documentation (or here in the forum) how to upload files in WDA.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your valuable answer.
But my requirement is ito uplode the excel file which is in .xlsx format. Because my flat file contains the Customer details which is a excel file. So how I can upload it.If I use the function module 'HR_KR_XSTRING_TO_STRING' then whn I will browse the file it wiil be selected. But when I uplode it, it will display junk data like
How to solve this issue. Kindly help me to solve this probe. I have no much knowledge in this platform because recently I have joined. Which function module I will be use so that my flat file will be uploded.
Regards/Rashmita
Hi Rashmita Parida,
In webdynpro application it is not supported to upload excel file.... So pls convert into tabed flat file and upload it...
it will work.
Regards,
Venkat
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.