4.6 table to csv file to email
Hi Experts
I have solisti1 table with 40 lines in each line (255 char) ,I have line of wordes seperated by " , "
I want to send this table via email as CSV file attachment
for taht i use 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send the mail
but when I send It I receive CSV file with one line , how I can make each line in the solisti1 table
as new line in the CSV file ...
pls help
Thanks and regardes
Hi
1. use the semicolon ' ; ' as seperator
2. the CR
text = your string ....
CONCATENATE text cl_abap_char_utilities=>cr_lf(1) INTO text.
CR_LF(1) .. 1 to use only the hex: 0d ( CR... ) LF is not needed..
best reg Robert
Similar Messages
-
Problem in uploading xls/csv file with Email address through oracle forms
Dear all,
I've created an interface to upload data from xls
and csv files to database tables.
I'm sucessed in this. Now i'm facing an issue.
If the xls/csv file having Email address,the
upload activity is not working..junk characters is
getting stored.
I came to know that, xls .csv file having email
address with hiperlink. so this may cause the
issue (just guessing)..
we can't restrict users to upload email without
hiperlink.. so what is the alternative to do
this..
Email address
[email protected]
[email protected]
[email protected]
etc...Can you give some more information:
What versions of Forms, database, Java, browser are you using?
How are you uploading data? Please show us your code.
What do you mean by "email with a hyperlink"? -
Download int table into csv file with each column in separate column in csv
Hi All,
I want to download the data in internal table to CSV file. but each column in the table should come as separate column in csv format.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = GD_FILE
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
tables
DATA_TAB = I_LINES_NEW
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 NE 0.
WRITE: 'Error ', SY-SUBRC, 'returned from GUI_DOWNLOAD SAP OUTBOUND'.
SKIP.
ENDIF.
with the above values passd , I am getting csv file but all the columns in one column separated by some square symbol.
How to separate them into different columns.
Thanks in advance
rgds,
MadhuriBelow example might help you understand on dowloading CSV file:
TYPE-POOLS: truxs.
DATA: i_t001 TYPE STANDARD TABLE OF t001,
i_data TYPE truxs_t_text_data.
SELECT * FROM t001 INTO TABLE i_t001 UP TO 20 ROWS.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ','
* I_LINE_HEADER =
* I_FILENAME =
* I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = i_t001
CHANGING
i_tab_converted_data = i_data
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.
DATA: file TYPE string VALUE 'C:\testing.csv'.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = file
CHANGING
data_tab = i_data[]
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards
Eswar -
How to send .CSV file via email in Oracle10g/11g PL/SQL
Hi Guys,
Can any one let me know or suggest me how to send .csv file via email attachment using Oracle PL/SQL.
Thanks in advance!
Regards,
LRKA FAQ. Use UTL_MAIL (if attachment is 32KB less). Else use UTL_SMTP. Search this forum. Search using google.
-
How to send a csv file by email in SSIS
Hi,
I need to create a SSIS package which creates a csv from sql table and send the same file by email. I have created the package but it thorws error saying the file does not exist in the send email task. For the first time the file will not be present but
the send email task expects the file to be present when executing itself. How to solve this issue?
PreethaIn Execution taks
/*you should map the shared folder to a drive letter*/
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'My Name',
@recipients = '[email protected]',
@subject = 'Error Log Count',
@file_attachments=N'F:\Testing.txt'
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Error while creating table from csv file
I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
Any idea?I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
Any idea? -
How to update Records of SAP table from .CSV file
Hi,
I have written a code which takes a data from (,) delimited CSV file and adds it into the Internal table.
Now I want to update the all fields in SAP table with the Internal table.
I want to use Update statement.
Update <table Name> SET <field needs to update> WHERE connditon.
I don't want to iterate through thousand on record in sap table to check the where condition.
Could you please tell me how to do it.Hi. I thing you will not workaround the iterating of the internal table.
You can pre-load all the records into another internal table
check lt_csv[] is not initial. " important, otherwise next select would read all records of the table
select .... into lt_dbitab for all entries in lt_csv where key-fieds = lt_csv-key_fields...
check sy-subrc eq 0 and lt_dbitab[] is not initial.
then do in-memory update of the it_dbitab
loop at it_dbitab assign <fs>.
read table lt_csv assign <fs_csv> with key ... " lt_csv should be sorted table with key, or you should try to use binary search
if sy-subrc eq 0.
...change required lt_dbitab fields: <fs>-comp = <fs_csv>-comp...
endif.
endloop.
ant then you can do mass-update
update dbtab from table lt_dbitab.
From performance view, this solution should be much faster than iterating lt_csv directly and updating every single database record
Br
Bohuslav -
Bulk Insert into a Table from CSV file
I have a CSV file with 1000 records and i have to insert those records into a table.
I tried for Bulk Insert command and Load data infile command but it throws error.
Am using Oracle 10g Express Edition.
I want to achieve it thru query command and not by plsql procedures
Please send me query syntax for this problem. . . .
Thanks in Advance,
Hariharan ST.Hi
If you create an external table that points to your csv file you will then be able populate your table from a query.
See: http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11210
Hope this helps -
Dynamically creating oracle table with csv file as source
Hi,
We have a requirment..TO create a dynamic external table.. Whenever the data or number of columns change in the CSV file the table should be replaced with current data and current number of columns...as we are naive experienced people in oracle please give us a clear solution.. We have tried with a code already ..But getting some errors. Code given below..
thank you
we have executed this code by changing the schema name and table name ..Remaining everything same ...
Assume the following:
- Oracle User and Schema name is ALLEXPERTS
- Database name is EXPERTS
- The directory object is file_dir
- CSV file directory is /export/home/log
- The csv file name is ALLEXPERTS_CSV.log
- The table name is all_experts_tbl
1. Create a directory object in Oracle. The directory will point to the directory where the file located.
conn sys/{password}@EXPERTS as sysdba;
CREATE OR REPLACE DIRECTORY file_dir AS '/export/home/log';
2. Grant the directory privilege to the user
GRANT READ ON DIRECTORY file_dir TO ALLEXPERTS;
3. Create the table
Connect as ALLEXPERTS user
create table ALLEXPERTS.all_experts_tbl
(txt_line varchar2(512))
organization external
(type ORACLE_LOADER
default directory file_dir
access parameters (records delimited by newline
fields
(txt_line char(512)))
location ('ALLEXPERTS_CSV.log')
This will create a table that links the data to a file. Now you can treat this file as a regular table where you can use SELECT statement to retrieve the data.
PL/SQL to create the data (PSEUDO code)
CREATE OR REPLACE PROCEDURE new_proc IS
-- Setup the cursor
CURSOR c_main IS SELECT *
FROM allexperts.all_experts_tbl;
CURSOR c_first_row IS ALLEXPERTS_CSV.logSELECT *
FROM allexperts.all_experts_tbl
WHERE ROWNUM = 1;
-- Declare Variable
l_delimiter_count NUMBER;
l_temp_counter NUMBER:=1;
l_current_row VARCHAR2(100);
l_create_statements VARCHAR2(1000);
BEGIN
-- Get the first row
-- Open the c_first_row and fetch the data into l_current_row
-- Count the number of delimiter l_current_row and set the l_delimiter_count
OPEN c_first_row;
FETCH c_first_row INTO l_current_row;
CLOSE c_first_row;
l_delimiter_count := number of delimiter in l_current_row;
-- Create the table with the right number of columns
l_create_statements := 'CREATE TABLE csv_table ( ';
WHILE l_temp_counter <= l_delimiter_count
LOOP
l_create_statement := l_create_statement || 'COL' || l_temp_counter || ' VARCHAR2(100)'
l_temp_counter := l_temp_counter + 1;
IF l_temp_counter <=l_delimiter_count THEN
l_create_statement := l_create_statement || ',';
END IF;
END;
l_create_statement := l_create_statement || ')';
EXECUTE IMMEDIATE l_create_statement;
-- Open the c_main to parse all the rows and insert into the table
WHILE rec IN c_main
LOOP
-- Loop thru all the records and parse them
-- Insert the data into the table created above
END LOOP;The initial table is showing errors and the procedure is created with compilation errors
After executing the create table i am getting the following errors
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-00554: error encountered while parsing access parameters
KUP-01005: syntax error: found "identifier": expecting one of: "badfile,
byteordermark, characterset, column, data, delimited, discardfile,
disable_directory_link_check, exit, fields, fixed, load, logfile, language,
nodiscardfile, nobadfile, nologfile, date_cache, processing, readsize, string,
skip, territory, varia"
KUP-01008: the bad identifier was: deli
KUP-01007: at line 1 column 9
ORA-06512: at "SYS.ORACLE_LOADER", line 19 -
Updating internal table with CSV file
I have a flat file as below:
aaaa, bbbb, asdc, dfgfhg, sdfsg, sdf, sdf, sdf, dfg, sdf, sgf, drgftfgh, sgf, drgtf, swftgd, sgf,
'sjhdfjhf','2003-10-11 07:52:37','167','alkjd',NULL,NULL,NULL,NULL,NULL,'MX1',NULL,NULL,'dkjffdj ,',NULL,NULL,NULL,'1',NULL,NULL,'AR, dfkj ',
Where we can see it is separated by commas.I want to upload this one into onr internal table.I used GUI_UPLOAD and gave the logic as folows:
TYPES: BEGIN OF ttab,
rec(1000) TYPE c,
END OF ttab.
TYPES: BEGIN OF tdat,
aaaa type char10
bbbb type char10,
asdc type char10,
dfgfhg type char10,
sdfsg type char10,
sdf type char10,
sdf type char10,
sdf type char10,
dfg type char10,
sdf type char10,
sgf type char10,
drgftfgh type char10,
sgf type char10,
drgtf type char10,
swftgd type char10,
sgf type char10,
END OF tdat.
DATA: itab TYPE TABLE OF ttab WITH HEADER LINE.
DATA: idat TYPE TABLE OF tdat WITH HEADER LINE.
DATA: file_str TYPE string.
PARAMETERS: p_file TYPE localfile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = p_file.
START-OF-SELECTION.
file_str = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_str
TABLES
data_tab = itab
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.
LOOP AT itab.
CLEAR idat.
SPLIT itab-rec AT ',' INTO idat-aaaa
idat-bbbb ,
idat-asdc ,
idat-dfgfhg ,
idat-sdfsg ,
idat-sdf ,
idat-sdf ,
idat-sdf ,
idat-dfg ,
idat-sdf ,
idat-sgf ,
idat-drgftfgh ,
idat-sgf ,
idat-drgtf ,
idat-swftgd ,
idat-sgf ,
APPEND idat.
ENDLOOP.
Now the issue is when I use the statement SPLIT itab-rec AT ',' this is not updating the table idat properly.Because the flat file contains the value as 'dkjffdj ,', too.
Can anyone give me some solution to update the internal table.hI
or you delete ' from csv file before uploading it or after uploading it, in this last case u can use statament replace:
REPLACE ''' WITH SPACE INTO ITAB-FIELD.
Max -
Import data from oracle database table into csv file
Hi
I have to import data from a table into a csv file. Could anyone suggest the best method to do it? My application is JSP as frontend and have put business logic in servlet.
Thanks in advance.FastReader from wisdomforce will help you quickly export data into csv file. http://www.wisdomforce.com
fastreader can be called and executed as an external process ( Runtime.exec(..) ) to extract data from Oracle tables into flat file -
Problem in convering internal table to CSV file
Hi,
Iam converting internal table data to CSV format with the code given below.
LOOP AT it_details_final INTO wa_details_final.
CLEAR : t_attachment.
CONSTANTS : c_sep TYPE c VALUE ','.
CONCATENATE wa_details_final-wf_rectype
wa_details_final-wf_bankn
wa_details_final-wf_znme1
wa_details_final-wf_rzawe
wa_details_final-wf_lifnr
wa_details_final-wf_chect
wa_details_final-wf_rwbtr
wa_details_final-wf_chkladat
cl_abap_char_utilities=>newline
INTO t_attachment SEPARATED BY c_sep.
APPEND t_attachment.
CLEAR t_attachment.
ENDLOOP.
Problem is ,data in one of the fields contain comma ( , ).
So, data after comma is getting shifted to the adjacent cell.
Please help me
Thanks & Regards,
SravanthiHello,
Try this perform
the ignorefields variable is used if you dont want a particular field in the output. You can ignore it for now
DATA: p_ignoredfields(1024).
CONSTANTS : const_sep TYPE c VALUE ','.
* itab to store data ready to be sent to csv file
DATA: BEGIN OF wa_csvdata,
line(4096),
END OF wa_csvdata.
DATA: gt_csvdata LIKE TABLE OF wa_csvdata.
*& Form CONVERT_TO_CSV
* text
FORM convert_to_csv TABLES lt_datatab USING value(p_ignoredfields).
FIELD-SYMBOLS: <wa_datatab> TYPE ANY.
FIELD-SYMBOLS: <wa_field> TYPE ANY.
* character variable incase table fields are of a diff type (ie: int)
DATA: lv_data TYPE string.
* set to X if the no data has been put into the csv workarea
DATA: flag_firstcol TYPE xflag.
* move the structure one character to the right since first char
* is position 0 in SAP
SHIFT p_ignoredfields BY 1 PLACES RIGHT.
REFRESH gt_csvdata.
CLEAR wa_csvdata.
LOOP AT lt_datatab ASSIGNING <wa_datatab>.
flag_firstcol = 'X'.
DO.
* one by one assign each position of the structure to the field
ASSIGN COMPONENT sy-index OF STRUCTURE <wa_datatab> TO <wa_field>.
IF sy-subrc <> 0.
EXIT.
ELSE.
* if the current field needs to be ignored then continue the do loop
IF p_ignoredfields+sy-index(1) = '.'.
CONTINUE.
ENDIF.
* we use lv_data since concatenate fails for integer types
lv_data = <wa_field>.
* remove commas in the data
WHILE sy-subrc = 0.
REPLACE const_sep WITH '' INTO lv_data.
ENDWHILE.
* if this data belongs to the first non ignored column
IF flag_firstcol = 'X'.
wa_csvdata = lv_data.
flag_firstcol = ''.
ELSE.
CONCATENATE wa_csvdata const_sep lv_data INTO wa_csvdata.
ENDIF.
ENDIF.
ENDDO.
APPEND wa_csvdata TO gt_csvdata.
CLEAR wa_csvdata.
ENDLOOP.
ENDFORM. " CONVERT_TO_CSV -
.csv file in an outlook email attachment
Hello,
How can we accomplish following using SOA/BPEL without using Oracle Beehive or any other third paty tools.
1. Emails contain a .csv file with 5 columns.
2. There is a table in Oracle EBS database with 5 columns.
3. We need to have real time integration to import these .csv file from incoming emails into Oracle table from #2 above.
How can SOA/BPEL detach the .csv file from emails, parse .csv fields and import these files in Oracle table in real time manner?
Please advise.
Darshas idea
- vba script in outlook for save .*csv files to some directory
- composite for pooling directory and insert data from parsed .*csv files
or
all by vba -
Leading Spaces in CSV file while sending Email
Hi All,
Iam sending CSV file via email, Iam getting leading space for the first field from column second.
I have used the below code for appending internal table.
Concatenating all the fileds with comma separator and aded 'cl_abap_char_utilities=>newline' at the last.
For first column iam getting correctly, form second column onwards iam getting spaces in front of first field. I have used the FM, SO_NEW_DOCUMENT_ATT_SEND_API1 for sending the email. Please suggest. thanks.Hi,
Concatenate cl_abap_char_utilities=>cr_lf before every line/record of the file.
This should resolve the issue.
Thanks,
Anupam -
Hello everyone,
To move data from roughly 50 CSV files in a loop to SQL tables (table per CSV file), I've used BulkInsert task in For each loop container.
Please know, for all different columns of all CSV files, the filed length was specified as varchar(255).
It worked well for the first 6 files but on 7th file, it has found the data in one of the columns of CSV file, which exceeds the limit of 255 characters. I would like to truncate the data and insert the remaining data for this column. In other words, I would
like to insert first 255 characters into table for this field and let the package execute further.
Also, if I would use SQLBulkCopy in Script task, will it be able to resolve this problem? I believe, I would face the similar problem over there too. Although, would like to get confirmation for the same from experts.
Can you please advise how to get rid of this truncation error?
Any help would be greatly appreciated.
Thanks, <b>Ankit Shah</b> <hr> Inkey Solutions, India. <hr> Microsoft Certified Business Management Solutions Professionals <hr> http://ankit.inkeysolutions.comHello! I suggest you add a derived column transformation between Source and Destination, use string functions to extract first 255 characters from the incoming field and send this output to destination field, that ways you can get rid of these sort of issues.
Useful Links:
http://sqlage.blogspot.in/2013/07/ssis-how-to-use-derived-column.html
Good Luck!
Please Mark This As Answer if it solved your issue.
Please Vote This As Helpful if it helps to solve your issue
Maybe you are looking for
-
Lenovo G500 win 8.1 Radeon problem
Hi i bought Lenovo g500like a year ago and recently updated my system to win 8.1and then eveything starts. My games FPS drops for 30-40 to 11-12 (games like witcher 2 which should work fine on Radeon HD8750M). So i decided to install new version of A
-
How to use dynamic internal table in interactive report syntax
pls let me know
-
Xi sender mail adapter with attachment (to Web Service w/ attachment)
Hello, We're working on an XI scenario wherein a sender mail adapter polls an exchange server inbox for mail (with attachment)and sends the attachment to a Web Service via SOAP Adapter? Does anyone know if this is doable, and if so, how? Thanks, Eric
-
How to set the defualt directory of where to look for a file to read
I am reading a file from a servlet. I wanted to see where Tomcat would write the file if I didn't specify a path. The results surprised me. It wrote the file in: "C:\Documents and Settings\myusername\Start Menu\Programs\Apache Tomcat 4.1". So I looke
-
CREATING A SINGLE INSTANCE PHYSICAL STANDBY FOR A RAC PRIMARY
Hi Creating a single instance physical standby database for a RAC Primary. Getting this error. sql statement: alter database mount standby database RMAN-00571: =========================================================== RMAN-00569: =============== ER