Writing CLOB data using UTL_FILE to several files by settingmaxrows in loop
Hey Gurus,
I have a procedure that creates a CLOB document (in the form of a table in oracle 9i). I need to now write this large CLOB data (with some 270,000 rows) into several files, setting the row max at 1000. So essentially ther would be some sort of loop construct and substr process that creates a file after looping through 1000 rows and then continues the count and creates a another file until all 270 xml files are created. Simple enough right...lol? Well I've tried doing this and haven't gotten anywhere. My pl/sql coding skills are too elementary I am guessing. I've only been doing this for about three months and could use the assistance of a more experienced person here.
Here are the particulars...
CLOB doc is a table in my Oracle 9i application named "XML_CLOB"
Directory name to write output to "DIR_PATH"
DIRECTORY PATH is "\app\cdg\cov"
Regards,
Chris
the xmldata itself in the CLOB would look like this for one row.
<macess_exp_import_export_file><file_header><file_information></file_information></file_header><items><documents><document><external_reference></external_reference><processing_instructions><update>Date of Service</update></processing_instructions><filing_instructions><folder_ids><folder id="UNKNOWN" folder_type_id="19"></folder></folder_ids></filing_instructions><document_header><document_type id="27"></document_type><document_id>CUE0000179</document_id><document_description>CUE0000179</document_description><document_date name="Date of Service">1900-01-01</document_date><document_properties></document_properties></document_header><document_data><internal_file><document_file_path>\\adam\GiftSystems\Huron\TIFS\066\CUE0000179.tif</document_file_path><document_extension>TIF</document_extension></internal_file></document_data></document></documents></items></macess_exp_import_export_file>
Similar Messages
-
How to view clob data using sql
Hi,
In our database, we have one table that is having one column of CLOB datatype but now i want to view the data using sql select query but it throws error: "Datatype not supported".
Could any one please let me know how to view the clob data using select query.
Oracle DB version : 10.2.0.3
Thanksh5.
use read procedure
PROCEDURE READ (
lobsrc IN BFILE|BLOB|CLOB ,
amount IN OUT BINARY_INTEGER,
offset IN INTEGER,
buffer OUT RAW|VARCHAR2 );
example Updating LOB by Using DBMS_LOB in PL/SQL
DECLARE
lobloc CLOB; -- serves as the LOB locator
text VARCHAR2(32767):='Resigned: 5 August 2000';
amount NUMBER ; -- amount to be written
offset INTEGER; -- where to start writing
BEGIN
SELECT resume INTO lobloc
FROM employees
WHERE employee_id = 405 FOR UPDATE;
offset := DBMS_LOB.GETLENGTH(lobloc) + 2;
amount := length(text);
DBMS_LOB.WRITE (lobloc, amount, offset, text );
text := ' Resigned: 30 September 2000';
SELECT resume INTO lobloc
FROM employees
WHERE employee_id = 170 FOR UPDATE;
amount := length(text);
DBMS_LOB.WRITEAPPEND(lobloc, amount, text);
COMMIT;
END; -
How to upload data using utl_file when you dont know the exact file name
Hi
i want to upload data from a flat file to a table.
i dont know the exact file name. i want to make a search for filename. like i want to make a search on file (say test*) which will give me all the files with test.
i want to upload data using these files.
how can i do this by using UTL_FILE.
Regards
ManishThank you very much.
Thing is previously we are using sqlloader and shell script for loading the data.
now i am creating a procedure (if possible without parameters).
Is there any other way i can do that.
can i make a wild card search using utl_file.
Thanks n Regards
Manish -
Write data using utl_file
hi , i am using oracle 10g.
i am writing this job which runs every day and writes into file.
first time i has to put upto 700,000 records into file and from next run it will be around 5000.
please let me know what ever i am doing is correct or not. i never used utl_file , since this is my first time using utl_file i really need help from you guys.
CREATE OR REPLACE PROCEDURE pr_cpe_dashboard
IS
CURSOR c1
IS
SELECT /*+ parallel ( qdm 8) index(sdm INDX_RPRE_MART_SITE_QREV) index(odm INDX_RPRE_MART_ORD_QSITE) */
qdm.quote_id
|| '||'
|| qdm.quote_revision
|| '||'
|| qdm.quote_status
|| '||'
|| qdm.last_modified_date
|| '||'
|| qdm.billing_method
|| '||'
|| qdm.quote_total
|| '||'
|| CASE
WHEN sdm.project_number IS NULL
THEN 'NULL'
ELSE sdm.project_number
END
|| '||'
|| CASE
WHEN odm.order_number IS NULL
THEN 'NULL'
ELSE odm.order_number
END
|| '||'
|| CASE
WHEN odm.order_type IS NULL
THEN 'NULL'
ELSE odm.order_type
END
|| '||'
|| CASE
WHEN odm.release_timestamp IS NULL
THEN 'NULL'
ELSE TO_CHAR (odm.release_timestamp, 'mm/dd/yyyy hh:mi:ss')
END
|| '||'
|| CASE
WHEN sdm.account_name IS NULL
THEN 'NULL'
ELSE sdm.account_name
END
|| '||'
|| qdm.nasp_id
FROM r_premisys_quote_detail_mart qdm,
r_premisys_site_detail_mart sdm,
r_premisys_order_detail_mart odm
WHERE qdm.quote_id = sdm.quote_id(+)
AND qdm.quote_revision = sdm.quote_revision(+)
AND qdm.quote_id = odm.quote_id(+)
AND qdm.quote_revision = odm.quote_revision(+)
AND qdm.last_modified_date >= (SELECT last_used_date
FROM job_audit_date);
output_file UTL_FILE.file_type;
l_dir VARCHAR2 (10) := 'c:/orders';
l_filename VARCHAR2 (25) := 'cpe.txt';
v_array t_array := t_array ();
BEGIN
output_file := UTL_FILE.fopen (l_dir, l_filename, 'W');
OPEN c1;
LOOP
FETCH employees_cur
BULK COLLECT INTO v_array LIMIT 1000;
FOR i IN 1 .. v_array.COUNT
LOOP
UTL_FILE.put_line (output_file, v_array (i));
END LOOP;
EXIT WHEN v_array.COUNT = 0;
END LOOP;
UTL_FILE.fclose (output_file);
END pr_cpe_dashboard;A couple of things.
This is wrong:
l_dir VARCHAR2 (10) := 'c:/orders';It must be the name of a directory object, created via the "+CREATE DIRECTORY+" command. Dir objects are (database) aliases for physical paths. Like any other db object, it provides a security layer that allows one to control access to it. You do not want any and all db sessions to access the root drive on that server.
Not necessary:
v_array t_array := t_array ();You are calling the constructor to create an empty array. Not needed as the bulk collect does that for you. Simply define the variable - the bulk collect takes the responsibility for initialising and populating it.
Review:
parallel ( qdm 8) Personally I dislike such hints, hints forcing indexes and so on. Reason is that the developer is second guessing the CBO. Yes, you may have the right values for the development db and its data set. It may even work for production for a while. But production is very seldom static. Process loads varies. Data volumes increases. Even the database model changes (e.g. new columns, new indexes, etc). H/w changes (e.g. more CPUs, more memory, etc).
By second guessing the CBO, the developer makes it very hard for the DBA and CBO properly manage performance and scalability on the server.
Also, keep in mind that UTL_FILE (and PL/SQL code) is a serialised process (only exception is specially crafted pipeline table functions). So despite using/requesting 8 parallel query processes (PQ) in the hint, a single PL process has to write that data to file. Be sure that you identify the appropriate bottleneck when dealing with I/O and wanting to use PQ to address it. -
Spooling large data using UTL_FILE
Hi Everybody!
While spooling out data into a file using UTL_FILE package I am unable spool the data The column data has a size of 2531 characters
The column 'source_where_clause_text' has very large data.
Its not giving any error but the external table is not returning and data
Following is the code.
CREATE OR REPLACE PROCEDURE transformation_utl_file AS
CURSOR c1 IS
select transformation_nme,source_where_clause_text
from utility.data_transformation where transformation_nme='product_closing';
v_fh UTL_FILE.file_type;
BEGIN
v_fh := UTL_FILE.fopen('UTLFILELOAD', 'transformation_data.dat', 'w', 32000);--132767
FOR ci IN c1
LOOP
UTL_FILE.put_line( v_fh, ci.transformation_nme ||'~'|| ci.source_where_clause_text);
-- UTL_FILE.put_line( v_fh, ci.system_id ||'~'||ci.system_nme ||'~'|| ci.system_desc ||'~'|| ci.date_stamp);
END LOOP;
UTL_FILE.fclose( v_fh );
exception
when utl_file.invalid_path then dbms_output.put_line('Invalid Path');
END;
select length(
'(select to_char(b.system_id) || to_date(a.period_start_date,''dd-mon-yyyy'') view_key, b.system_id, to_date(a.period_start_date,''dd-mon-yyyy'') period_start_date, to_date(a.period_end_date,''dd-mon-yyyy'') period_end_date, to_date(a.clos
ing_date,''dd-mon-yyyy'') closing_date from ((select decode(certification_type_code, ''A'', ''IDESK_PRODUCTS_PIPELINE'',''C'', ''IDESK_PRODUCTS_COMMITMENT_LINKAGE'') system_nme, to_char(to_date(''01'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyy
yy''),''dd-mon-yyyy'') period_start_date, to_char(last_day(to_date(''12'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyyyy'')),''dd-mon-yyyy'') period_end_date, to_char(trunc(certification_datetime_stamp), ''dd-mon-yyyy'') closing_date from odsu
pload.prod_monthly_certification where certification_type_code in (''A'',''C'') minus select trim(system_nme), to_char(period_start_date, ''dd-mon-yyyy''), to_char(period_end_date, ''dd-mon-yyyy''), to_char(closing_date, ''dd-mon-yyyy'') from utility.system_closing
statusv where system_nme in (''IDESK_PRODUCTS_PIPELINE'', ''IDESK_PRODUCTS_COMMITMENT_LINKAGE'')) union all (select ''BMS Commitment Link'' system_nme, to_char(to_date(''01'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyyyy''),''dd-mon-yyyy'')
period_start_date, to_char(last_day(to_date(''12'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyyyy'')),''dd-mon-yyyy'') period_end_date, to_char(trunc(certification_datetime_stamp), ''dd-mon-yyyy'') closing_date from odsupload.prod_monthly_c
ertification where certification_type_code = ''C'' minus select trim(system_nme), to_char(period_start_date, ''dd-mon-yyyy''), to_char(period_end_date, ''dd-mon-yyyy''), to_char(closing_date, ''dd-mon-yyyy'') from utility.system_closing_status_v where system_nme
= ''BMS Commitment Link'') union all (select ''BMS'' system_nme, to_char(to_date(''01'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyyyy''),''dd-mon-yyyy'') period_start_date, to_char(last_day(to_date(''12'' || lpad(trim(to_char(certification_as_
of_month_yr)),6,''0''),''ddmmyyyy'')),''dd-mon-yyyy'') period_end_date, to_char(trunc(certification_datetime_stamp), ''dd-mon-yyyy'') closing_date from odsupload.prod_monthly_certification where certification_type_code = ''A'' minus select trim(system_nme), to_char
(period_start_date, ''dd-mon-yyyy''), to_char(period_end_date, ''dd-mon-yyyy''), to_char(closing_date, ''dd-mon-yyyy'') from utility.system_closing_status_v where system_nme = ''BMS'')) a, utility.system_v b where a.system_nme = b.system_nme)') length1
from dual
--2531
begin
SSUBRAMANIAN.transformation_utl_file;
end;
create table transformation_utl
TRANSFORMATION_NME VARCHAR2(40),
SOURCE_WHERE_CLAUSE_TEXT VARCHAR2(4000)
ORGANIZATION external
type oracle_loader
default directory UTLFILELOAD
ACCESS PARAMETERS
records delimited by newline CHARACTERSET US7ASCII
BADFILE UTLFILELOAD:'transformation.bad'
LOGFILE UTLFILELOAD:'transformation.log'
fields TERMINATED by "~"
LOCATION ('transformation_data.dat')
) REJECT LIMIT UNLIMITED
select * from transformation_utlafter running the procedure, did you verify that the file 'transformation_data.dat' has data? open it, make sure it's correct. maybe it has no data, and that's why the external table doesn't show anything.
also, check the LOG and BAD files after selecting from the external table. maybe they have ERRORS in them (or all the data is going to BAD because you defined something wrong). -
How can you SELECT via Database Link CLOB data using Application Express?
Customer Issue:
Developer using Oracle's Application Express 3.1. The Developer is trying to SELECT a CLOB datatype column from a remote (10.2.0.3) database, via a database link on her 10.2.0.4 based client Application. The Developer wants to be able to select CLOB data from the remote database which has limitation that she can't make any changes to the remote database.
Developer's Comments:
I do a select and get the error. Getting error ORA-22992: cannot use LOB locators selected from remote tables. So she feels she can't use dbms_lob.substr in this configuration I can do a "select into" but that is for one value. I am trying to run a select statement for a report that brings back more than one row. I do not have permission to change anything on the remote database. I want to access the remote database and multiple tables.
This is not something I work with, would greatly appreciate help or ideas. Is this a limitation of the 3.1; or does she just not have this set up correctly; or should she be using a Collection (if yes, please share example)
Thanks very much,
Pam
Edited by: pmoutrie on Jun 4, 2009 12:01 PM
Hello???
Would really appreciate an answer.
Thanks,
PamThis may not be a perfect solution for you but it worked for my situation.
I wanted to grab some data from Grid Control's MGMT$JOB_STEP_HISTORY table but I couldnt' create an Interactive Report due to the existance of a CLOB column. I cheated this by creating a view on the GC DB, grabbing the first 4000 characters and turning it into a varchar2 column:
create view test_job_step_history as
select job_Name, target_name, status, start_time, end_time, to_char(substr(output,1,4000)) output
from MGMT$JOB_STEP_HISTORY where trunc(end_time) > trunc(sysdate)-90
In an APEX Interactive Report:
select * from test_job_step_history@GCDB
Granted, the output looks aweful right now but I am only looking for a very particular output (failed, denied, ORA-, RMAN-, etc) so the formatting isn't the most important thing to me right now.
If anyone can improve -- and I'm sure you can -- on this I'd love to hear about it.
Thanks,
Rich -
Reading CLOB data using jdbc thin driver
Hi,
When I try reading data for a CLOB column using thin jdbc driver, I get the following error message
"Exception: ORA-06550: line 1, column 22:
PLS-00302: component 'GETCHUNKSIZE' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored".
This error message is displayed when the call is made to get the character stream from the Clob object.
Do I need to any server side setup before I can access CLOB data from the database?
thanks.
Puru BalakrishnanI updated to the latest jdbc drivers, 816classes12b.zip, and the problem went away.
null -
Can someone please help me with my code as i am stuck, I have succesfully displayed the question i want to screen using the button find. Then and only then will the bottom panel be shown with the question and relevant answers displayed in text boxes.
I need help in overwriting what the text box said to what the user then changes it to and writing it to the dat file. any help on this would be greatly appreciated as its part of an assignment i have to do for next week and this is only one part of it cheers. My code is as follows:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class UpdateQuestions extends JFrame implements ActionListener
Container cPane;
JPanel p1,p2;
JButton btnFind,btnUpdate,btnClose;
JTextField tfNumberSearch,tfQuestionNum,tfQuestion,tfAnswerA,tfAnswerB,tfAnswerC,tfCorrect;
JLabel lblNumberSearch,lblQuestion,lblAnswerA,lblAnswerB,lblAnswerC,lblCorrect;
RandomAccessFile rf;
UpdateQuestions()
cPane = getContentPane();
cPane.setBackground(Color.RED);
//Build Update Window
setTitle("Update Quiz Questions");
setSize(1024,768);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
//Absolute Layout Manager
cPane.setLayout(null);
//Size & Layout For Top Panel
p1 = new JPanel();
p1.setBackground(Color.WHITE);
p1.setBounds(50,50,600,100);
p1.setLayout(null);
cPane.add(p1);
//Top Panel
lblNumberSearch = new JLabel("Enter Question No");
lblNumberSearch.setFont(new Font("Serif",Font.BOLD,24));
lblNumberSearch.setForeground(Color.BLACK);
lblNumberSearch.setBounds(10,30,200,50);
p1.add(lblNumberSearch);
tfNumberSearch = new JTextField();
tfNumberSearch.setFont(new Font("Serif",Font.BOLD,18));
tfNumberSearch.setColumns(3);
tfNumberSearch.setForeground(Color.BLACK);
tfNumberSearch.setBounds(210,30,100,50);
p1.add(tfNumberSearch);
btnFind = new JButton("Find");
btnFind.setFont(new Font("Serif",Font.BOLD,26));
btnFind.addActionListener(this);
btnFind.setBounds(400,10,100,80);
p1.add(btnFind);
p1.setVisible(true);
//Size & Layout For Bottom Panel
p2 = new JPanel();
p2.setBounds(50,250,900,400);
p2.setLayout(null);
cPane.add(p2);
// Question Label & Text Box
lblQuestion = new JLabel("Question");
lblQuestion.setFont(new Font("Serif",Font.BOLD,24));
lblQuestion.setForeground(Color.BLACK);
lblQuestion.setBounds(10,10,330,50);
p2.add(lblQuestion);
tfQuestion = new JTextField();
tfQuestion.setFont(new Font("Serif",Font.BOLD,18));
tfQuestion.setColumns(50);
tfQuestion.setForeground(Color.BLACK);
tfQuestion.setBounds(150,10,600,50);
p2.add(tfQuestion);
//Answer A Label & Text Box
lblAnswerA = new JLabel("Answer A");
lblAnswerA.setFont(new Font("Serif",Font.BOLD,24));
lblAnswerA.setForeground(Color.BLACK);
lblAnswerA.setBounds(10,90,330,50);
p2.add(lblAnswerA);
tfAnswerA = new JTextField();
tfAnswerA.setFont(new Font("Serif",Font.BOLD,18));
tfAnswerA.setColumns(20);
tfAnswerA.setForeground(Color.BLACK);
tfAnswerA.setBounds(150,90,400,50);
p2.add(tfAnswerA);
//Answer B Label & Text Box
lblAnswerB = new JLabel("Answer B");
lblAnswerB.setFont(new Font("Serif",Font.BOLD,24));
lblAnswerB.setForeground(Color.BLACK);
lblAnswerB.setBounds(10,170,330,50);
p2.add(lblAnswerB);
tfAnswerB = new JTextField();
tfAnswerB.setFont(new Font("Serif",Font.BOLD,18));
tfAnswerB.setColumns(20);
tfAnswerB.setForeground(Color.BLACK);
tfAnswerB.setBounds(150,170,400,50);
p2.add(tfAnswerB);
//Answer C Label & Text Box
lblAnswerC = new JLabel("Answer C");
lblAnswerC.setFont(new Font("Serif",Font.BOLD,24));
lblAnswerC.setForeground(Color.BLACK);
lblAnswerC.setBounds(10,250,330,50);
p2.add(lblAnswerC);
tfAnswerC = new JTextField();
tfAnswerC.setFont(new Font("Serif",Font.BOLD,18));
tfAnswerC.setColumns(20);
tfAnswerC.setForeground(Color.BLACK);
tfAnswerC.setBounds(150,250,400,50);
p2.add(tfAnswerC);
//Correct Answer Label & Text Box
lblCorrect = new JLabel("Correct");
lblCorrect.setFont(new Font("Serif",Font.BOLD,24));
lblCorrect.setForeground(Color.BLACK);
lblCorrect.setBounds(10,330,330,50);
p2.add(lblCorrect);
tfCorrect = new JTextField();
tfCorrect.setFont(new Font("Serif",Font.BOLD,18));
tfCorrect.setColumns(20);
tfCorrect.setForeground(Color.BLACK);
tfCorrect.setBounds(150,330,400,50);
p2.add(tfCorrect);
btnUpdate = new JButton("Update");
btnUpdate.setFont(new Font("Serif",Font.BOLD,26));
btnUpdate.addActionListener(this);
btnUpdate.setBounds(700,300,150,80);
p2.add(btnUpdate);
p2.setVisible(false);
private String pad(String s,int size)
int x;
for (x = s.length(); x < size; x++)
s = s + " ";
return s;
public void actionPerformed(ActionEvent e)
int num;
if(e.getSource()==btnClose)
try
rf.close();
setVisible(false);
catch(IOException ex3)
JOptionPane.showMessageDialog(null,"Cannot Close Question.dat");
if(e.getSource()==btnFind)
boolean eof,found;
int qNo;
long posQ, posAnsA, posAnsB, posAnsC, posCorrect;
String question="", answerA="", answerB="", answerC="", answerCorrect="";
num = Integer.parseInt(tfNumberSearch.getText());
eof=false;
found=false;
try
rf = new RandomAccessFile("Question.dat","rw");
rf.seek(0);
catch(FileNotFoundException ex1)
JOptionPane.showMessageDialog(null,"Cannot Open Question.dat");
catch (IOException ex)
eof=true;
while(!eof)
try
qNo = rf.readInt();
posQ = rf.getFilePointer(); question = rf.readUTF();
posAnsA = rf.getFilePointer(); answerA=rf.readUTF();
posAnsB = rf.getFilePointer(); answerB=rf.readUTF();
posAnsC = rf.getFilePointer(); answerC=rf.readUTF();
posCorrect = rf.getFilePointer(); answerCorrect=rf.readUTF();
if(num==qNo)
found=true;
eof=true;
tfQuestion.setText(question);
tfAnswerA.setText(answerA);
tfAnswerB.setText(answerB);
tfAnswerC.setText(answerC);
tfCorrect.setText(answerCorrect);
p2.setVisible(true);
rf.close();
catch (IOException ex)
eof=true;
}// End of While not !eof
}// End of Find Button
if(e.getSource()==btnUpdate)
String question, answerA, answerB, answerC, answerCorrect;
long posQ, posAnsA, posAnsB, posAnsC, posCorrect;
question = tfQuestion.getText();
question = pad(question,80);
answerA = tfAnswerA.getText();
answerA = pad(answerA,20);
answerB = tfAnswerB.getText();
answerB = pad(answerB,20);
answerC = tfAnswerC.getText();
answerC = pad(answerC,20);
answerCorrect = tfCorrect.getText();
answerCorrect = pad(answerCorrect,20);
rf.seek(posQ);
rf.writeUTF(question);
rf.seek(posAnsA);
rf.writeUTF(answerA);
rf.seek(posAnsB);
rf.writeUTF(answerB);
rf.seek(posAnsC);
rf.writeUTF(answerC);
rf.seek(posCorrect);
rf.writeUTF(answerCorrect);
}//End of Action Performed
}//End of UpdateQuestionsCreate your JFrames, then use
myFirstFrame.setVisible( true );
// time to launch second
mySecondFrame.setVisible( true );
// time to hide second
mySecondFrame.setVisible( false );The simplest file I/O will work for you. Use a FileOutputStream to write the file. I think three lines of code should do the trick. See the API docs for java.io. -
Getting ORA-24801: error when reading a CLOB data using BufferReader
I am getting the "ORA-24801: illegal parameter value in OCI lob function", when reading a CLOB using a BufferedReader, i am using "oracle.jdbc.OracleDriver" for creating a connection pool and using Oracle 9.2.0.7 with Weblogic 8.1 SP 5. My code looks like this,
oracle.sql.CLOB c_lob = null;
c_lob = ( oracle.sql.CLOB)stmt.getClob(7);
BufferedReader in1 = new BufferedReader(c_lob.getCharacterStream());
char buffer[] = new char[1];
int i;
while((i = in1.read(buffer)) != -1)
The error is coming at "in1.read(buffer)".Hi,
Your buffer size should be the clob size.
char[] buffer = new char[c_lob.getBufferSize()];
Also, set the value for i as -1.
You could see the sample on OTN for help:
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/Readme.html
Thanks,
Rashmi -
Capturing data using write to measurement file for encoder
hello dear,
can anyone help to check with my encoder to measure data?
i have connect the write to measurement file but when i open the .txt file,
no result appear, thanks so much for your help
Solved!
Go to Solution.
Attachments:
encoder capture.vi 180 KBwell, I have never used that method to write data to a file, but if you double click on your write the write LabVIEW measurement file object and look at the configuration you have selected save to a series of files. Is that what you wanted, or did you just want one file?
Jim
Jim
LV 2013 -
Problem in Uploading Data using a Tab Separated File?
Hi All,
I am trying to upload a file which tab separated containing customer and bank details and my file structure somewhat in the following manner.
10 21169 abcde xyz kdHDHLk gdh ghgah (Customer Details)
20 21169 DE 20050000 01122334 (bank details for customer 21169)
20 21169 DE 23022200 1122334455
(bank details for customer 21169)
20 21169 DE 23984899 223344556 (bank details).
But when I am trying to intial upload the details to an internal table using GUI_upload FM and display to check if it is loading correctly or not it is not giving me any o/p.
I am copying the code which I am trying to execute. Please tell me what way I need to modify the code so that it executes correctly.
parameters: p_file type rlgrap-filename.
data: begin of wa_file,
text(256) type c,
end of wa_file.
data: it_file like table of wa_file.
types: begin of ty_kna1,
kunnr type kunnr,
name1 type name1,
sortl type sortl,
stras type stras,
ort01 type ort01,
land1 type land1,
spras type spras,
end of ty_kna1.
data: it_kna1 type standard table of ty_kna1,
wa_kna1 type ty_kna1.
types: begin of ty_knbk,
kunnr type kunnr,
banks type knbk-banks,
bankl type knbk-bankl,
bankn type knbk-bankn,
end of ty_knbk.
data: it_knbk type standard table of ty_knbk,
wa_knbk type ty_knbk.
data: v_id(2).
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
Start-of-Selection.
data: p_file1 type string.
p_file1 = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = p_file1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = it_file
* 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.
constants: c_tab type X value '09'.
loop at it_file into wa_file.
if wa_file+0(2) = '10'.
split wa_file at 'c_tab'
into v_id
wa_kna1-kunnr
wa_kna1-name1
wa_kna1-sortl
wa_kna1-stras
wa_kna1-ort01
wa_kna1-land1
wa_kna1-spras.
append wa_kna1 to it_kna1.
elseif wa_file+0(2) = '20'.
split wa_file at 'c_tab'
into v_id
wa_knbk-kunnr
wa_knbk-banks
wa_knbk-bankl
wa_knbk-bankn.
append wa_knbk to it_knbk.
endif.
endloop.
write:/ 'Customer Master General Data'.
uline.
loop at it_kna1 into wa_kna1.
write:/ wa_kna1-kunnr,
wa_kna1-name1,
wa_kna1-sortl,
wa_kna1-stras,
wa_kna1-ort01,
wa_kna1-land1,
wa_kna1-spras.
endloop.
clear wa_kna1.
skip 2.
write:/ 'Customer Master Bank Data'.
uline.
loop at it_knbk into wa_knbk.
write:/ wa_knbk-kunnr,
wa_knbk-banks,
wa_knbk-bankl,
wa_knbk-bankn.
endloop.
clear wa_knbk.
Regards,
MDDeclare Class cl_abap_char_utilities
Use File type as 'DBF'
Has_field_seperator = w_tab in FM GUI_UPLOAD
DATA: w_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = w_file
filetype = 'DBF'
append = ' '
write_field_separator = w_tab
TABLES
data_tab = it_extractchar
fieldnames = it_header
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
OTHERS = 22 -
Initialize a date using eCATT and a file
We are trying to clear the values in a date field (MBEW-ZKDAT), i.e. we're trying to update the field from some date to the initial value.
We have an eCATT that has been working fine when there is some value in the date field. But when we try to put any other value (00/00/0000, 00000000 or just leave it blank) in the file, we're getting 'Invalid date' error.
I've looked in FAQ, SAP Help, but can't find any useful information on this. Does anyone know what we need to enter in the date field to make it blank (=initialize)?
Thank you.Hello Jelena
Normally &CLEAR does this job.
[Special Variables (eCATT Tutorial)|http://help.sap.com/saphelp_nw04/helpdata/EN/3d/72cd3bb961766de10000000a11402f/content.htm]
Regards
Uwe -
Unload dynamic data using JDBC into a file
Hi,
I have to download the result of a dynamic SELECT query into a file.
The query will be provided at runtime. So I am unsure of the number of columns and the data types of the columns.
Also I am unable to use io on the returned resultset object.
So basically i have to persist the data from the resultset object into a file.
Any hints
Thanks in advanceAlso I am unable to use io on the returned resultset object.What do you mean by this?
See the JDBC tutorial: http://java.sun.com/docs/books/tutorial/jdbc/index.html
and the file I/O tutorial: http://java.sun.com/docs/books/tutorial/essential/io/index.html -
Writing transient data into a spreadshee​t file in Windows XP
Hi,
I need to be able to save the data of 13 seperate properties in a spread sheet. I need to capture transient data and store it in a spreadsheet or something for analysis. I want to be able to create a new file everytime I capture the data, name the file, and I want to specify how long it should be capturing the data (maybe a time limit or start and stop buttons).
By the way, I have been trying to learn through examples in my LabVIEW 2009 Student Edition manual and the one example I tried was having problems working with my current laptop, which is running Windows XP. The error message told me that I couldn't write "?" and things like that. I think it is a Windows XP thing. I'm not sure. I can post the message if I need to.
Can someone please help me out? If someone could create an example I could work off of, I would greatly appreciate it! Thanks!!Thanks for pointing out those examples. I have looked through someof them, but I am totally lost. For one example, I don't now what do do with my loops. I want the continuous loop to display data but I don't know if I need another loop to stop and start the file writing. I included my VI so you guys can take a look.
If someone could help me a bit more, like modifying my VI and sending it back to me so I can see what I am doing wrong, you guys would be a big help! Thanks again!
Attachments:
Multiple Signals Test.vi 82 KB -
CSV file reading using UTL_FILE at run time
Hi,
I have to read CSV file using UTL_FILE.
but Folder contains Many CSV files.
I dont know there name.So i have to read csv file at run time.
Please let me know how should we achieve this?
Thanksplace the following in a shell script, say "list_my_files.ksh"
ls -l > my_file_list.datthen run the shell script using dbms_scheduler;
begin
dbms_scheduler.create_program (program_name => 'a_test_proc'
,program_type => 'EXECUTABLE'
,program_action => '/home/bluefrog/list_my_files.ksh'
,number_of_arguments => 0
,enabled => true);
end;
/then open "my_file_list.dat" using UTL_FILE, read all file names and choose the one you require.
P;
Maybe you are looking for
-
I recently made a dumb decision and changed my iPad pass code, I must have blanked out because I have no memory of the password to get in and now I'm locked out. iTunes is requiring the pass code but I don't remember it! I'm not connected to iClou
-
Goods Movement 351 not posting to PCA
For our new plant implentation, we create STO (ME23N), GI - 351 movement type, and GR - 101. No sales order, No delivery. Also 101 GR doesnt create financial document. at good issue 351 movement type : inv FG 13300100 Cr inv FG 13300100 Dr F
-
Not able to post the Time for already created timecard
Hi All, I have a question on OTL, already time is posted for a week say 29-MAY-2010 to 06-JUN-2010 (for 5 working days), now I need to post the time on saturday & sunday too. I'm using all the mentioned API's given by the oracle. But while processing
-
Sharing an external hard drive - iMac and iPad
I currently have an external hard drive connected to an iMac. I also have an iPad. How can I share the hard drive between both and have access to it from the iPad. The hard drive is a Western Digital 2TB My book.
-
What kind of music file to use when you download
I just got my Video Ipod and i do not know what kind of music file i am using to download my music. i know thereis aac, mps, wave, and all different kinds. i do not know how to change which one i am using. i assume it already is set to aac???please h