Convert created idoc to an output text file
Hi,
How can i convert an idoc to an output text file? is there a standard program in SAP that does this?
Thanks,
Tots
Hi,
We can do it.
The steps are
1. Create a xml file port (we21)
2. Create a partner profile point to the file port.
3. Make sure the idocs are genereated.
4 . Run the staandard program (RSEOUT001) with the port and required details in teh selection screen.
The idocs will be generated to a xml file .
Regards
Similar Messages
-
Ability to create a collection from a text file containing the names of the pictures
1 thing that would be very good is the ability to create a collection / quick collection from a text file that contains the names of the picture we want in that collection...
The reason for that is when i receive an order from a customer typicaly 100-200 different pictures (i'm a wedding photographer), i ask my customer to send me an excel spread sheet with all the name or number of the picture thay want with size & quantity...
I would like to be able to use that file as an input for a batch job that would add all those files to a collection "customer order" instaid od adding them 1 by 1... it would save me lots of time and would prevent some errors in the order...
I am currently able to do that with the help of a small utility (Useful File Utility) is the name... with the other RAW converter i use... BibbleWell, it is workflow software, true, but it's really focussed on image development. What you're proposing would necessarily make the primary focus be on the business angle, I suspect.
If you're talking about tools to help customers sit down and pick what they want for manual processing later, that's one thing - but going the rest of the distance to order processing and fulfillment would be out of scope, at least in my view. The reason is that there is just so much room for potential variation in how this gets conducted that I can't see how Adobe could possibly satisfy every pro with one implementation. Even just dealing with all of the possible payment vendors is a hugely problematic area.
I agree with Don; a third-party plugin via the upcoming SDK might be a distinct possibility, particularly if it were for a "plus services" solution in which the plugin were designed to work with a specific fulfillment vendor. THAT could work quite nicely, and the plugin might even be free (in return for giving the vendor your business, of course).
In other words, it's not that I see it as a bad idea, it's just that I don't think it belongs in the "core" of LR. This is something that is best dealt with using the SDK so that differences in processes can be allowed for. -
Text created in Premiere showing other text files in the timeline and exports.
Hi,
I'm creating slates with text generated in Premiere. For each new slate I am duplicating a text layer, Option + Dragging the duplicate file over the text I'd like to replace, then opening the new text layer in the text editor and updating the information.
Things seem fine at first and then randomly text layers in the timeline will show text from other files in the timeline. If I open the text file up in the text editor I see the correct info but not in the timeline.
The only fix I have found is to delete render files, move the text layer around in the timeline, quit and re-open. But still, sometimes when I export, the export preview window will show the wrong text and when I export the file I create shows the wrong text as well.
It seems like Premiere is getting confused by multiple text files in the timeline and is pointing to the wrong cache files.
Thoughts would be a huge help!Thanks for the tip Kevin. Anything I can do to avoid this in the future?
I've had this happen on a number of projects. My media and project files are on a SAN, cache and previews are local.
Thanks,
Mike Brown
P: (401) 743-7452 -
Creating jTbale that reads a text file
hey,
i want to make a Jtable out of a text file such that if there are blank spaces it should enter the text into a new column and if there is a new line then it should be entered into a new row. ...like if there is a text file such as
1 2 3
4 5 6
then it should be entered into a JTable of 2 rows and three columns.....following similar topics in forum I have written something like this
try {
Vector data = new Vector();
vector data1 = new vector();
String aLine;
String aDouble;
FileInputStream fis = new FileInputStream(selFile);
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
//read each double
while ((adouble = br.readDouble()) != null) {
// create a vector to hold the field values
Vector column = new Vector();
// tokenize words into field values
StringTokenizer str = new StringTokenizer(adouble, " ");
while (str.hasMoreTokens()) {
// add field to the column
column.addElement(str.nextToken());
// add column to the model
model.addColumn(column);
// read each line of the file
while ((aLine = br.readLine()) != null) {
// create a vector to hold the field values
Vector row = new Vector();
// tokenize line into field values
StringTokenizer st = new StringTokenizer(aLine, "|");
while (st.hasMoreTokens()) {
// add field to the row
row.addElement(st.nextToken());
// add row to the model
model.addRow(row);
// Close file
br.close();
fis.close();
catch (IOException ioExc){
ioExc.printStackTrace();
}the code ofcourse is not doing what is expected
please help!!!!!!!!
ThanksThanks camickr....i read that we can use readDouble however I am getting an error if am using that.....here is my complete code.....
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
public class TeamTable extends JFrame implements ActionListener, ItemListener
static JTable table;
// constructor
public TeamTable()
super( "Invoermodule - ABCD" );
setSize( 740, 365 );
// setting the rownames
ListModel listModel = new AbstractListModel()
String headers[] = {"Values"};
public int getSize() { return headers.length; }
public Object getElementAt(int index) { return headers[index]; }
// add listModel & rownames to the table
DefaultTableModel defaultModel = new DefaultTableModel(listModel.getSize(),4);
table = new JTable( defaultModel );
// setting the columnnames and center alignment of table cells
int width = 200;
int[] vColIndex = {0,1,2,3};
String[] ColumnName = {"a", "b", "c", "d"};
TableCellRenderer centerRenderer = new CenterRenderer();
for (int i=0; i < vColIndex.length;i++) {
table.getColumnModel().getColumn(vColIndex).setHeaderValue(ColumnName[i]);
table.getColumnModel().getColumn(vColIndex[i]).setPreferredWidth(width);
table.getColumnModel().getColumn(vColIndex[i]).setCellRenderer(centerRenderer);
table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
// force the header to resize and repaint itself
table.getTableHeader().resizeAndRepaint();
// create single component to add to scrollpane (rowHeader is JList with argument listModel)
JList rowHeader = new JList(listModel);
rowHeader.setFixedCellWidth(100);
rowHeader.setFixedCellHeight(table.getRowHeight());
rowHeader.setCellRenderer(new RowHeaderRenderer(table));
//JList columnHeader = new JList(listModel);
//columnHeader.setFixedCellWidth(100);
//rowHeader.setFixedCellHeight(table.getRowHeight());
//columnHeader.setCellRenderer(new ColumnHeaderRenderer(table));
// add to scroll pane:
JScrollPane scroll = new JScrollPane( table );
scroll.setRowHeaderView(rowHeader); // Adds row-list left of the table
getContentPane().add(scroll, BorderLayout.CENTER);
// add menubar, menu, menuitems with evenlisteners to the frame.
JMenuBar menubar = new JMenuBar();
setJMenuBar (menubar);
JMenu filemenu = new JMenu("File");
menubar.add(filemenu);
JMenuItem open = new JMenuItem("Open");
JMenuItem save = new JMenuItem("Save");
JMenuItem exit = new JMenuItem("Exit");
open.addActionListener(this);
save.addActionListener(this);
exit.addActionListener(this);
filemenu.add(open);
filemenu.add(save);
filemenu.add(exit);
filemenu.addItemListener(this);
// ActionListener for ActionEvents on JMenuItems.
public void actionPerformed(ActionEvent e)
String open = "Open";
String save = "Save";
String exit = "Exit";
DefaultTableModel model = (DefaultTableModel)table.getModel();
if (e.getSource() instanceof JMenuItem)
JMenuItem source = (JMenuItem)(e.getSource());
String x = source.getText();
if (x == open)
System.out.println("open file");
// create JFileChooser.
String filename = File.separator+"tmp";
JFileChooser fc = new JFileChooser(new File(filename));
// set default directory.
File wrkDir = new File("C:/Documents and Settings/Table");
fc.setCurrentDirectory(wrkDir);
// show open dialog.
int returnVal = fc.showOpenDialog(null);
File selFile = fc.getSelectedFile();
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: " +
fc.getSelectedFile().getName());
try{
Vector data = new Vector();
String adouble;
FileInputStream fis = new FileInputStream(selFile);
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
//read each double
while ((adouble = br.readDouble()) != null) {
// create a vector to hold the field values
Vector column = new Vector();
Vector row = new Vector();
// tokenize words into field values
StringTokenizer str = new StringTokenizer(adouble, " ");
StringTokenizer st = new StringTokenizer(adouble, "|");
while (str.hasMoreTokens()) {
// add field to the column
column.addElement(str.nextToken());
// add column to the model
model.addColumn(column);
while (st.hasMoreTokens()) {
// add field to the column
row.addElement(st.nextToken());
// add row to the model
model.addRow(row);
// Close file
br.close();
fis.close();
catch (IOException ioExc){
ioExc.printStackTrace();
if (x == save) {
System.out.println("save file");
if (x == exit) {
System.out.println("exit file");
// ItemListener for ItemEvents on JMenu.
public void itemStateChanged(ItemEvent e) {
String s = "Item event detected. Event source: " + e.getSource();
System.out.println(s);
public static void main(String[] args) {
TeamTable frame = new TeamTable();
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit(0);
frame.setVisible(true);
* Define the look/content for a cell in the row header
* In this instance uses the JTables header properties
class RowHeaderRenderer extends JLabel implements ListCellRenderer {
* Constructor creates all cells the same
* To change look for individual cells put code in
* getListCellRendererComponent method
RowHeaderRenderer(JTable table) {
JTableHeader header = table.getTableHeader();
setOpaque(true);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
* Returns the JLabel after setting the text of the cell
public Component getListCellRendererComponent( JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
setText((value == null) ? "" : value.toString());
return this;
class CenterRenderer extends DefaultTableCellRenderer
public CenterRenderer()
setHorizontalAlignment( CENTER );
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (hasFocus)
setBackground( Color.cyan );
else if (isSelected)
setBackground( table.getSelectionBackground() );
else
setBackground( table.getBackground() );
return this; -
Regarding Date format in output text file
Hi Frnds,
i am taking the data from vbak table into one internal table T_vbak, in that i am having vdatu field also, and after that using GUI_Download function module i am downloading that internal table data to one text file into presentation server.
But the date format is displaying in yyyymmdd format in the text file, but i want the format like mm/dd/yyyy in the text file, can anybody plz help me....Hey Bala,
You can use the following conversion routine for converting the date from yyyymmdd format into mm/dd/yyyy.
data: l_date(10) type c.
Loop at t_vbak into wa_vbak.
CONCATENATE wa_vbak-vdatu4(2) wa_vbak-vdatu6(2) wa_vbak-vdatu(4) INTO l_date SEPARATED BY '/'.
wa_vbak-vdatu = l_date.
modify t_vbak from wa_vbak.
Endloop.
Regards,
Chetan.
PS: Reward points if this helps. -
Creating idoc,downloading them in flat-files,sending them in zipped form
Hi Friends,
Presently I have a requirement regarding creation of WPDBBY idocs, downloading them in flat files and sending the files in zipped form to the user.
1. In the first program bonusbuy records have to be fetched which have been created/changed during the selection period. for every selected bonusbuy record transaction WPMA is executed which will create an WPDBBY Idoc for the Bonusbuy.
2. In the second program the idocs created are taken as input. first all deletion idocs are sorted. A deletion idoc can be recognized because it only has one segment (E1WPBB01) and in this segment the field AENDKENNZ equals DELE. For every idoc a file is created The name of this file is determined via the Logical file from the selection screen, with a sequence number. It is then saved. All files are zipped en send. After processing of the Idocs, the Idoc status is changed to u201818u2019.
If any of you have information about how to do this then pls tell me. I will definitely reward points for your heplful answers. Thanks!
Regards,
AbhishekHi,
For creating zip files and related processing use class cl_abap_zip.
You can check sample code at
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/dynamicTransformationofInternaltabledataintoXMLandCreatingaZIPFile
..very easy to use.
Regards,
Abhijit -
Hi. I tried to get data from my crio. I started my project with fpga wizard on the getting started window. I created target vi and host vi. In the host vi, I put "file dialog" function to create text data file but it doesn't pop up in the start-up. Can anyone tell me what's wrong with my vi's? I just want to get position and time data.
untitled 47 is my host vi
Attachments:
Quad Ctr.vi 1069 KB
Untitled 47.vi 366 KBStick to one thread for the same question.
http://forums.ni.com/t5/LabVIEW/can-not-create-text-file-in-fpga-mode/td-p/1406470 -
Hi,
I have 2 text file that should be statically outputted with specific parameters ,
what is the best way to do that?
RegardsTo get all the files present in a specific directory on the application server
REPORT ZSRK_045 .
TABLES EPSF.
PARAMETERS DIR LIKE EPSF-EPSDIRNAM DEFAULT 'D:\usr\sap\ERP\DVEBMGS00\work'.
"Give the app server directory name where u have stored the files
" go to AL11 tcode to check the directory name
DATA : FILECOUNTER LIKE EPSF-EPSFILSIZ,
ERRORCOUNTER LIKE EPSF-EPSFILSIZ,
DIRLIST TYPE TABLE OF EPSFILI WITH HEADER LINE.
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
DIR_NAME = DIR
FILE_MASK = ' '
IMPORTING
DIR_NAME = DIR
FILE_COUNTER = FILECOUNTER
ERROR_COUNTER = ERRORCOUNTER
TABLES
DIR_LIST = DIRLIST
EXCEPTIONS
INVALID_EPS_SUBDIR = 1
SAPGPARAM_FAILED = 2
BUILD_DIRECTORY_FAILED = 3
NO_AUTHORIZATION = 4
READ_DIRECTORY_FAILED = 5
TOO_MANY_READ_ERRORS = 6
EMPTY_DIRECTORY_LIST = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT DIRLIST.
WRITE : / DIRLIST-NAME, DIRLIST-SIZE.
ENDLOOP. -
Formatting of output text file.
I am writing values of variables to a text file. I also have column headings. Some of the column headings are long, perhaps 14 characters. The field for my variable values is only 8 characters long. Thus I would like to install a tab or two between my column headings so that they line up w my values. How may I do that?
You can specify a length with the format string.
So, if the longest string is 14 characters, specify %14s as the format string. Your text will be right justified. If you want the text to appear at the left, use a format specifier of %-14s.
Don't play around with multiple TABs, it will make the file difficult to read in other apps like Excel.
Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.
"You are what you don't automate"
Inplaceness is synonymous with insidiousness -
Align Columns? using Acrobat Pro 9 to create pdf from text file(s)
Hello,
Every time that I have tried to create a PDF from a text file, the columns dont align. The default Notepad setting I use to view a text file is Courier New which shows the columns aligned. How can I set defaults in Acrobat Pro 9 to have columns align?
ThanksBy definition a plain text file has no font, so it cannot be monospaced. Acrobat converts plain text using Times, this cannot be changed.
As TSN suggests to create a PDF from a text file with a specific choice of font and formatting you must print from another application. -
How to create a mapping with text file as my target
I need to create a mapping with source as a table and target as a text file.
I am using OWB 10g R2. with database Oracle10g.
Any one can help me to create a mapping with a text file as target.Hi,
just create a File-Location and File-definition and use this file-operator as target object inside your mapping.
Regards jwehner -
HELP ON HOW TO STORE OUTPUT IN TEXT FILE
Hello,
I am trying to output the results from queties into an output text file does anyone knows how to do that please?
For example i want to do :
Select SYSDATE from dual;
and output the result of it in a text file called output.txt does anyone knows how to do that please?
THanks a lot and every help is appreciated.
Regards,
giannisCan i set the path of the output file Yes, you can :
TEST@db102 SQL> spool /tmp/output.txt
TEST@db102 SQL> select sysdate from dual;
SYSDATE
14-JUN-06
TEST@db102 SQL> spool off
TEST@db102 SQL> !ls -ltr /tmp | tail -n 1
-rw-r--r-- 1 ora102 dba 313 Jun 14 01:52 output.txt
TEST@db102 SQL> !cat /tmp/output.txt
TEST@db102 SQL> select sysdate from dual;
SYSDATE
14-JUN-06
TEST@db102 SQL> spool off
TEST@db102 SQL> -
Hi Experts,
I need your HELP to include headings START_DATE, NUM_LOGS,MBYES,RSIZE in my text file "redo_history.log" below.
05-3-2009,36, 3600,100
05-4-2009,191, 19100,100
05-5-2009,56, 5600,100
06-1-2009,220, 22000,100
06-2-2009,245, 24500,100
06-3-2009,217, 21700,100
My desired output text file (redo_history.log) should be on below:
START_DATE, NUM_LOGS,MBYES,RSIZE
05-3-2009,36, 3600,100
05-4-2009,191, 19100,100
05-5-2009,56, 5600,100
06-1-2009,220, 22000,100
06-2-2009,245, 24500,100
06-3-2009,217, 21700,100
Im executing the following script below to generate text file named redo_history.log:
select dump_csv('SELECT Start_Date,
Num_Logs,
to_char(Round(Num_Logs * (Vl.Bytes / (1024 * 1024)),2),''999999999'') AS Mbytes,
Vl.Bytes / (1024*1024) AS RSize
FROM (SELECT To_Char(Vlh.First_Time,''MM-W-YYYY'') AS Start_Date,
COUNT(Vlh.Thread#) Num_Logs
FROM V$log_History Vlh
WHERE Vlh.First_Time > current_date - interval ''30'' day
GROUP BY To_Char(Vlh.First_Time,''MM-W-YYYY'')) log_hist,
( select distinct bytes from V$log ) Vl
ORDER BY Log_Hist.Start_Date',',','EXT_TABLES','redo_history.log')
from dual;
Please find below dump_csv.sql:
CREATE OR REPLACE function dump_csv( p_query in varchar2,
p_separator in varchar2
default ',',
P_DIR in varchar2 ,
p_filename in varchar2 )
return number
AUTHID CURRENT_USER
is
l_output utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(2000);
l_status integer;
l_colCnt number default 0;
l_separator varchar2(10) default '';
l_cnt number default 0;
begin
l_output := utl_file.fopen( P_DIR, p_filename, 'w' );
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
for i in 1 .. 255 loop
begin
dbms_sql.define_column( l_theCursor, i,
l_columnValue, 2000 );
l_colCnt := i;
exception
when others then
if ( sqlcode = -1007 ) then exit;
else
raise;
end if;
end;
end loop;
dbms_sql.define_column( l_theCursor, 1, l_columnValue,
2000 );
l_status := dbms_sql.execute(l_theCursor);
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
l_separator := '';
for i in 1 .. l_colCnt loop
dbms_sql.column_value( l_theCursor, i,
l_columnValue );
utl_file.put( l_output, l_separator ||
l_columnValue );
l_separator := p_separator;
end loop;
utl_file.new_line( l_output );
l_cnt := l_cnt+1;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
return l_cnt;
end dump_csv;
Thanks in advance for you HELP.
Regards,
Eddieow005731 wrote:
No, I am not asking how to know the column name.
I am questioning why go through all the hassles to determine the column names, while they are already known.
When the user prepares the query to pass on to dump_csv():
SELECT Start_Date,
Num_Logs,
to_char(Round(Num_Logs * (Vl.Bytes / (1024 * 1024)),2),''999999999'') AS Mbytes,
Vl.Bytes / (1024*1024) AS RSize
FROM ...
he obviously specifies/knows the column names. (It's not like he was doing select * ...)But what if he was doing select *? And why hard code column names for this query and then have to change them if the query changes when you can write it to be completely dynamic?
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10 -
hi,
I met a problem when I try to store data to text file. That's the description:
- To read some objects from the binary file
- To update object state, do some operations
- To output some properties of the object to text format file.
That's a part of my code:
{color:#0000ff}
//------ begin ---------//
// ".cluto" is a binary file where store the number of objects as the first object and a set of docVector object
File cluto = new File (config3.getOutputPath (), config3.getOutputFileType () + ".cluto");
ObjectInputStream reader1 = new ObjectInputStream (new BufferedInputStream (new FileInputStream (cluto), BUFFERSIZE));
// output text file definition
File rlabel = new File (config3.getOutputPath (), config3.getOutputFileType () + ".rlabel");
BufferedWriter rlabelWriter = new BufferedWriter (new FileWriter (rlabel), BUFFERSIZE);
// get the first object in ".cluto", the number of objects in the input binary file
Integer vectorNumber = (Integer)reader1.readObject ();
// temporal variable
docVector tVector;
for(int i=0; i<vectorNumber.intValue (); i++) {
tVector = (docVector)reader1.readObject ();
tVector.dimsPruning ();
tVector.updateDimsWeight (config1.getWEIGHT_TYPE ());
rlabelWriter.write (tVector.vectorLableToString ()); // tVector.vectorLabelToString() return a string!
reader1.close ();
rlabelWriter.flush ();
rlabelWriter.close ();
//------ end --------//
{color}
The program works and creates the file ".rlabel", but a binary file instead of text file! Anyone have ideas about this problem?
ThanksSorry, I means ".rlabel".
Good news, I fix the problem. In my old code, the I/O stream keeps always opened when I write huge data to the file (See "for" loop). And after the loop, I close the stream.
Now, I open and close the stream in each loop. The problem is resolved.
that's the new code:
// this function is used to write a string to a file
/* write a string to a file */
public void writeStringToFile (String content, String fileName) {
BufferedWriter writer = null;
try {
writer = new BufferedWriter (new FileWriter (fileName, true));
writer.write (content);
writer.close ();
} catch (IOException ex) {
ex.printStackTrace ();
String rlabel = "test.rlabel";
for(int i=0; i<vectorNumber.intValue (); i++) {
tVector = (docVector)reader1.readObject ();
tVector.dimsPruning (prunedTerm);
writeStringToFile (tVector.vectorLableToString (), rlabel);
//------- end ----------//
I don't know whether the open/close operations in a large loop cost a lot.
Thanks -
SQLCMD - getting the entire output to file?
Hi All
Ive written my first SQLCMD script using this reference :-
http://msdn.microsoft.com/en-us/library/ms162773.aspx
but in my output file I only get one line, whereas when I run the sql scripts manually from query analyser it shows (1 rows affected) multiple times down
the results window, how can i get these multiple rows of output to show in my output text file?
Thanks
StewHi ssssstew,
As Hasham has indicated, we might need to see your code. sqlcmd does not support multiple concurrent writings to the same file.
However, you might try this trick from Madhivanan at SQLServerCurry:
http://www.sqlservercurry.com/2011/11/sql-server-handling-multiple-result.html
Turn your query into a stored procedure:
create procedure test
as
select 1 as id, 'test1' as name
select 2 as id, 'test2' as name
When you execute this procedure, it returns two result sets. The following code will copy these two result sets in a table variable.
Then execute it and send the select * from that table to the output file instead:
declare @t table(id int, names varchar(100))
insert into @t
exec test
select * from @t ---output to file
Hope this helps
Maybe you are looking for
-
HT1661 Imac 2009 imac 2013 target mode did only work one time
My 2009 imac has a broken graphics card. The imac stats up as usual and is ok. To copy some files to my hew 2013 imac id use an thunderbolt to firewire adaptor. At the first attemp to start up in target mode, is did work very well. The target disk sh
-
TableModel with 'getRowClass()' instead of 'getColumnClass()'
Folks, I have a JTable with only a header and 2 rows. The first row should display String-info and the second should have checkboxes (Holds Boolean objects).. the problem is the TableModel interface only has a method for the column-class and that won
-
Solaris 10 with internet ?
Hello, I am Spanish. This after this translated of Spanish-to-English, maybe the translation be bad XD I have just to have just to install the solaris 10, this very well, but I do not manage to have internet. I use a coneccion Ethernet, I do not unde
-
Does anyone know of a way to lock access to adding/removing media to/from my iPod without a password? I know I can password lock the screen (effectively locking anyone from using my iPod without a password) but what about once it's plugged in? does a
-
Example scenarios for usage of scripting
Hi, sapian Can any of you give me some typical examples for usage of scripting in sap BODS except the sql statements.Like i need examples for error handling and for some other scenarios where i can use scripting. Please suggest me some scenarios