How to upload .csv file with tab as delimiter.
HI,
I want to upload a .csv file with tab as delimiter to unix path in background.
I know there is function module 'GUI_UPLOAD', but in my case data is available in an internal table .
upload the *.CSV :
OPEN DATASET lv_filename
FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
* Write file records into file on application server
LOOP AT gt_datatab INTO gs_datatab.
TRANSFER gs_datatab TO lv_filename.
ENDLOOP.
CLOSE DATASET lv_filename.
Bhanu,
Define a local variable of type CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
LV_TAB TYPE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
LOOP AT GT_DATATAB INTO GS_DATATAB.
CONCATENATE GS_DATATAB-FIELD1
GS_DATATAB-FIELD2
GS_DATATAB-FIELDN
INTO LV_STRING SEPARATED BY LV_TAB.
TRANSFER LV_STRING TO lv_filename.
ENDLOOP.
Thanks,
Vikram.M
Similar Messages
-
How to upload .CSV file from Application Server
Hi Experts,
How to upload .CSV file separated by ',' from Application server to an internal table.
Invoice No,Cust No,Item Type,Invoice Date,days,Discount Amount,Gross Amount,Sales Amount,Customer Order No.,Group,Pay Terms
546162,3233,1,9/4/2007,11,26.79,5358.75,5358.75,11264,HRS,11
546163,2645,1,9/4/2007,11,3.07,305.25,305.25,10781,C,11
Actually I read some already answered posts. But still I have some doubts.
Can anybody please send me the code.
Thanks in Advance.Hi Priya,
Check this code
Yhe logic used here is as follows,
Get all the data into an internal table in the simple format ie: a row with one field contains an entire line
After getting the data, we split each line of the table on every occurrence of the delimiter (comma in your case)
Here, I have named the fields as field01, field02 etc, you could use your own names according to your requirement
parameters: p_file(512).
DATA : BEGIN OF ITAB OCCURS 0,
COL1(1024) TYPE C,
END OF ITAB,
WA_ITAB LIKE LINE OF ITAB.
DATA: BEGIN OF ITAB_2 OCCURS 0,
FIELD01(256),
FIELD02(256),
FIELD03(256),
FIELD04(256),
FIELD05(256),
FIELD06(256),
FIELD07(256),
FIELD08(256),
FIELD09(256),
FIELD10(256),
FIELD11(256),
FIELD12(256),
FIELD13(256),
FIELD14(256),
FIELD15(256),
FIELD16(256),
END OF ITAB_2.
DATA: WA_2 LIKE LINE OF ITAB_2.
OPEN DATASET p_FILE FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.
IF SY-SUBRC = 8.
WRITE:/ 'File' , p_FILE , 'cannot be opened'.
LV_LEAVEPGM = 'X'.
EXIT.
ENDIF.
WHILE SY-SUBRC <> 4.
READ DATASET p_FILE INTO WA_ITAB.
APPEND WA_ITAB TO ITAB.
ENDWHILE.
CLOSE DATASET p_FILE.
LOOP AT ITAB INTO WA_ITAB.
SPLIT WA_ITAB-COL1 AT ',' " where comma is ur demiliter
INTO WA_2-FIELD01 WA_2-FIELD02 WA_2-FIELD03 WA_2-FIELD04
WA_2-FIELD05 WA_2-FIELD06 WA_2-FIELD07 WA_2-FIELD08 WA_2-FIELD09
WA_2-FIELD10 WA_2-FIELD11 WA_2-FIELD12 WA_2-FIELD13 WA_2-FIELD14
WA_2-FIELD15 WA_2-FIELD16.
APPEND WA_2 TO ITAB_2.
CLEAR WA_2.
ENDLOOP.
Message was edited by:
Kris Donald -
Upload Csv files with infopackages - Error 1
Hello again,
i'm trying to upload csv file into a infopackage with master data text but the sistem sends a error message "Error 1 uploading external data".
Infopackage settings:
source system: PC
file type: data file
csv file
data separator ;
ESC signal "
a created a txt file with data separated with ; and later converted txt file into a csv file.
can anybody help me pls?
Thanks
Silvia MarquesHi Silvia,
If the fields are correct in the transfer structure (only 2 fields). Then check whether the field length and type has been defined correctly for both the fields.
If thats not a problem then try to load only upto PSA.
If you are using IDOC as your transfer method then go to the "details" tab of the monitor of the error request and see the details. It will give you the correct picture of the error.
Bye
Dinesh. -
How to upload CSV file(Flat File) in SAP system.
Hi All,
Please guide me how to upload flat file into SAP system.
Regards
AvinavUse following syntax -
DATA L_P_FILE TYPE STRING.
L_P_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_P_FILE <-------Your PC file name
FILETYPE = u2018ASCu2019
HAS_FIELD_SEPARATOR = u2018Xu2019
TABLES
DATA_TAB = P_I_DATA[] <-----Your internal table
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 -
How to upload large file with http via post
Hi guys,
Does anybody know how to upload large file (>100 MB) use applet to servlet with http via post method? Thanks in advance.
Regards,
Mark.Hi SuckRatE
Thanks for your reply. Could you give me some client side code to upload a large file. I use URL to connect to server. It throws out of memory exception. The part of client code is below:
// connect to the servlet
URL theServlet = new URL(servletLocation);
URLConnection servletConnection = theServlet.openConnection();
// inform the connection that we will send output and accept input
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
// Don't used a cached version of URL connection.
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches(false);
// Specify the content type that we will send text data
servletConnection.setRequestProperty("Content-Type",
+"application/octet-stream");
// send the user string to the servlet.
OutputStream outStream = servletConnection.getOutputStream();
FileInputStream filein = new FileInputStream(largeFile);
//BufferedReader in = new BufferedReader(new InputStreamReader
+(servletConnection.getInputStream()));
//System.out.println("tempCurrent = "+in.readLine());
byte abyte[] = new byte[2048];
int cnt = 0;
while((cnt = filein.read(abyte)) > 0)
outStream.write(abyte, 0, cnt);
filein.close();
outStream.flush();
outStream.close();
Regards,
Mark. -
How to upload a file with a HTML form into a BLOB ?
Hi,
I want to upload a file into a BLOB.
I have created a procedure in PL/SQL whitch generates an html form.
You can upload a file with <input type="file" name="my_file">.
How can I insert this file into my database ?
Thank's for your Help
EstelleHi Estelle,
Portal Applications forum is a more apporpriate forum for such questions. Please post your question there.
Thanks,
Ravi -
Upload csv files with infopackages
Hello,
I want to upload csv files for an infopackage in BW System and when i execute the infopackage, the system sends the error message "Role for scan virus /SCET/GUI_UPLOAD is not active".
Can anybody help me?
Thanks
Silvia MarquesHi Silvia,
You can check OSS note: 841387. Other relevant notes are :803637, 797108 and 807989.
Hope this helps... -
Uploading csv file with number type data to database using apex
hi
am trying to upload csv file to oracle database using apex when i select the file using file browser and click on the button.
my table looks like
coloumn type
col1 number(2)
col2 number(2)
col3 number(2)
col4 number(2)
please tell me the steps i need to follow
urgent requirementThis thread should help - Load CSV file into a table when a button is clicked by the user
-
How to upload CSV file w/o ,, for the last line
Hi Experts,
As part of one interface uploading the csv file (4coulmns) manually using the TCODE: CSCA_FILE_COPY.
After uploading when i see in the AL11 as it is csv file it is filling the , in each space.
But my issue while running the interface (because of logic in it) checking for the hash total in the last line where (record count, hash total) only 2 items should come but because of manual upload adding the (record count, hash total, , ,) another two spaces.
Where program not moving further becasue the it is alway comparing the amounts (1000.00 not matching with 1000.00, , ) it is not processing. In production files directly load in to unix server so no issues and i can't ask to change the program code...because iam not following the process. As part of testing i've to do manually only.
Please suggest the workaround for this.
Is it possible to change the contents directly in AL11 directly....then HOW ?
or
How to create a csv file w/o , , in the last line (may be it is not possible) ?
Thanks for your replies in advance.
Regards
VVRI don't think you can edit from AL11, nor creating a CSV without those commas at the end because are created to state fields with empty value.
You have 6 columns filled with values but for the last line you only fill the first four. It is expected to appear , , for the last 2 columns on the last line.
I can only suggest keep doing it manually before uploading the CSV file... or... you are saying you can't change the program.
How about upload all CSV files... then writing another program to get those files from AL11 and delete the spare commas at the end line?
Cheers,
Andres. -
Anyone know how to upload csv file to temp table of sybase DB from java?
Dear All,
I blindly need your help in achieving the following:
I have the csv file which contains OrdId and BillId values. I just wanted to read these two values one by one from excel and loaded them into one temp table of Sybase SQL Anywhere.
here is the sample query for your reference:
begin tran
create table tempdb..ordBill (ord_id int identity,bill_id int
go
load table tempdb..ordBill from 'c:\\test\\test.csv'Error:
Incorrect syntax near the keyword 'table'.
I am having only one tool Microsoft ISQL/W from which i connect to remote sybase DB and run some queries like sp_help , create etc.. from there.
It would be great,if somebody knows the way of doing the above thru some java program. Otherwise, is there any tool like BCP required to do the above?
Awaiting for your valuable reply
thanks
pannarHi,
I could connect to my Sybase DB thru java program. Can somebody help me how to upload the csv file into sybase temp table ?
Here is the sample code:
import java.sql.*;
public class DBConn {
public DBConn(){
public static void main(String[] args) {
try {
//Class.forName("com.sybase.jdbc2.jdbc.SybDriver.class.getname()");
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
String sourceURL = "jdbc:sybase:Tds:ldbd1.devo.ilx.com:5000";
Connection conn = DriverManager.getConnection(sourceURL, "pannar", "pannar");
//Connection conn = DriverManager.getConnection(sourceURL);
System.out.println("Success");
} catch (Exception e) {
System.err.println("Got an excpetion! ");
e.printStackTrace();
} -
How to import csv file with multiple tables into sql server
I have multiple csv files that has one sheet but has 130 headers with each header having different data.
I'd like to import each one of these header rows with data into its own file in sql server.
I know very basic SSIS and am but am not familiar with the scripting in it though which what I assume I'd have to use.
Each header in the csv file is structured as such(also see example pic):
first header would be this:
ITEM = ORG_V
DATE = 2013-07-22 10:00 ~ 2013-07-22 10:15
column names
data
second header would be this:
ITEM = TER_V
DATE = 2013-07-22 10:00 ~ 2013-07-22 10:15
column names
data
The headers can be at any random row number as well as the data size in each excel file differs but they all start with "ITEM ="
and then in the next row "DATE ="
I could also convert these to excel files if it makes this process easier.Why don't you put a filter on D3, filter out the blanks, copy/paste to a new CSV file, save it, and import it.
There's no way you're going to get SQL to do that kind of thing for you. The language is for set based operations, not for complex data manipulation tasks.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
How to import data from CSV file with columns separated by semicolon?
I migrate database from MS SQL 2008 to ORACLE 11g
I export data to CSV file from MS SQL
then I try to import it to Oracle
several tables goes fine using Import data option in the SQL Developer
Standard CSV files with data separated by comma were imported.
chars, date (with format string), and integer data are imported via import wizard without problems
the problems were when I try to import table with noninteger numbers with modal part separated by comma not by dot
comma is the standard separator for columns in CSV file
so I must change the standard separator to semicolon
then the import wizard have problem to correct recognize the columns data because it use only standard CSV comma separator :-/
In SQL Developer 1.5.3 Tools -> Preferences -> Migration -> Data Move Options
I change "End of Column Delimiter" to ; but it doens't work
Is this possible to change the standard column separator for import data wizzard in SQL Developer 1.5.3?
Or maybe someone know how to import data in SQL Developer 1.5.3 from CSV when CSV colunn separator is set to semicolon?A new preference has been added to customize the import delimiter in main code line. This should be available as part of future release.
-
How to generate a second csv file with different report columns selected?
Hi. Everybody:
How to generate a second csv file with different report columns selected?
The first csv file is easy (report attributes -> report export -> enable CSV output Yes). However, our users demand 2 csv files with different report columns selected to meet their different needs.
(The users don't want to have one csv file with all report columns included. They just want to get whatever they need directly, no extra columns)
Thank you for any help!
MZHello,
I'm doing it usually. Typically example would be in the report only the column "FIRST_NAME" and "LAST_NAME" displayed whereas
in the csv exported with the UTL_FILE the complete address (street, housenumber, additions, zip, town, state ... ) is written, these things are needed e.g. the form letters.
You do not need another page, just an additional button named e.g. "export_to_csv" on your report page.
The csv export itself is handled from a plsql procedure "stored procedure" ( I like to have business logic outside of apex) which is invoked by pressing the button "export_to_csv". Of course the stored procedure can handle also parameters
An example code would be something like
PROCEDURE srn_brief_mitglieder (
p_start_mg_nr IN NUMBER,
p_ende_mg_nr IN NUMBER
AS
export_file UTL_FILE.FILE_TYPE;
l_line VARCHAR2(20000);
l_lfd NUMBER;
l_dateiname VARCHAR2(100);
l_datum VARCHAR2(20);
l_hilfe VARCHAR2(20);
CURSOR c1 IS
SELECT
MG_NR
,TO_CHAR(MG_BEITRITT,'dd.mm.yyyy') AS MG_BEITRITT ,TO_CHAR(MG_AUFNAHME,'dd.mm.yyyy') AS MG_AUFNAHME
,MG_ANREDE ,MG_TITEL ,MG_NACHNAME ,MG_VORNAME
,MG_STRASSE ,MG_HNR ,MG_ZUSATZ ,MG_PLZ ,MG_ORT
FROM MITGLIEDER
WHERE MG_NR >= p_start_mg_nr
AND MG_NR <= p_ende_mg_nr
--WHERE ROWNUM < 10
ORDER BY MG_NR;
BEGIN
SELECT TO_CHAR(SYSDATE, 'yyyy_mm_dd' ) INTO l_datum FROM DUAL;
SELECT TO_CHAR(SYSDATE, 'hh24miss' ) INTO l_hilfe FROM DUAL;
l_datum := l_datum||'_'||l_hilfe;
--DBMS_OUTPUT.PUT_LINE ( l_datum);
l_dateiname := 'SRNBRIEF_MITGLIEDER_'||l_datum||'.CSV';
--DBMS_OUTPUT.PUT_LINE ( l_dateiname);
export_file := UTL_FILE.FOPEN('EXPORTDIR', l_dateiname, 'W');
l_line := '';
--HEADER
l_line := '"NR"|"BEITRITT"|"AUFNAHME"|"ANREDE"|"TITEL"|"NACHNAME"|"VORNAME"';
l_line := l_line||'|"STRASSE"|"HNR"|"ZUSATZ"|"PLZ"|"ORT"';
UTL_FILE.PUT_LINE(export_file, l_line);
FOR rec IN c1
LOOP
l_line := '"'||rec.MG_NR||'"';
l_line := l_line||'|"'||rec.MG_BEITRITT||'"|"' ||rec.MG_AUFNAHME||'"';
l_line := l_line||'|"'||rec.MG_ANREDE||'"|"'||rec.MG_TITEL||'"|"'||rec.MG_NACHNAME||'"|"'||rec.MG_VORNAME||'"';
l_line := l_line||'|"'||rec.MG_STRASSE||'"|"'||rec.MG_HNR||'"|"'||rec.MG_ZUSATZ||'"|"'||rec.MG_PLZ||'"|"'||rec.MG_ORT||'"';
-- DBMS_OUTPUT.PUT_LINE (l_line);
-- in datei schreiben
UTL_FILE.PUT_LINE(export_file, l_line);
END LOOP;
UTL_FILE.FCLOSE(export_file);
END srn_brief_mitglieder;Edited by: wucis on Nov 6, 2011 9:09 AM -
How to create a csv file with NCS attributes?
Hi
i installed Cisco Prime NCS and trying to perform bulk update of device credentials with csv file.
How to create a csv file with all required attributes?
This is part of NCS online help talking about this topic:
Bulk Update Devices—To update the device credentials in a bulk, select Bulk Update Devices from the Select a command drop-down list. The Bulk Update Devices page appears.You can choose a CSV file.
Note The CSV file contains a list of devices to be updated, one device per line. Each line is a comma separated list of device attributes. The first line describes the attributes included. The IP address attribute is mandatory.
Bellow is test csv file i created but does not work:
10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
The error i am getting while importing this file:
Missing mandatory field [ip_address] on header line:10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
Assistance appreciated.It looks like the IP address field is incorrectly set.,
It should be as follows
{Device IP},{Device Subnet Mask}, etc etc
so a practical example of the aboove could be (i dont know if this is completely correct after the IP address / Subnet Mask)
10.64.160.31,255.255.255.0,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
below is a link to the documentation
http://www.cisco.com/en/US/docs/wireless/ncs/1.0/configuration/guide/ctrlcfg.html#wp1840245
HTH
Darren -
How to upload a file into server using j2ee jsp and servlet with bean?
How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
Anyone help me please!u don't need j2ee and struts to do file uploading. An example is as such
in JSP. u use the <input> file tag like
<input type="file"....>You need a bean to capture the file contents like
class FileUploadObj {
private FormFile srcFile;
private byte[] fileContent;
// all the getter and setter methods
}Then in the servlet, you process the file for uploading
* The following loads the uploaded binary data into a byte Array.
FileUploadObj form = new FileUploadObj();
byte[] byteArr = null;
if (form.signFile != null) {
int filesize = form.srcFile.getFileSize();
byteArr = new byte[filesize];
ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
bytein.read(byteArr);
bytein.close();
form.setFileContent(byteArr);
// Write file content using Writer class into the destination file in the server.
...
Maybe you are looking for
-
I updated my itunes to 9.2 and now my iphone won't sync - help!
I have an imac on Tiger. My iphone is 3G. It was working fine until I updated my itunes to 9.2. Now suddenly itunes isn't picking up my iphone. What to do? Can I revert back to the previous version of itunes? If I do, will I lose all my files? Thanks
-
I just factory restored my iPod 5 touch and when I plug it into iTunes to back it up, iTunes stops responding and closes. This only occurs when the iPod is plugged in, when it isn't, iTunes works fine. I am using Windows 8 and iTunes is updated (as o
-
Select multiple equipment records in selection screen
hi need to select multiple equipment records. Not a range of equipment records but many equipment records. I am using this as select option SELECT-OPTIONS: s_equip FOR equi-equnr. Please help
-
Difficulty using hardcoded swf file to display flv files
Hi, I have created a swf player using the flvplayback component to display flv files. The document in flash is 275 pixels wide by 130px pixels long. I also have my video component (flyPlayBack) set at 275px by 100px to display the playback controls.
-
Why does Mac Mini Server refuse to accept my Airport WPA password?
I've several Macs all able to access my ADSL net connection with no problems. However I am trying to configure a Mac Mini Server to do so but it keeps asking for the WPA password which I've correctly entered. Any clues for a solution please? Thanks P