Pls tell me how to upload from excel file to database.
hello,experts,
I want to upload data from excel local file to database table created by myself.when I use function
CALL FUNCTION 'GUI_DOWNLOAD'
the data in the internal table just become error code data that can not understand.
who can help me out?
thanks.
Hi,
1st copy the values in XLS into internal table by using function Module:-
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file_name<it is file path of u r XLS>
i_begin_col = 1
i_begin_row = 1
i_end_col = 250
i_end_row = 1
tables
intern = itab<this structure is same like u r database table>
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc 0.
then modify or insert these values to database from internal table:-
modify <DB table> from itab accepting duplicate keys.
for file popup use :
at selection-scree on <screen field>.
call function 'F4_FILENAME'
exporting
program = sy-cprog
dynnr = sy-dynnr
importing
filename = zfilename.
here zfilename of type rlgrap-filename.
and pass this as path in ASLA_EXCEL_TO_INTERNAL_TABLE
Edited by: vijay Mekala on Dec 29, 2007 12:45 PM
Similar Messages
-
How to upload normal excell file to ztable
Hi All there,
Can anybody tell me how to upload normal excell file to ztable directly.
pl provide detail coding
Regards
SagarHi Sagar,
first upload the excel data into your internal table using a FM than upload the data to your ZTABLE using BDC.
parameters:
p_file type rlgrap-filename " File name
data:
lw_file type string. " File Path
data:
t_bdcdata type
standard table
of bdcdata,
fs_bdcdata type bdcdata. " Work area for bdcdata
* Messages of call transaction
data:
t_messtab type
standard table
of bdcmsgcoll,
fs_messtab type bdcmsgcoll. " Work area for messtab
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
importing
file_name = p_file.
lw_file = p_file.
call function 'GUI_UPLOAD'
exporting
filename = lw_file
filetype = 'ASC'
has_field_separator = 'X'
dat_mode = 'X'
tables
data_tab = t_final_data
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif. " IF SY-SUBRC <> 0
if t_final_data is initial.
message 'File not found'(003) type 'E'.
endif. " IF T_FINAL_DATA IS INITIAL
end-of-selection.
perform upload_0585_data_using_bdc. " populate the bdcdata table using tcode SHDB
call transaction 'PA30' using t_bdcdata
mode 'A'
messages into t_messtab.
form upload_0585_data_using_bdc.
loop at t_final_data into fs_final_data.
perform bdc_field using 'Q0585-ACNTR(07)'
w_curr.
perform bdc_field using 'Q0585-ACOPC'
lw_flag.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.
perform bdc_dynpro using 'MP058500' '2000'.
perform bdc_field using 'BDC_OKCODE'
'/EBCK'.
perform bdc_dynpro using 'SAPMP50A' '1000'.
endloop.
* Start new screen *
form bdc_dynpro using program dynpro.
clear fs_bdcdata.
fs_bdcdata-program = program.
fs_bdcdata-dynpro = dynpro.
fs_bdcdata-dynbegin = 'X'.
append fs_bdcdata to t_bdcdata.
endform. " Form bdc_dynpro using program...
* Insert field *
form bdc_field using fnam fval.
clear fs_bdcdata.
fs_bdcdata-fnam = fnam.
fs_bdcdata-fval = fval.
append fs_bdcdata to t_bdcdata.
endform. " Form bdc_field using fnam fval
With luck,
Pritam. -
hi!pls tell me how can I cancel the files that download,but they can not be downloaded,there maybe a. Problem.
What files, and downloaded from where and by what app?
-
How to upload an excel file using ABAP.
Hi,
Can anyone please help me in understanding how to upload an excel file using ABAP.
Thanks!!http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/
check the link
TYPES: Begin of t_record,
name1 like itab-value,
name2 like itab-value,
age like itab-value,
End of t_record.
DATA: it_record type standard table of t_record initial size 0,
wa_record type t_record.
DATA: gd_currentrow type i.
*Selection Screen Declaration
PARAMETER p_infile like rlgrap-filename.
*START OF SELECTION
call function ALSM_EXCEL_TO_INTERNAL_TABLE
exporting
filename = p_infile
i_begin_col = 1′
i_begin_row = 2′ Do not require headings
i_end_col = 14′
i_end_row = 31′
tables
intern = itab
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. Problem uploading Excel Spreadsheet
endif.
Sort table by rows and colums
sort itab by row col.
Get first row retrieved
read table itab index 1.
Set first row retrieved to current row
gd_currentrow = itab-row.
loop at itab.
Reset values for next row
if itab-row ne gd_currentrow.
append wa_record to it_record.
clear wa_record.
gd_currentrow = itab-row.
endif.
case itab-col.
when 0001′. First name
wa_record-name1 = itab-value.
when 0002′. Surname
wa_record-name2 = itab-value.
when 0003′. Age
wa_record-age = itab-value.
endcase.
endloop.
append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop. -
CRM ABAP How to upload an Excel file into an internal table?
How to upload an Excel file using GUI_UPLOAD?? what should be the values of the parameters? The function modules ALSM_EXCEL_TO_INTERNAL_TABLE and KCD_EXCEL_OLE_TO_INT are not present in CRM. Please suggest me a way out!
Hi saurabh,
you can try the folowing sample..
and make modifications according to your requirement..
TYPE-POOLS: truxs.
DATA: i_text_data TYPE truxs_t_text_data,
v_filename_string TYPE string.
DATA: BEGIN OF itab OCCURS 0,
Name(30),
Phone(15),
Fax(500).
DATA: END OF itab.
PARAMETERS: p_file LIKE rlgrap-filename.
START-OF-SELECTION.
v_filename_string = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_filename_string
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
dat_mode = ''
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = i_text_data
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
* I_LINE_HEADER =
i_tab_raw_data = i_text_data
i_filename = p_file
TABLES
i_tab_converted_data = itab
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
this is a sample code that uploads a excel file using GUI_UPLOAD, but uses another function module to convert that uploaded data into an internal table..
regards
satesh -
How to upload a excel file in webdynpro? Please help!
Hi Experts,
I have a requirement where I need to upload a excel file in my webdynpro for ABAP report.
I have used the fileupload UI element in my view and a upload button.
However when I test the application I found that it is getting file data as some junk value like below:
###ࡱ#################>########################################################################################################################################################################################################################################
Why is that so?
Is there any limitation with fileuplaod reading excel file?
Do i have to use any encoding option?
What is the alternative option to read excel file in ABAP webdynpro?
Thanks
GopalHi,
Check this.. Write this code in Upload button 's method
********** Reading data from flat file ****************
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_datasource type xstring.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `DATASOURCE`
IMPORTING
value = lv_datasource ).
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
* FROM_CODEPAGE = '8500'
IN_XSTRING = LV_DATASOURCE
* OUT_LEN = '1'
IMPORTING
OUT_STRING = LV_STRING.
SPLIT LV_STRING AT CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO TABLE IT_STR.
LOOP AT IT_STR INTO LV_STRING.
SPLIT LV_STRING AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO TABLE FIELDS.
READ TABLE FIELDS INTO LV_FIELD INDEX 1. " Reading 1st field
ls_header-STATU = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 2. " Reading 2st field
ls_header-LIFNR = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 3.
ls_header-BSART = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 4.
ls_header-EKORG = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 5.
ls_header-EKGRP = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 6.
ls_header-BUKRS = LV_FIELD.
clear LV_FIELD.
APPEND wa to it.
append ls_header to lt_header.
clear: ls_header,wa.
endloop.
lo_nd_header->BIND_TABLE( lt_header ).
Thanks,
Ramesh
Edited by: Rameshkumar Raamasamy on Dec 20, 2010 11:16 AM -
Can anybody help how to upload an excel file into sap-crm urgent
hi guys,
i need the right function module to upload the excel file from the presentation server in to sap-crm.
1) I know we use the function module 'ALSM_EXCEL_TO_INT_TABLE' in sap-r/3 but this function module is not exist in sap-crm.
2) i tried with the function moduel 'GUI_UPLOAD' but its not uploading correctly i am gettting hases(#).
Please can any one provide the right function module to upload the excel into sap-crm with an sample code.
thanks
viswa gunthaHi Visma,
Please check this link for sample custom FM.
Re: function mudule for MS excel file to sap crm
Hope this will help.
Regards,
Ferry Lianto
Please reward points if helpful as away to say thanks. -
How to read from excel file and write it using implicit jsp out object
our code is as below:Please give us proper solution.
we are reading from Excel file and writing in dynamicaly generated Excel file.it is writing but not as original excel sheet.we are using response.setContentType and response.setHeader for generating pop up for saveing the original file in to dynamically generated Excel file.
<%@ page contentType="application/vnd.ms-excel" %>
<%
//String dLoadFile = (String)request.getParameter("jspname1");
String dLoadFile = "c:/purge_trns_nav.xls" ;
File f = new File(dLoadFile);
//set the content type(can be excel/word/powerpoint etc..)
response.setContentType ("application/msexcel");
//get the file name
String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
//set the header and also the Name by which user will be prompted to save
response.setHeader ("Content-Disposition", "attachment; filename="+name);
//OPen an input stream to the file and post the file contents thru the
//servlet output stream to the client m/c
FileInputStream in = new FileInputStream(f);
//ServletOutputStream outs = response.getOutputStream();
int bit = 10;
int i = 0;
try {
while (bit >= 0) {
bit = in.read();
out.write(bit) ;
} catch (IOException ioe) { ioe.printStackTrace(System.out); }
out.flush();
out.close();
in.close();
%>If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
import java.nio.*;
import java.nio.channels.*;
import java.io.*;
import java.util.*;
import java.text.*;
class Kopy {
* @param args [0] = source filename
* args [1] = destination filename
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println ("Syntax: java -cp . Kopy source destination");
System.exit(1);
File in = new File(args[0]);
long fileLength = in.length();
long t = System.currentTimeMillis();
FileInputStream fis = new FileInputStream (in);
FileOutputStream fos = new FileOutputStream (args[1]);
FileChannel fci = fis.getChannel();
FileChannel fco = fos.getChannel();
fco.transferFrom(fci, 0, fileLength);
fis.close();
fos.close();
t = System.currentTimeMillis() - t;
NumberFormat nf = new DecimalFormat("#,##0.00");
System.out.print (nf.format(fileLength/1024.0) + "kB copied");
if (t > 0) {
System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
} -
How to import a excel file into database?
hi all,
How can I import a excel file into database?
What I need to do first?
Thanks,
Amy1. Create a conrtol file in your disc(with notepad) ex
test_loader.ctl
LOAD DATA
INFILE='C:\Testcsv.csv'
into table test_table
FIELDS TERMINATED BY ','
TRAILING NULL COLS
(ID,COL1,COL2,COL3)
The table descrption is
scott@ORCL> desc test_table;
Name Null? Type
ID NUMBER
COL1 VARCHAR2(10)
COL2 VARCHAR2(10)
COL3 VARCHAR2(10)
scott@ORCL>
2 .Create a file testcsv.csv from your excel file you want to load with " save as" csv comma seperated value
in your hard disc c:\
3. in dos command mode write
C:\>sqlldr scott/tiger control=c:\testcsv.ctl log=c:\testcsv.log
Thats it! -
How to upload all excel files data from one folder into internal table.
Dear All,
I have one requirement, It is like I want to upload the frontend file data into my internal table, But here my scenario is;
If I have one folder ( Called : Temp) in my frontend system, in this folder ( Called : Temp) I have 100 excel files. In each excel file I have some 1000u2019s of entries. All these data of every file I want to take into my internal table.
If I have one file I can go for, CALL METHOD cl_gui_frontend_services=>file_open_dialog and then upload method to upload. But I want to take all these excel files from that folder at a time, is there any class or any thing is there..? plz help..
Thanks...
Edited by: satishsuri on Jan 11, 2011 9:33 AMHi satishsuri ,
You will have to use 3 methods together :
CALL METHOD cl_gui_frontend_services=>directory_browse "Browse the Directory
CALL METHOD cl_gui_frontend_services=>directory_list_files "Get all the files from the directory
CALL METHOD cl_gui_frontend_services=>gui_upload "Upload each file in a loop
Example:
TYPES: BEGIN OF ty_data,
line TYPE string,
END OF ty_data.
DATA: str_file TYPE string,
str_dir TYPE string,
it_file_table TYPE STANDARD TABLE OF file_info,
wa_file_table TYPE file_info,
v_count TYPE i,
it_data TYPE STANDARD TABLE OF ty_data,
wa_data TYPE ty_data.
CALL METHOD cl_gui_frontend_services=>directory_browse
CHANGING
selected_folder = str_dir.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = str_dir
CHANGING
file_table = it_file_table
count = v_count.
LOOP AT it_file_table INTO wa_file_table.
CONCATENATE str_dir wa_file_table-filename INTO str_file SEPARATED BY '\'.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = str_file
filetype = 'ASC'
CHANGING
data_tab = it_data.
LOOP AT it_data INTO wa_data.
WRITE : / wa_data-line.
ENDLOOP.
ULINE.
ENDLOOP.
Regards,
Jovito -
How to upload a excel file using BDC
how should i upload a file using BDC
i have downloaded a excel file containing the values of table A006 a X server.
now i hav to upload it into new server Y server using BDC , how do i do it?
wat all things one shud consider ?Hi,
This is very simple, follow the below mention steps to do so:
1.Declare an internal table having same structure as db table, but take all the fields type as 'C' and length same as defined in the table.
TYPES:BEGIN OF it,
key(20) TYPE c,
indicator(20) TYPE c,
bldat(20) TYPE c,"bkpf-bldat
budat(20) TYPE c,"bkpf-budat
END OF it.
DATA: itab TYPE STANDARD TABLE OF it,
wa TYPE it.
2.Include TRUX as type pool and declare a variable of type trux_t_text_data to be passed in the FM that actually reads data from excel sheet into above declared intrenal table.
TYPE-POOLS: truxs.
DATA: it_raw TYPE truxs_t_text_data.
3. Call the FM 'TEXT_CONVERT_XLS_TO_SAP' and pass the file name and the internal table name into the parameter
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR = 'X'
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file "name of the excel file
TABLES
i_tab_converted_data = itab[] "internal table where data will be stored
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
4. loop at internal table and modify the ztable/dbtable where data to be upload .
Hope this solve your problem.
Pooja -
How to upload a XML File in database
i use Blob type to set domain the Xml file. But i don't know use what class to define it.i only know use OrdHttpUploadFile to define a image. What class do i use to define a Xml file.
during my tries to adapt this code to my needs, following error occured during compilation of the procedure:
PLS-00201: identifier 'IMAGES.MIME_TYPE' must be declared
here is my procedure:
CREATE OR REPLACE PROCEDURE load_file( file_name VARCHAR2 )
AS file_lob BFILE;
binary_lob BLOB;
mime_type images.mime_type%TYPE;
extension_pos NUMBER;
BEGIN
--Use the extension of the file name to determing the MIME-type
--The MIME-type for a .pdf file will be application/pdf
extension_pos := INSTR( file_name, '.' );
mime_type := 'application/' || SUBSTR( file_name,extension_pos + 1,LENGTH( file_name ) );
-- Insert a new row into the images table. Get the LOB locator
-- for the newly inserted row
-- we will be using that to insert
-- the content from the file.
INSERT INTO TESTBLOB( blobid, filename, mime_type, content )
VALUES( 1, file_name, mime_type, EMPTY_BLOB() )
RETURNING content INTO binary_lob;
-- Open up the file in the IMAGES directory named file_name,
-- load that file into the newly created LOB locator, and
-- close the file
file_lob := BFILENAME( 'TESTDIRECTORY', file_name );
dbms_lob.fileOpen ( file_lob, dbms_lob.file_readOnly );
dbms_lob.loadFromFile( binary_lob,file_lob,dbms_lob.getLength( file_lob ) );
dbms_lob.fileClose ( file_lob );
END;
how do I have to adjust the declaration of the mime_type variable respectively what does images.mime_type%TYPE mean?
katharina -
Procurement Card data upload from flat file to database
Hi All,
I need to upload Procurement Card data from a flat file to the database in the table BBP_PCMAS.
I found a BAPI BAPI_PCARD_CREATEMULTIPLE which uploads the data perfectly, however the structure PCMASTER that it takes as input does not contain the field for Blocking reason PCBLOCK - Reason for blocking procurement card. I need to upload this file as well from the flat file.
Any suggestions?
ThanksHi,
You are correct the function module BAPI_PCARD_CREATEMULTIPLE does not contain the PCBLOCK field.
Alternatively what you can do is read the PC data after it is created and modify it with the PCBLOCK appropiately. The necessary function modules are given below.
BBP_PCMAS_READ_PCMAS - Read Data
BBP_PCMAS_MODIFY_PCMAS - Modify Data
Note: BBP_PCMAS_MODIFY_PCMAS is a Update Task FM. Hence it shoild be called as given below, ( refer form write_data of the FM BAPI_PCARD_CREATEMULTIPLE)
call function 'BBP_PCMAS_MODIFY_PCMAS' in update task
exporting
i_pcmas = i_pcmas
* I_PCMAS_OLD =
* I_DELETE =
tables
t_pcacc = i_pcacc
* T_PCACC_OLD =
exceptions
not_found = 1
others = 2.
Regards
Kathirvel -
How to read from properties file
Hi,
I am using JSR 168.
while creating a new portlet, a folder gets created with the name as "portlet". Under which is resource package and <PortletName>Bundle.java.
pls tell me how to read from .properties file.
waiting eagerly for some reply
Thanks & Regards,
HP
Edited by: user9003827 on Apr 13, 2010 3:42 AMI think i have mixed it up :)
I have looked at it again and believe you are using regular JSP portlets.
Can you tell what you want to achieve by reading .properties file. Are you meaning the preferences of the portlet or what exactly are you trying to do?
Reading propertie files is easy:
// Read properties file.
Properties properties = new Properties();
try {
properties.load(new FileInputStream("filename.properties"));
String myKey = properties.getProperty("yourKey");
} catch (IOException e) {
}Edited by: Yannick.O on 13-Apr-2010 05:52 -
How to Upload the excel flat file in LSMW
Hi all,
Can any one plz Help me,
How to Upload a excel file format by suing the lsmw .
Regadrs.
[email protected]
Upender..
Edited by: Upender Reddy on Sep 12, 2008 8:37 AMHi,
In 7 th step of LSMW we need to specify the file ie flat file.
In this step you describe all files to be used in the following steps:
· Your legacy data on the PC and/or R/3 server
· The file for the read data
· The file for the converted data.
As your legacy data is on the PC: ie your excel file that is tab delimited or comma delimited.
here give ur file name, description , click data from one src structure, then delimiter is tabulator if so, in file structure click both check boxes if in ur flat file ur first row is column, file type is record end indicator, code page ASCII and conitnue that's it.
you can go through this link very useful :
****************/Tutorials/LSMW/LSMWMainPage.htm.
thanx.
Maybe you are looking for
-
hi, I am planning to install several wireless security cams at home, and the one from linksys seemed a good choice to me. I am looking for a specific feature that I am not able to find any explanation on. In the features I see that I am abe to watc
-
I need to install just the Windows XP hardware device drivers for my PCI-DNET card, P/N 184726E-11. Ordered under P/N 777358-01, the card is boxed with an installation CD-ROM. CD-ROM is NI-DNET for windows Ver 1.6.7. When the install app runs, it
-
Working on a data merge and I'm trying to select the .xls document that the customer provided. But InDesign (both CS3 and CS5.5) wont see it as a good file. When I turn off "Support Filetypes" in the data import window and try to force the program to
-
Does Siri take up minutes on your data plan?
Also does it you use wifi instead of Internet does it use data on your plan? I am dying to know! Please and thank you.
-
Cant Click on desktop and cant find dock
can somebody plz help me out to figure this problem out. why cant i click on desktop and cant see dock on destop.