on 07-14-2015 10:19 AM
Hi,
AM unable to read data from excel file into internal table please help me to solve this,below code.
DATA: LV_FILECONTENT TYPE XSTRING,
CONVT TYPE REF TO CL_ABAP_CONV_IN_CE,
WA_STRING TYPE STRING,
S_TABLE TYPE STRING_TABLE.
DATA S_CONTENT TYPE string.
LV_FILECONTENT = lv_datasource.
CONVT = CL_ABAP_CONV_IN_CE=>CREATE( INPUT = LV_FILECONTENT
ENCODING = '6102').
CONVT->READ( IMPORTING DATA = S_CONTENT ).
SPLIT S_CONTENT AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE S_TABLE.
**....
LOOP AT S_TABLE INTO WA_STRING.
** IF WA_STRING CO CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB OR SY-TABIX EQ 1.
** CONTINUE.
** ENDIF. "Skip the heading line
** SPLIT WA_STRING AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
** INTO L_Variabl-field1 L_variable-fiedld2.
**...
ENDLOOP.
Getting dump at
CONVT->READ( IMPORTING DATA = S_CONTENT ).
Hi,
Are you using file upload UI element. What is the format of the excel file. Generally try using .CSV format while uploading in WDA.
Regards,
Monishankar C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I suspect there is some problem with the text encoding parameter value which is different from the excel sheet you are uploading.
Please check the following link, which refers of uploading a data from excel and displaying it as a table, much similar to yours, with little changes.
Excel File Upload And Display Data Using Web DynPro ABAP - Web Dynpro ABAP - SCN Wiki
And to find the encoding value in the excel sheet check the value in excel sheet and change it accordingly in the code.
Regards,
Harsha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you please share the dump analysis, so that it will be easy to analyze the issue.
BR,
RAM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for reply, after using the above code am unable to get data so i used below code, in this code am getting data in diff format as below. Please find code and data which i get from this code.
TYPES : BEGIN OF ty_final1,
temp(10) TYPE c,
per(10) TYPE c,
stdt(10),
endt(10),
rat(3),
END OF ty_final1.
DATA lt_temp TYPE TABLE OF ty_final1.
DATA i_data TYPE STANDARD TABLE OF string.
* DATA i_data1 TYPE STANDARD TABLE OF ty_final1.
DATA it_final1 TYPE TABLE OF ty_final1.
DATA wa_final1 LIKE LINE OF it_final1.
DATA lo_nd_line_items TYPE REF TO if_wd_context_node.
DATA lo_el_line_items TYPE REF TO if_wd_context_element.
DATA ls_line_items TYPE wd_this->element_data_tab.
DATA lt_line_items LIKE STANDARD TABLE OF ls_line_items.
DATA : str TYPE string,
xstr TYPE xstring,
fields TYPE string_table,
fs_table LIKE wa_final1,
lv_field1(200) TYPE c,
lv_field2(200) TYPE c,
lv_field3(200) TYPE c,
lv_field4(200) TYPE c,
lv_count TYPE i,
lv_count1 TYPE i.
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 = xstr ).
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = xstr
IMPORTING
out_string = str.
SPLIT str AT cl_abap_char_utilities=>newline INTO TABLE i_data.
CLEAR str.
*refresh it_final1.
LOOP AT i_data INTO str.
* SPLIT str AT cl_abap_char_utilities=>newline INTO TABLE fields.
SPLIT str AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
READ TABLE fields INTO lv_field1 INDEX 1.
fs_table-temp = lv_field1.
* SPLIT str AT '#' INTO fs_table-month fs_table-bw_typ fs_table-col_typ fs_table-np_type.
CLEAR lv_field1.
READ TABLE fields INTO lv_field1 INDEX 2.
fs_table-per = lv_field1.
** CLEAR lv_field.
READ TABLE fields INTO lv_field1 INDEX 3.
** lv_count = strlen( lv_field1 ).
** lv_count = lv_count - 1.
fs_table-stdt = lv_field1 ."+0(lv_count).
READ TABLE fields INTO lv_field1 INDEX 4.
fs_table-endt = lv_field1.
*** lv_count = lv_count - 1.
READ TABLE fields INTO lv_field1 INDEX 5.
fs_table-rat = lv_field1.
*** fs_table-np_type = lv_field1+0(lv_count).
APPEND fs_table TO it_final1.
CLEAR : lv_field1,lv_count.
ENDLOOP.
***--Data in IT_FINAL1
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.