on 04-12-2012 4:46 PM
hi everyone,
I am working on an application in which I need to upload an excel file and all its data should be transferred to database table.
can anyone help me out?
Regards,
Rajiv.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks YUVAL for replying,
I want to insert data from excel sheet to my database table on click of a button.
I am not able to insert data to my database table with the above link.
I am the calling function 'HR_KR_XSTRING_TO_STRING' and then i am calling a function to convert the data to insert it to the database. here it is giving an error. Tell me how to resolve this or tell me some other way to do this.
Regards,
Rajiv
Hi Rajiv,
Did you try the above steps I suggested. Hope the following link will give you more idea.
http://www.sapdev.co.uk/file/file_upexcel.htm
Regards,
Fareez
Hi Fareez,
The above link which you gave is working fine when i am using it in SE38.
But when I am using it in web dynpro it is giving an error
'The method could not be found at dynamic call.'.
The code which i am using is
method ONACTIONUPLOAD.
TYPE-POOLS: truxs.
TYPES:
BEGIN OF t_tab,
A(10) TYPE c,
B(10) TYPE c,
C(10) TYPE c,
D(10) TYPE c,
E(10) TYPE c,
F(300) TYPE c,
G(50) TYPE c,
H(50) TYPE c,
I(50) TYPE c,
J(50) TYPE c,
K(50) TYPE c,
END OF t_tab.
DATA: it_datatab type standard table of t_tab,
p_file TYPE rlgrap-filename,
wa_datatab type t_tab.
DATA: it_raw TYPE truxs_t_text_data.
wd_context->get_attribute( EXPORTING name = 'DATA' IMPORTING value = p_file ).
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
field_name = P_FILE
IMPORTING
file_name = p_file.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER = 'X'
i_tab_raw_data = it_raw
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* LOOP AT T_UPLOAD INTO WA_UPLOAD.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-a,
wa_datatab-b,
wa_datatab-c,
wa_datatab-d,
wa_datatab-e,
wa_datatab-f,
wa_datatab-g,
wa_datatab-h,
wa_datatab-i,
wa_datatab-j,
wa_datatab-k.
CALL FUNCTION 'ZFM_QBANK'
EXPORTING
A = wa_datatab-a
B = WA_datatab-B
C = WA_datatab-C
D = WA_datatab-D
E = WA_datatab-E
F = WA_datatab-F
G = WA_datatab-G
H = WA_datatab-H
I = WA_datatab-I
J = WA_datatab-J
K = WA_datatab-K.
ENDLOOP.
ENDMETHOD.
Regards,
Rajiv
Hi Rajiv,
The method 'F4_FILENAME' is to use with SAP GUI and not with web dynpro. Use a File Upload component to upload the xls file and the pass the raw data to the TEXT_CONVERT_XLS_TO_SAP. I think this should be the problem with your code.
Moreover you cannot use write and message statements in Web dynpro. Tune your entire code for Web dynpro.
Regards,
Fareez
Hi,
1. Use the file upload component to upload the excel file.
2. Convert the raw file data to internal table using TEXT_CONVERT_XLS_TO_SAP.
3. Now store the internal table to the database.
Regards,
Fareez
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
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.