Output data to txt file with full length of the field as in database
Hi
I have a problem related to output data I ntxt file on server
for eg
CONCATENATE
wa_sagadr_outtab-seqno
wa_sagadr_outtab-bpext
wa_sagadr_outtab-name_org1
wa_sagadr_outtab-country INTO wa_sagadr_text SEPARATED BY ''.
the output is separated by single space irrespective of database length of the field , I want to display all the lenth of the database field eventhough the remaining space is blank ie if a field is 20 char in dtabase and only filled with 6 char the whole 20 char lenth should be displayed in the output file
ouput as below
required format ie space equvalent to as in database lenght
000001 700006 C4 Plant AMD Export Sdn.Bhd.so on.
my format as coming single space in between only
000001 700006 C4 Plant AMD Export Sdn.Bhd
pls suggest
For this maintain an work area with the fields and structure same as the one which you want.
ten populate the work are and write to file.
concatenate will not work.
e.g.
DATA: begin of wa_sagadr_text,
seqno like wa_sagadr_outtab-seqno,
bpext like wa_sagadr_outtab-bpext,
name_org1 like wa_sagadr_outtab-name_org1,
country like wa_sagadr_outtab-country
end of wa_sagadr_text,
clear wa_sagadr_text.
wa_sagadr_text-seqno = wa_sagadr_outtab-seqno.
wa_sagadr_text-bpext= wa_sagadr_outtab-bpext.
wa_sagadr_text-name_org1 = wa_sagadr_outtab-name_org1.
wa_sagadr_text-country = wa_sagadr_outtab-country INTO wa_sagadr_text.
transfer wa_sagadr_text to outputfile
or write:/ your fields.
Similar Messages
-
Pulling output data from .txt file
Hello, I am trying to have a program that allows a user to input shopping items into the program andhave that input go to a .txt file called shoppinglist, then after the user is finished, he/she can type no to stop entering items to the list and the program will then pull all the info entered to the .txt file and output it to the screen, creating a shooping list for the user. My problem is that I am not quite sure how to output the data from the .txt file to the screen. Here is my code.
import java.io.*; // uses the java io library for the
import java.util.*; // BufferedReader class
public class week5
public static void main(String [] args)
PrintWriter inputItems = null;
try
inputItems = new PrintWriter(new FileOutputStream("shoppinglist.txt"));
BufferedReader outputItems = null;
String line = null;
outputItems = new BufferedReader(new FileReader("shoppinglist.txt"));
line = outputItems.readLine();
outputItems.close();
catch(FileNotFoundException e)
System.out.println("File file.txt not found");
System.out.println("or could not be opened.");
catch(IOException e)
System.out.println("Error reading from file file.txt.");
System.out.println("This program will create a shopping list:");
String keepGoing = "yes";
String item = null;
Scanner keyboard = new Scanner(System.in);
for (int count = 1; count < 999 && keepGoing.equalsIgnoreCase("yes");count++)
//ask for input, write it to a file
System.out.print("Please enter item # " + count + ": ");
System.out.print("");
item = keyboard.nextLine();
inputItems.println(count + " " + item);
//ask if you want to keep going
System.out.print("Do you wish to enter more items (yes/no): ");
System.out.print("");
keepGoing = keyboard.nextLine();
System.out.println("Your shopping list contains: " + item);
System.out.print("");
inputItems.close();
} All the above does is output the last item entered by the user, not the whole shopping list. Any help is greatly appreciated.nim_ramesh wrote:
outputItems = new BufferedReader(new FileReader("shoppinglist.txt"));
/* I think u want to print the text here so */
line = outputItems.readLine(); // Replace this line with that while loop
outputItems.close();
He hasn't even read the user input at that point.
OP, you need to sit down and think about the exact order you want to do things in, and rewrite your code in a logical straightforward manner. It looks like you just threw some code in hoping it would work, instead of coding deliberately. I'm not insulting you or anything, I know you're new to Java. I'm just trying to give you some advice. Look at your code, and ask yourself why the following line of code appears before you've even written anything to your file:
line = outputItems.readLine(); -
Write data to .txt file with formatting
Hi,
I am trying to read data from serial port and write it on to a .txt file. I am able to write onto the file but it has got no formatting. What I would ideally like to do is, read the data from serial port, take only some parts of it and write on to the text file with proper formatting. Also, I would like to use the same file to append data each time. I am also having issues setting the pointer to EOF. I would like to append to end of file.
This is my sample data
18:33:23 02/10/10 28.32 0 LAC 0.378 mg/dL 0000\
18:33:23 02/10/10 28.32 0 GLU 102 mg/dL 0000
that is being read from the serial port. From this I would like to take only columns 1,2,3,5,6 and write onto the .txt file.
Can someone provide some pointers? I'm using Labview 6.1
Thanks,
SukanyaIf you know what "charecters" you don't want it is pretty easy. A little more difficult when they are unwanted only in certain places in the string. There is a remove whitespace function in the string functions palette. There is also a search and replace function in the "additional string functions" subpalette, that can be set up to find all instances of a char and replace it with something else, an empty string if you want to just delete it/them from your string.
Putnam
Certified LabVIEW Developer
Senior Test Engineer
Currently using LV 6.1-LabVIEW 2012, RT8.5
LabVIEW Champion -
Import data from txt-file with reading column names
Hello,
after changing the the export of my simulation programm I can't use the solution postet here, wich works well. (I branded the post as soluted thats why I start a ne post)
Can anybode please tell me how to adept the code to import the new type of txt file. Here the name of the columns are in the first line aof the columns, like this (with ignoring the first lines).
"TIME " "Sitzbasis_X" "Sitzbasis_Y" "Sitzbasis_Z" "Achsklammer_Z" "Antriebsachse_Z" "Gegengewicht_Z" "Lenkachse_Z"
0.000000e+000 -5.472285e+003 -1.886681e+002 1.812099e+004 4.539113e+004 -1.252936e+005 -1.499764e+004 -9.806650e+003
1.000000e-003 -1.722846e+003 -1.141275e+002 8.443419e+003 2.475389e+004 -7.533712e+004 -1.138092e+004 -9.624729e+003
2.000000e-003 -3.964053e+002 -7.694600e+001 3.186345e+003 1.399086e+004 -5.653730e+004 -9.956198e+003 -9.311346e+003
I added an example file
Thanks for Help
Gabriel
Solved!
Go to Solution.
Attachments:
TXT-File.txt 115 KBHello Gabriel
You can use the DataPlugin Wizard (Navigator>>File>>DataPlugin Wizard) to define a new file import filter for your data. It will take only one minute.
Please found the uri file I create for you. Copy the attached file to your disk, unpack it and double click the uri file.
Then you can open your file by using "open with".
Hope this help
Attachments:
TXT_File_DataPlugin.zip 4 KB -
Output Data to CSV File with headers
So I'm trying to create a powershell script that outputs a list of computers with their default printers. Here's what I have to far:
cls
$obj = New-Object PSObject
$ComputerList = Import-CSV C:\test\PCList.csv
ForEach ($Computer in $ComputerList)
$DefaultPrinter = Get-WmiObject -Query "select * from Win32_Printer where Default=True"
$DefaultPrinterName = $DefaultPrinter.ShareName
$obj | Add-Member WorkstationName $Computer.Name -Force
$obj | Add-Member DefaultPrinter $DefaultPrinterName -Force
Write-Output -InputObject $obj | Out-File -FilePath C:\test\PCList_defaultprinter.csv -Append
It's not formatting the CSV in a workable format. What I'd like is to have 2 columns (Workstation Name and Default Printer Name) but it's not exactly doing that.
Any help would be greatly appreciated!!!Use Export-CSV instead of Out-File, as in:
cls
$obj = New-Object PSObject
$ComputerList = Import-CSV C:\test\PCList.csv
ForEach ($Computer in $ComputerList)
$DefaultPrinter = Get-WmiObject -Query "select * from Win32_Printer where Default=True"
$DefaultPrinterName = $DefaultPrinter.ShareName
$obj | Add-Member WorkstationName $Computer.Name -Force
$obj | Add-Member DefaultPrinter $DefaultPrinterName -Force
$obj | Export-Csv -Path C:\test\PCList_defaultprinter.csv -NoTypeInformation -Append
Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx -
Export Excel Table in .txt File with space delimited text in UNICODE Format
Hi all
I've a big unsolved problem: I would like to convert an Excel table with some laboratory data in it (descriptions as text, numbers, variables with some GREEK LETTERS, ...). The output should be a formatted text with a clear structure. A very good solution is
given by the converter in Excel "Save As" .prn File. All works fine, the formattation is perfect (it does not matter if some parts are cutted because are too long), but unfortunately the greek letters are converted into "?"!!!
I've tried to convert my .xlsx File in .txt File with formatting Unicode and the greek letters are still there! But in this case the format is not good, the structure of a table is gone!
Do you know how to save an Excel file in .prn but with Unicode formatting instead of ANSI or a .txt with space delimited text?
Thanks a lot to everyone that can help me!
M.L.C.This solution works in Excel/Access 2013.
Link the Excel table into Access.
In Access, right-click the linked table in the Navigation Pane, point your mouse cursor to "Export", and then choose "Text File" in the sub-menu.
Name the file, and then under "Specify export options", check "Export data with formatting and layout". Click "OK".
Choose either Unicode or Unicode (UTF-8) encoding. Click "OK".
Click "Close" to complete the export operation. -
How to create an UTF8 data file with max length fields
We have a legacy application which allows for a transparent text field a maximum length of 30 Bytes.
The DB-Length of the field is 40 Chars.
In old NUC days it was so simple:
TYPES: BEGIN OF t_items,
hwmc(30) TYPE C,
A move, that was it.
Now we have migrated to unicode, use UTF8 for the external data and are puzzeling over how to create an output field with a fixed length of 30 Bytes.
Has somebody an elegant idea?wyfwong, >> Does the schema which stores a large BLOB column has to create a large tablespace in order to store the column value or the database automatically enlarge the tablespace when a large BLOB column is loaded into the table? <<
The answer to this question would depend on how you defined the tablespace adn datafiles used to store the tablespace objects to begin with: raw partitions verse files, autoextend on or off, etc....
It would seem to me to be foolish not to predefine the tablespace at least large enough to hold the tables and indexes based on their expected near_term data loads. That is, if you know the initial load of data will be 60G then the tablespace should be larger than 60G to start with.
HTH -- Mark D Powell -- -
Interface output file : tab limited vs flat file with fixed length
hey guys,
any idea on difference b/w to file type : flat file with fixed length or tab limited file
thanksTab Delimited:
Two Field are seperated by a TAB
eg. SANJAY SINGH
First field is First Name and Second is Sir Name.
Nth field will be after N -1 tab
Fixed Length:
Every field has a fixed starting position and length
eg. SANJAY SINGH
Here First field start from Position 1 and has lenght 10 and 2nd field start from 11th postion and has lenght 10.
Fixed Length -> The lenght of each field is fixed, while in tab delimited the lenght of field is not fixed but we know it ends when the Seperatot (Tab) is encountered. -
Java.io.NotSerializableException when overwrite the JTable data into .txt file
hi everyone
this is my first time to get help from sun forums
i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
At the beginning, the code will be generate successfully and the jtable will be showing out with the data that been save in the studio1.txt previously,
but after i edit the data at the JTable, and when i trying to click the save button, the error had been showing out and i cannot succeed to save the JTable with the latest data.
After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
I hope i can get any solution at here and this will be very useful for me.
the following is my code...some of it i create it with the GUI netbean
but i dunno how to attach my .txt file with this forum
did anyone need the .txt file?
this is the code that suspect maybe some error here
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String filename = "studio1.txt";
try {
FileOutputStream fos = new FileOutputStream(new File(filename));
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(jTable2);
oos.close();
catch(IOException e) {
System.out.println("Problem creating table file: " + e);
return;
System.out.println("JTable correctly saved to file " + filename);
}the full code will be at the next msgthis is the part 1 of the code
this is the full code...i had /*....*/ some of it to make it easier for reading
package gui;
import javax.swing.*;
import java.io.*;
public class timetables extends javax.swing.JFrame {
public timetables() {
initComponents();
@SuppressWarnings("unchecked")
private void initComponents() {
jDialog1 = new javax.swing.JDialog();
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
buttonGroup3 = new javax.swing.ButtonGroup();
buttonGroup4 = new javax.swing.ButtonGroup();
jTextField1 = new javax.swing.JTextField();
jLayeredPane1 = new javax.swing.JLayeredPane();
jLabel6 = new javax.swing.JLabel();
jTabbedPane1 = new javax.swing.JTabbedPane();
jScrollPane3 = new javax.swing.JScrollPane();
jTable2 = new javax.swing.JTable();
jScrollPane4 = new javax.swing.JScrollPane();
jTable3 = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
/* org.jdesktop.layout.GroupLayout jDialog1Layout = new org.jdesktop.layout.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 400, Short.MAX_VALUE)
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 300, Short.MAX_VALUE)
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
String filename1 = "studio1.txt";
try {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
jTable2 = (JTable) ois.readObject();
System.out.println("reading for " + filename1);
catch(Exception e) {
System.out.println("Problem reading back table from file: " + filename1);
return;
try {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
jTable3 = (JTable) ois.readObject();
System.out.println("reading for " + filename1);
catch(Exception e) {
System.out.println("Problem reading back table from file: " + filename1);
return;
jTable2.setRowHeight(20);
jTable3.setRowHeight(20);
jScrollPane3.setViewportView(jTable2);
jScrollPane4.setViewportView(jTable3);
jTable2.getColumnModel().getColumn(4).setResizable(false);
jTable3.getColumnModel().getColumn(4).setResizable(false);
jTabbedPane1.addTab("STUDIO 1", jScrollPane3);
jTabbedPane1.addTab("STUDIO 2", jScrollPane4);
jTextField1.setText("again n again");
jLabel6.setText("jLabel5");
jLabel6.setBounds(0, 0, -1, -1);
jButton2.setText("jButton2");
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
-
How to output data to a file in SCC-SG04?
I am using SCC-2345 with SCC-SG04 connected to NI-6221 in Windows 2000 in VC6.
How to output data to a file like data1.dat in VC6 or in Labwindows/CVI?Hello mwibm,
If you just want to do file input/output in LabWindows/CVI, I would take a look at the Formatting and I/O CVI library or the ANSI File I/O functions. For example, if you just want to write an array of data to a file, I would look at the ArrayToFile function or the fwrite/fputs/fprintf ANSI C functions included in stdio.h. The ANSI C functions will also work in Visual Studio. More information on the LabWindows/CVI File I/O functions can be found in CVI help, and more information on ANSI C functions can be found in CVI Help and online at various websites.
Maybe you could further clarify what problems you are having and what kind of data you want to write to a file.
Thanks.
Wendy L
LabWindows/CVI Developer Newsletter - ni.com/cvinews -
I want to save data to txt file on as ,how can do it ?
hi~everyone
i have some data in inner table ,i wantto save the data into TXT file on AS, then i download the file from AS,how can come true it ?who can give me some demo or cues ,thank you very much!
Message was edited by:
deqiang zhangCheck the example program using GUI_DOWNLOAD and it may help you
report zan_guidownload no standard page heading.
tables : vttk.
data : begin of i_vttk occurs 0,
tknum like vttk-tknum,
shtyp like vttk-shtyp,
end of i_vttk.
data : begin of i_down occurs 0,
fld(255) type c,
end of i_down.
start-of-selection.
select tknum shtyp from vttk into table i_vttk.
end-of-selection.
loop at i_vttk.
concatenate i_vttk-tknum ',' i_vttk into i_down.
endloop.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = 'C:\down.xls'
filetype = 'ASC'
append = 'X'
write_field_separator = ','
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = i_vttk
FIELDNAMES =
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
OTHERS = 22
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Thanks
Seshu -
how to get all how to get all paragraphs style and their fonts of a indesign file and write all info with para info into txt file with scriptingstyle and their fonts of a indesign file and write all info with para info into txt file with scripting
I write the script this one works
var par=doc.stories.everyItem().paragraphs.everyItem().getElements();
for(var i=par.length-1;i>=0;i--)
var font=par[i].appliedParagraphStyle.name;
var font1=par[i].appliedFont.name;
var size=par[i].pointSize;
WriteToFile (par[i].contents + "\r" + "Style : " + font + "\r" + "FONT1 : " + font1 + "\r" + "Size : " + size + "\r", reportFilePath);
function WriteToFile(text, reportFilePath) {
file = new File(reportFilePath);
file.encoding = "UTF-8";
if (file.exists) {
file.open("e");
file.seek(0, 2);
else {
file.open("w");
file.writeln(text);
file.close();
Thanks for all your support -
How to store a data on txt file through java program
that means i want a coding for write data on txt file using java program.that storing data is stored like this formate,
sathees
krishnan
rama
suresh
Stored on one by one. not like this
sathees krishnan rama suresh.........import java.io.*;
import org.w3c.dom.Document;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class rsk1{
public static void main (String argv []){
try {
String sr[] = new String[100];
String s1=" ";
int j=0;
DataInputStream in = new DataInputStream(System.in);
OutputStream f1 = new FileOutputStream("file1.txt");
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File("book.xml"));
// normalize text representation
doc.getDocumentElement ().normalize ();
System.out.println ("Root element of the doc is " +
doc.getDocumentElement().getNodeName());
NodeList listOfPersons = doc.getElementsByTagName("person");
int totalPersons = listOfPersons.getLength();
System.out.println("Total no of people : " + totalPersons);
for(int s=0; s<listOfPersons.getLength() ; s++){
Node firstPersonNode = listOfPersons.item(s);
if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){
Element firstPersonElement = (Element)firstPersonNode;
NodeList firstNameList = firstPersonElement.getElementsByTagName("first");
Element firstNameElement = (Element)firstNameList.item(0);
NodeList textFNList = firstNameElement.getChildNodes();
sr[++j]=((Node)textFNList.item(0)).getNodeValue().trim();
NodeList lastNameList = firstPersonElement.getElementsByTagName("last");
Element lastNameElement = (Element)lastNameList.item(0);
NodeList textLNList = lastNameElement.getChildNodes();
sr[++j]=((Node)textLNList.item(0)).getNodeValue().trim();
NodeList ageList = firstPersonElement.getElementsByTagName("age");
Element ageElement = (Element)ageList.item(0);
NodeList textAgeList = ageElement.getChildNodes();
sr[++j]=((Node)textAgeList.item(0)).getNodeValue().trim();
NodeList stuList = firstPersonElement.getElementsByTagName("stu");
Element stuElement = (Element)stuList.item(0);
NodeList textstuList = stuElement.getChildNodes();
sr[++j]=((Node)textstuList.item(0)).getNodeValue().trim();
}//end of if clause
}//end of for loop with s var
System.out.println("Process completed");
for(int i=1;i<=j;i++)
byte buf[] = sr.getBytes();
byte buf1[] = s1.getBytes();
f1.write(buf);
f1.write(buf1);
f1.close();
}catch (SAXParseException err) {
System.out.println ("** Parsing error" + ", line "
+ err.getLineNumber () + ", uri " + err.getSystemId ());
System.out.println(" " + err.getMessage ());
}catch (SAXException e) {
Exception x = e.getException ();
((x == null) ? e : x).printStackTrace ();
}catch (Throwable t) {
t.printStackTrace ();
}//end of main -
Can TXT file with separater ',' be upload to internal TBL using GUI_UPLOAD?
hello, experts,
I have a problem with data transfer. I need to upload TXT file to SAP internal table, data in TXT file are separated by ',' and more than one line records are contained in the file. I tried to use FM GUI_UPLOAD as below to upload the file and transfer the data to internal table, however it comes out error. SY-SUBRC is UNKNOW ERROR, error message shows: Cannot interpret date in file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILEPATH
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = ','
READ_BY_LINE = 'X'
TABLES
DATA_TAB = TAB_X3
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
Thank you.HAS_field_separator can have only SPACE or X.
upload the file using GUI_UPLOAD and then in the program you split the lines by comma.
Data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
DATA: begin of itab1 occurs 0,
matnr type mara-matnr
werks type marc-werks
lgort type marc-lgort,
end of itab1.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILEPATH
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
READ_BY_LINE = 'X'
TABLES
DATA_TAB = TAB_X3
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
loop at itab.
split itab-rec at ',' into itab1-matnr itab1-werks itab1-lgort.
append itab1.
endloop. -
How to read the second line in a .txt file with bufferedReader?
hi,
i am not the best in speaking english and programming java :)
so, just try to make sense of my question:
Im using a BufferedReader to read a .txt file.
the .txt file has 5+ different lines, and each line has 6 tokens (separated with ; )
My java file has 6 textFields and each textfield is filled with one of the 6 different tokens.
and my problem is:
I want my buffered reader to read the next line (with 6 new different tokens) by pressing a button.
if somethings not understandable, just ask :)maybe its easier to help me, when i publish my code, so here it is:
(its my version, without Thof's code. Sorry, but the comments are the most in german)
/* userdata.java */
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
public class userdata extends Frame {
//-----------------------------------KlassenVariablen------------------------------------------------
private JPanel panel = new JPanel ();
String tokId = "";
String tokName= "";
String tokAge= "";
String tokTel= "";
String tokMail= "";
String tokText= "";
BufferedReader br;
String zeile;
StringTokenizer st;
String delim = ";";
//---------Buttons f?r Panel 1-------------------------
Button first = new Button("|< First");
Button back = new Button("< Back");
Button next = new Button("Next >");
Button last = new Button("Last >|");
//---------Buttons f?r Panel 3-------------------------
Button neu = new Button("New");
Button safe = new Button("Safe");
Button refresh = new Button("Refresh");
//--------Labels f?r Panel 2-----------------------------
Label lid = new Label("ID",Label.LEFT);
Label lname = new Label("Name",Label.LEFT);
Label lage = new Label("Age",Label.LEFT);
Label ltel = new Label("Tel.",Label.LEFT);
Label lmail = new Label("E-Mail",Label.LEFT);
Label ltext = new Label("Spruch",Label.LEFT);
Label lub = new Label("Last Button",Label.LEFT);
TextField id = new TextField();
TextField name = new TextField();
TextField age = new TextField();
TextField tel = new TextField();
TextField mail = new TextField();
TextField text = new TextField();
TextField usedbutton = new TextField();
//--------ActionEvent bla sachen eben--------------------
public static void main (String[] args) throws IOException {
userdata wnd = new userdata();
wnd.setVisible(true);
public userdata() throws IOException {
//--------------------------------Layout mit panel bestimmung--------------------------------------
setLayout(new BorderLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
add(BorderLayout.NORTH ,p1);
add(BorderLayout.CENTER , p2);
add(BorderLayout.SOUTH , p3);
//-------------------------------Funktionslose Buttons in PANEL 1------------------------------------
p1.add(first);
p1.add(back);
p1.add(next);
p1.add(last);
p1.add(usedbutton);
//--------------------------------Funktionierende Textfelder in PANEL 2------------------------------
Panel labelpanel = new Panel();
p2.setLayout(new GridLayout(7,3));
p2.add(lid);
p2.add(id);
p2.add(lname);
p2.add(name);
p2.add(lage);
p2.add(age);
p2.add(ltel);
p2.add(tel);
p2.add(lmail);
p2.add(mail);
p2.add(ltext);
p2.add(text);
p2.add(lub);
p2.add(usedbutton);
//--------------------------------------Buttons in PANEL 3-----------------------------------------
p3.add(neu);
p3.add(safe);
p3.add(refresh);
//--------------------------------BufferedReader -------------------------------------------------
readData();
//--------------------------------Panel 2 TextField-----------------------------------------------
fillForm();
//================================ActionPerformed==================================================
first.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("First");
usedbutton.setText("First");
back.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Back");
usedbutton.setText("Back");
next.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Next");
usedbutton.setText("Next");
last.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Last");
usedbutton.setText("Last");
neu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("New entry");
usedbutton.setText("New");
safe.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Now Saving, do not turn off!");
usedbutton.setText("Save");
//-----------------refresh
refresh.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
try{
readData();
}catch( IOException ioe){
System.out.println("Fehler beim lesen aus Datei");
fillForm();
usedbutton.setText("Refresh");
//=============================================================================Button Funktionen!!!
pack();
//--------------------------------WindowsListener hinzuf?gene--------------------------------------
addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent event)
setVisible(false);
dispose();
System.exit(0);
//-----------------------------------readData() - > Buffered Reader in aktion! --------------------
private void readData() throws IOException{
BufferedReader br = new BufferedReader(new FileReader("My .txt File with path"));
String zeile;
StringTokenizer st;
String delim = ";";
zeile = br.readLine();
st = new StringTokenizer(zeile, delim);
st.hasMoreTokens();
//System.out.println (st.nextToken());
tokId = new String(st.nextToken());
tokName = new String (st.nextToken());
tokAge = new String (st.nextToken());
tokTel = new String (st.nextToken());
tokMail = new String (st.nextToken());
tokText = new String (st.nextToken());
//--------------------------fillForm() - > f?llt die TextFelder aus!--------------------------------
private void fillForm(){
id.setText(tokId);
name.setText(tokName);
age.setText(tokAge);
tel.setText(tokTel);
mail.setText(tokMail);
text.setText(tokText);
}
Maybe you are looking for
-
I want to set up Firefox to only allow certain pages to load - how do I do this?
My children are having my old laptop and I dont want them to be able to 'stumble' across anything unsuitable. How can I set up Firefox so that it only allows pages to load from websites I choose? Thanx!
-
Is B2B document editor necessary in SOA suite 11g environment?
Hi All, In my server, SOA suite 11g is installed, which include B2B engine also.For devoloping a POC in B2B environment, document editor is necessary or not?. Without document editor, is it posible to devolop a simple POC? I am completely new to this
-
Hi, I am trying to understand how to access an SQL database from CVI. I don't understand how the sample programs shipped with the toolkit can access the database they use if it is not listed in the ODBC Data Source Administrator. In the code, I
-
Airport Card (Powerbook) not seeing network after Update
Using software update, I updated the Airport file. Somehow it seems to have knobbled my airport card and which now wont recognise my netgear dg834gt modem. I've been trying to fix this for two days now. grrr. Is this update for Base stations and Expr
-
Upgraded to IOS 8 and restore to factory default and now get error trying to restore
I was told to restore Ipod Touch 5th G to Factory defaults to check mic problem. I performed backup which seemed to work fine and forced to install update to IOS 8. Did the Restore to factory default which seemed to work without a problem. Now when I