How to save data from text file in databse for a transaction...
Hi Guys,
I have a text file which has some data related relevant to transaction VA01 separated by tabs.
Now instead of going in the transaction in VA01 and thne feeding the data manually, I would like this data
to get read automatically from the text file and get processed field by field for transaction VA01 and thne get saved.
How do I achieve this ? Do I have to use SHDB or some other method ?a
hi tushar,
REPORT ZCALL_TRANS_TAB1 .
TABLES: LFA1,LFBK,lfb1.
*& internal table declaration
data: BEGIN OF it_vendor occurs 0,
LIFNR LIKE LFA1-LIFNR,
bukrs like lfb1-bukrs,
END OF it_vendor.
DATA: BEGIN OF IT_BANK occurs 0,
LIFNR LIKE LFA1-LIFNR,
BANKS LIKE LFBK-BANKS,
BANKL LIKE LFBK-BANKL,
BANKN LIKE LFBK-BANKN,
koinh like lfbk-koinh,
END OF IT_BANK.
data: it_bdcdata like bdcdata occurs 0 with header line.
data: it_messages like bdcmsgcoll occurs 0 with header line.
*selection screen.
selection-screen: begin of block b1 with frame.
parameters: p_file like rlgrap-filename default 'c:/vendor.txt'
obligatory.
parameters: p_file1 like rlgrap-filename default 'c:/xyz.txt'
obligatory.
selection-screen: end of block b1.
*at selection screen.
at selection-screen on value-request for p_file.
perform f4_help using p_file.
at selection-screen on value-request for p_file1.
perform f4_help1 using p_file1.
*start of selection
start-of-selection.
*******uploading file
perform upload_file using p_file P_FILE1.
******open session.
perform populate_data.
*& Form f4_help
text
-->P_P_FILE text
form f4_help using p_p_file.
data: l_file type ibipparms-path.
call function 'F4_FILENAME'
importing
file_name = l_file.
p_file = l_file.
endform. " f4_help
*& Form POPULATE_DATA
text
--> p1 text
<-- p2 text
form populate_data .
DATA: L_STRING TYPE STRing.
DATA: L_COUNTER(2) TYPE n.
loop at it_vendor.
perform bdc_dynpro using 'SAPMF02K' '0106'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-D0130'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
it_vendor-lifnr.
perform bdc_field using 'RF02K-BUKRS'
it_vendor-bukrs.
perform bdc_field using 'RF02K-D0130'
'X'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-bankn(03)'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
******CALL TRANSACTION.
call transaction 'FK02' using it_bdcdata mode 'A'
messages into it_messages.
write:/ sy-subrc.
perform format_messages.
clear it_bdcdata.
refresh it_bdcdata.
endloop.
endform. " POPULATE_DATA
*& Form FORMAT_MESSAGES
text
--> p1 text
<-- p2 text
form format_messages .
data: l_msg(100).
loop at it_messages.
call function 'FORMAT_MESSAGE'
exporting
id = it_messages-msgid
lang = sy-langu
no = it_messages-msgnr
v1 = it_messages-msgv1
v2 = it_messages-msgv2
v3 = it_messages-msgv3
v4 = it_messages-msgv4
importing
msg = l_msg
exceptions
not_found = 1
others = 2
write:/ l_msg.
endloop.
endform. " FORMAT_MESSAGES
*& Form bdc_dynpro
text
-->P_0173 text
-->P_0174 text
form bdc_dynpro using value(p_program)
value(p_screen).
it_bdcdata-program = p_program.
it_bdcdata-dynpro = p_screen.
it_bdcdata-dynbegin = 'X'.
append it_bdcdata.
clear it_bdcdata.
endform. " bdc_dynpro
*& Form bdc_field
text
-->P_0178 text
-->P_0179 text
form bdc_field using value(p_fnam)
value(p_fval).
it_bdcdata-fnam = p_fnam.
it_bdcdata-fval = p_fval.
append it_bdcdata.
clear it_bdcdata.
endform. " bdc_field
*& Form upload_file
text
-->P_P_FILE text
-->P_P_FILE1 text
form upload_file using p_p_file
p_p_file1.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = P_P_FILE
FILETYPE = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = IT_VENDOR
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
NO_AUTHORITY = 10
OTHERS = 11
IF sy-subrc <> 0.
MESSAGE I000(ZZ) WITH 'UNABLE TO UPLOAD'.
STOP.
ENDIF.
*******UPLOADING BANK DETAILS
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = P_P_FILE1
FILETYPE = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = IT_BANK
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
NO_AUTHORITY = 10
OTHERS = 11
IF sy-subrc <> 0.
MESSAGE I000(ZZ) WITH 'UNABLE TO UPLOAD'.
STOP.
ENDIF.
endform. " upload_file
*& Form f4_help1
form f4_help1 using p_p_file1.
data:l_file1 type ibipparms-path.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = l_file1.
p_file1 = l_file1.
endform. " f4_help1
Similar Messages
-
How to extract data from text file to database table
Hi ,
I am trying to upload data in text file to database table using GUI_UPLOAD function .what would be the program for that.
thanks in advance.Hi,
I don't think you have a standard sap program to upload data from file to database table...
Instead you can create a custom program like this..
DATA: T_FILEDATA(1000) OCCURS 0 WITH HEADER LINE.
DATA: T_ZTABLE LIKE ZTABLE OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEST.TXT'
tables
data_tab = T_FILEDATA
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.
LOOP AT T_FILEDATA.
T_ZTABLE = T_FILEDATA.
APPEND T_ZTABLE.
ENDLOOP.
MODIFY ZTABLE FROM TABLE T_ZTABLE.
COMMIT WORK..
Thanks,
Naren -
How to put data (from texte file) in the Tab
Hi,
I have a file with one line data.
I want to put the data in a tab with 5 colums and x line.
I attach a example.
Thank's
Attachments:
ni-help.zip 9 KBYou need to modify the input parameters in the Spreadsheet Sheet String to Array. For the delimeter, you need to specify a space. By default, the function uses a tab as a delimiter.
-
Cant get data from text file to print into Jtable
Instead of doing JDBC i am using text file as database. I cant get data from text file to print into JTable when i click find button. Goal is to find a record and print that record only, but for now i am trying to print all the records. Once i get that i will change my code to search desired record and print it. when i click the find button nothing happens. Can you please take a look at my code, dbTest() method. thanks.
void dbTest() {
DataInputStream dis = null;
String dbRecord = null;
String hold;
try {
File f = new File("customer.txt");
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
Vector dataVector = new Vector();
Vector headVector = new Vector(2);
Vector row = new Vector();
// read the record of the text database
while ( (dbRecord = dis.readLine()) != null) {
StringTokenizer st = new StringTokenizer(dbRecord, ",");
while (st.hasMoreTokens()) {
row.addElement(st.nextToken());
System.out.println("Inside nested loop: " + row);
System.out.println("inside loop: " + row);
dataVector.addElement(row);
System.out.println("outside loop: " + row);
headVector.addElement("Title");
headVector.addElement("Type");
dataTable = new JTable(dataVector, headVector);
dataTableScrollPane.setViewportView(dataTable);
} catch (IOException e) {
// catch io errors from FileInputStream or readLine()
System.out.println("Uh oh, got an IOException error!" + e.getMessage());
} finally {
// if the file opened okay, make sure we close it
if (dis != null) {
try {
dis.close();
} catch (IOException ioe) {
} // end if
} // end finally
} // end dbTestHere's a thread that loads a text file into a JTable:
http://forum.java.sun.com/thread.jsp?forum=57&thread=315172
And my reply in this thread shows how you can use a text file as a simple database:
http://forum.java.sun.com/thread.jsp?forum=31&thread=342380 -
How to read data from a file that was formatted by excel?
Hi everyone, I'm familiar with java.io and the ability to read from files, can anyone tell me how to read data from a file that was formatted by excel? Or at least give me some web references so that I can learn about it?
http://jakarta.apache.org/poi/hssf/index.html
HSSF stands for Horrible Spreadsheet Format, but it still works! -
How to extract data from XML file with JavaScript
HI All
I am new to this group.
Can anybody help me regarding XML.
I want to know How to extract data from XML file with JavaScript.
And also how to use API for XML
regards
NagarajuThis is a Java forum.
JavaScript is something entirely different than Java, even though the names are similar.
Try another website with forums about JavaScript.
For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3 -
How to write data to text file using external tables
can anybody tell how to write data to text file using external tables concept?
Hi,
Using external table u can load the data in your local table in database,
then using your local db table and UTL_FILE pacakge u can wrrite data to text file
external table
~~~~~~~~~~~
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2153251
UTL_FILE
~~~~~~~~~
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#sthref14093
Message was edited by:
Nicloei W
Message was edited by:
Nicloei W -
How to insert data from *.dmp file to oracle 11g using Oracle SQL Develope
hi
i backup my database using PL/SQL developer and made *.dmp file
how to insert data from *.dmp file to oracle 11g using Oracle SQL Developer 2.1.1.64
and how to make *.dmp file from sql*plus ?
thanks in advancePl/Sql developer has a config window, there you choose the exec to do the import/export.
Find it and his home version, it may be exp or expdp, the home version is the version of the client where the exp executable is.
Then use the same version of imp or impdp to execute the import, you do not need to use Oracle SQL Developer 2.1.1.64. If you want to use it, you must have the same version in the oracle home that exp/imp of sql developer use. -
How to delete data from a file using IO package
Hi All,
i am trying to remove some content of the file.
this content is not at starting of file not even at end of file.
can anybody tell me how can i delete number of lines from file using IO package.iam having some data in text file .ex:in flowrist.txt
12/5/07,500,300,6000 like many set of datas are
there.In these if i want to delete the data based on
the date which i specified.How to do this specific
deletion?You need to open a stream to read in the file and then use the indexOf method provided in the Sting class to check if the line contains the date or whatever String you are looking for, if so then skip that line and store or re-write the lines you wish to keep, as well as some extra lines you may wish to add.
Take a look below at this example found on Google.
http://www.java-tips.org/java-se-tips/java.io/how-to-read-file-in-java.html
The above read a file line by line and prints it to console. You should be able to modify this, instead of using System.out to print the line you should use index of to check the lines for a date/String. Index of return -1 if the String you specify is not in the line you parse. -
Loading data from text file into ListBox
I have data in a text file that I want to load into a
listbox... I have fully mastered handling strings and arrays so I'm
going to need some help...
I was wondering how do I get flash to load a text file that
contains the data below.. and display it line for line like I want
it to list down the component
"Launch;7.1.7.6"
"Engine;7.1.7.6"
"OSX;7.0.0.2" (or something close to that)
and I was wondering how do i just get it to take it fromt he
file.. line for line from where it says exeversion in the file and
list it in the listbox...
I'm really thankful to anybody that helps.
Data in text file:
quote:
exeversion=Launch;7.1.7.6;
exeversion=Engine;7.1.7.6;
exeversion=LinuxX86;7.0.0.2;
exeversion=LinuxPPC;7.0.0.2;
exeversion=LinuxMIPS;7.0.0.2;
exeversion=OSX;7.0.0.2;
exeversion=Config;7.1.7.6;
exeversion=UI;7.1.7.7;
exeversion=JAVA;7.0.4.5;nobody cna help me? i really need to know or have a tutorial
or something so i can learn from it... i really appreciate anyone
who helps -
Charting data from text file in LabVIEW 5.1 for Windows
I am having some difficulties trying to figure out how to plot a chart with
data from a file. I would like to be able to read data from a text file
into a chart using LabVIEW 5.1 for Windows. I have looked in the help
within the program and online. I have also looked in the user manual and
the book "LabVIEW for Everyone". Could you please give me specific
instructions on how I would construct the program to be able to do this.
Thank you.Hi Ellie,
It depends on how data is stored in that txt file. Usually you load the data into an array either using or , the array if necessary and send it to the graph indicator in required form. If you want a more detailed answer, send me a sample data file ([email protected]). -
How to transfer data from excel files into z-tables
Please help me with a code which transfers data from excel file to z-table.
Thanks in advance
ShuvirHi Daniel,
Export Data
Purpose
Use this procedure to export SAP data to a local file such as Microsoft Excel.
Menu Path
Use the following menu path to begin this process:
· SystemèListèSaveèLocal File
Helpful Hints
When reviewing fields, R = Required, O = Optional and C = Conditional.
Procedure
1. Start the transaction using the menu path or transaction code.
Whatever Data You Want to Export
2. Select SystemèListèSaveèLocal File. This works well for any data in SAP. This is the only option for the top-level (first page) of a report.
In a drill-down view within a report the Local File button on the toolbar may be used and has the same options.
Choose File Format
3. Click .
4. Click to continue. If prompted for a format after choosing Spreadsheet, select Excel Table to get an Excel file that can be modified more easily.
Choose File Save Location Step 1
5. Click to the right of the Directory field to choose a different location.
Choose File Save Location Step 2
6. Click or browse your computer to locate the directory where you want to save your file.
7. Complete the following field:
· File name:
You must add the proper file extension to the name of your file (.xls for Excel, .rtf for Rich Text, .html for HTML). The file extension tells your computer what program to open the file with. If you do not have the file extension at the end, you may not be able to open it.
8. Click to continue.
Generate File in Location and Format Selected
9. Click to create the file in the location and format selected. In this example the file was named "example.xls" and saved on the desktop.
Result
You have completed the export process.
thanks
karthik -
How to load data from text.txt fiel and tokenize it into JCombo box???
Hi Everyone,
I am new to Java and Netbeans. I am working on the same GUI project and need your Help!!
I have two queries and since i am new,please if possible explain step by step
1.) How can I load the contents of data stored in sometext.txt file when i click the JCombo box]?? Also, if i enter a new string not existing in text, it should display a message and add the new entered data into the sometext.txt file.
2.) How can i input the contents of table.txt file (which has characters seperated by Tab) into a JTable into specific rows and columns??. Again, the txt should add and update the new entered data.
I dont want to use any databse connection!!
Explainations with Examples/Attachments will be greatly and truly appreciated
Please Please Help me ASAP as i have to submit this assignment by next week!!hi camickr,
I tried to load a file into Jtable. I have used random access file method to read a large text file seperated by tabs. When i tried to run the file, i was unable to load the data from the file. i guess i am missing the link between custom table and the default table. Can you please help me?
The complete code is attached below:.(The reason i am attaching the whole code is ..so that you can check me where i am going wrong, please dont mind!!)
package javaapplication;
import java.io.*;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
public class table extends javax.swing.JFrame {
/** Creates new form table */
public class FileTableModel extends AbstractTableModel {
RandomAccessFile raf;
ArrayList<Long> lineToPos = new ArrayList<Long>();
int columnCount = -1;
public FileTableModel(String fileName) {
try {
raf = new RandomAccessFile(new File(fileName), "C://temp.txt");
lineToPos.add(new Long(0));
String line = null;
while ((line = raf.readLine()) != null) {
if (columnCount == -1)
columnCount = line.split(" ").length;
lineToPos.add(new Long(raf.getFilePointer()));
lineToPos.remove(lineToPos.size()-1);
} catch (Exception e) {
e.printStackTrace();
protected void finalize() throws Throwable {
super.finalize();
raf.close();
public int getColumnCount() {
return columnCount;
public int getRowCount() {
return lineToPos.size();
public Object getValueAt(int rowIndex, int columnIndex) {
try {
raf.seek(lineToPos.get(rowIndex).longValue());
String line = raf.readLine();
String[] strs = line.split(" ");
return strs[columnIndex];
} catch (IOException e) {
e.printStackTrace();
return null;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTable1.setModel(jTable1.getModel());
jScrollPane1.setViewportView(jTable1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(15, Short.MAX_VALUE))
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(14, Short.MAX_VALUE))
pack();
}// </editor-fold>
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new table().setVisible(true);
// Variables declaration - do not modify
private javax.swing.JScrollPane jScrollPane1;
public javax.swing.JTable jTable1;
// End of variables declaration
} -
Read data from text file one by one using for loop
Dear Forum
I want to read data of single colum of text file inside the for loop one by one(for each iteration value must be replaced by another value of text file).This value is used by a formula inside for loop. also after completion of iterations the values must be plotted on xy graph. How to do it.? please help me.
profraviIt's not very efficient to read a file line by line. Much simpler to read it all at once and then auto-index the results inside a for loop. The image below shows a generic solution to your problem. This assumes that the data in the file is in a single column.
I would also recomend checking ou the learning LabVIEW resources here.
I would aslos suggest that since this type of question is not specific to either NI-Elvis or the LabVIEW SE, you should post similar questions to the LabVIEW board. If you have problems, attaching a sample of the text file would help.
Message Edited by Dennis Knutson on 10-18-2007 09:11 AM
Attachments:
XY Graph From File.PNG 4 KB -
Pool data from text file and insert into database
Can anyone tell me how to pool data from a text file and insert into database?
let's say my text file is in this format
123456 Peter 22
234567 Nicholas 24
345678 Jane 20
Then I need to insert the all the value for this three column into a table which has the three column name ID, Name, Age
Anyone knows? I need to do this urgently...Thank in advanced1. Use BufferedReader and read the file line by line.
2. Loop thru the file and do the following steps with in this loop.
3. Use StringTokenizer to seperate each line into three values (columns).
4. Now create a insert statement with these values and add the statement to the batch (using addBatch() method of PreparedStatement or Statement).
5. Finally (after exiting the loop), execute these batch of statements (using ps.executeBatch()).
Sudha
Maybe you are looking for
-
Hi I want to store a picture on my javacard. Is there a way to do it ? I think it will be easy if i put the byte[] on a file but i don t know if it s possible to creat a file in a javacard ? could i have some help please ? thanks
-
Which downloads do I need for studying these certifications?
I'm studying for the following certifications: Oracle Database: SQL Certified Expert Oracle Database 11g Administrator Certified Associate Oracle PL/SQL Developer Certified Associate Oracle Forms Developer Certified Professional Oracle Advanced PL/SQ
-
Mac OSX Player Issue: kernel: IOSurface: buffer allocation size is zero.
We posted a blog entry trying to investigate the Console.app error log messages that appear when using the Adobe Flash Player on OSX (32bit and 64bit affected, 10.7 Lion, Player version 10.3 and 11.0). find our Blog entry here: http://www.nanofunk.ne
-
Material master updation IDOC mapping
Hi Experts, I am getting IDOC MATMAS05 from an external system.I want to put a check on the field status(MARC-MMSTA) and update the MRP 1 data .For eg if status is 40 (inactive),I have to update MRP type to X0.How can I process further? I am using t
-
Dreamweaver behavior for flash player 8
Hi, I'd use to control my .swfs with the dreamweaver behavior (control shockwave or flash), but since i did download the flashplayer8 the .swf do not acept "gotoframe" or "rewind" commands, just "play" and "stop"...somebody can tell me where i can fi