Problem in uploading text file to itab
Hi experts,
I declared a itab with two fields which refers a a dB table fields.Then i created a excel file: In the firest column i placed entry for the first field
and in the second column i placed entry for the second field.Both fields i have taken from thatDB table.Then i saved that excel file as type text-tab delimited.Then i called GUI_UPLOAD.
So when exicute my pgm i see the contents in the itab as follows:
Field1 field2
kv_sub_area0 004#descvription by ravikumar.
But i should get like this:
Field1 field2
kv_sub_area0004 descvription by ravikumar.
Why # is coming and it is taking some characters from field1 to filed2.
I am using version 4.7 Actually field1 is of length 30 as per DB table.
If i reduce the length in the itab declaration then it is giving corect..
can any body tellme why this problem occurs?
Regards
in GUI_UPLOAD
mention as
FILE_TYPE = 'ASC'.
HAS_FIELD_SEPERATOR = 'X'.
if you provide the above both, i believe your problem will be solved.
that '#' special symbol is for horizantal tab.
regards
srikanth
Message was edited by: Srikanth Kidambi
Similar Messages
-
Problem while uploading text file through portal into WebDAV repository .
Hi all...
I am not able to upload any file through portal onto my webDav repository for remote server however reverse is possible i.e. any document created at remote server is reflected in portal.
Everytime when i try to upload file though portal , i get the following error::
The item could not be created because an exception occurred in the framework.
Kindly suggest what to do....
ThankSHi Chetna,
Have you specified any user information in the webdav repository....Like always connect through this user, in the webdav repsository tab....This user may not have write permission in the windows.
Also are you sure that the user you logged in portal by which you failed to create new files or folders and the user that was able to create file in the windows are one and the same.....
Regards,
Ganesh N -
GUI_UPLOAD - Problem in uploading xml file
Hi,
I have problem in uploading xml file into itab.
Here is the code
begin of GS_STRING,
STR(72) type C,
end of GS_STRING,
GT_STRING like standard table of GS_STRING,
call function 'GUI_UPLOAD'
EXPORTING
FILENAME = FILE_NAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = GT_STRING
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 I499(SY) with 'File upload failed'.
stop.
endif.
endif.
In debuggin mode, i can see the itab uploaded with xml payload. But in that same place, the hexadecimal format has double zeros 00 after each character.
XML message : <?xml
Correct Hexadecimal : 3C3F786D6C
Hexadecimal in itab : 3C003F0078006D006C00
This makes the resultant xml invalid.
can anyone help me to solve this?
Thanks,
Uma
Edited by: Uma Maheswari on May 30, 2008 4:15 PMwhat do you want to do with the uploaded XML?
i use the following
constants: line_size type i value 255.
data: begin of xml_tab occurs 0,
raw(line_size) type x,
end of xml_tab,
file type string,
size type i.
call function 'GUI_UPLOAD'
exporting
filename = filename
filetype = 'BIN'
has_field_separator = ' '
header_length = 0
importing
filelength = size
tables
data_tab = xml_tab
exceptions
others = 1. -
Upload text file to oracle table with checking and aggregation
Hi Friends,
I am new to ODI. I have encountered a problem which is specific to ODI 11G (11.1.1.6.3) to upload text file to oracle table with checking and aggregation. Would you please teach me how to implement the following requirement in ODI 11G?
Input text file a:
staffCode, staffCat, status, data
input text file b:
staffCodeStart, staffCodeEnd, staffCat
temp output oracle table c:
staffCat, data
output oracle table d:
staffCat, data
order:
a.staffCode, a.staffCat, a.status
filter:
a.status = ‘active’
join:
a left outerjoin b on a.staffCode between b.staffCodeStart and b.staffCodeEnd
insert temp table c:
c.staffCat = if b.staffCat is not null then b.staffCat else a.staffCat
c.data = a.data
insert table d:
if c.staffCat between 99 and 1000 then d.staffCat = c.staffCat, d.data = sum(c.data)
else d.staffCat = c.staffCat, d.data = LAST(c.data)
Any help on fixing this is highly appreciated. Thanks!!
Thanks,
ChrisDear Santy,
Many thanks for your prompt reply. May I have more information about the LAST or SUM step?
I was successful to create and run the following interfaces p and q
1. Drag text file a to a newly created interface panel p
2. Filter text file a : a.status = ‘active’
3. Lookup text file a to text file b : a.staffCode between b.staffCodeStart and b.staffCodeEnd
4. Drag oracle temp table c to interface panel p
5. Set c.staffCat : CASE WHEN b.staffCat IS NULL THEN a.staffCat ELSE b.staffCat END
6. Set c.data : a.data
7. Drag oracle temp table c to a newly created interface panel q
8. Drag oracle table d to interface panel q
9. Set UK to d.staffCat
10. Set Distinct Rows to table d
11. Set d.staffCat = c.staffCat
12. Set d.data = SUM(c.data)
However, the interface q should be more than that:
If c.staffCat is between 99 and 1000, then d.data = the last record c.data; else d.data = sum(c.data)
Would you please teach me how to do the LAST or SUM steps? Moreover, can interface p and interface q be combined to one interface and do not use the temp table c? Millions thanks!
Regards,
Chris -
Upload text files with non-english characters
I use an Apex page to upload text files. Then i retrieve the contents of files from wwv_flow_files.blob_content and convert them to varchar2 with utl_raw.cast_to_varchar2, but characters like ò, à, ù become garbage.
What could be the problem? Are characters lost when files are stored in wwv_flow_files or when i do the conversion?
Some other info:
* I see wwv_flow_files.DAD_CHARSET is set to "ascii", wwv_flow_files.FILE_CHARSET is null.
* Trying utl_raw.cast_to_varchar2( utl_raw.cast_to_raw('àòèù') ) returns 'àòèù' correctly;
* NLS_CHARACTERSET parameter is AL32UTF8 (not just english ASCII)Hi
Have a look at csv upload -- suggestion needed with non-English character in csv file it might help you.
Thanks,
Manish -
Problem in Uploading TEXT field for PR
Hi all,
I am using FM 'GUI_UPLOAD ' for uploading text file .
There are three coloumns in my text file ie(PR number, item and TEXT id (long text) seperated by TAB
As there are long text in the last coloumn and in between there are tab space i was unable to get the entire text
To over come that problem , i have used multiple coloumn in the internal table of input table so that even if there are tab space
i can store it in the other coloumn .
But the problem is when im using FM"BAPI_REQUISITION_CREATE" and passing the table by breaking into 132 charactes
in requisition_item_text im completely , getting different format.
I mean the format of the uploaded text is completely messed up.:(
Please help.
Regards,
ChandanHIII Chandan,
When we use GUI_UPLOAD function module
Call function GUI_UPLOAD
Exporting
Filenmae = "the one which we are passing on to selection screen" should be of type File name
i.e IBIPPARMS-PATH.
It is of type char and size 128
So i think this is the reason u r unable to transport the data -
Problem in Uploading a File by Applet
Hi Members,
* I have faced problem while uploading a file from client to server by ftp protocol using APPLET(No JSP) only
* I am getting exception while running....
* My source code is as follows,
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class UploadAndDownload extends Applet implements ActionListener {
Button upload;
Button browse;
TextField filename;
File source = null;
Label name;
StringBuffer sb;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
public void init() {
setLayout(new FlowLayout());
upload = new Button("Upload");
browse = new Button("Browse");
name = new Label("Filename");
filename = new TextField("", 45);
add(name);
add(filename);
add(upload);
add(browse);
upload.addActionListener(this);
browse.addActionListener(this);
public void actionPerformed(ActionEvent evt) {
// Code for browsing a file
String input_file_name = "";
if (evt.getSource() == browse)
Frame parent = new Frame();
FileDialog fd = new FileDialog(parent, "Select a file", FileDialog.LOAD);
fd.setVisible(true);
input_file_name = fd.getFile();
filename.setText(input_file_name);
// Gets the file from the file dialog and assign it to the source
source = new File(input_file_name);
repaint();
// Code for Uploading a file to the server
if (evt.getSource() == upload) {
// Appending the server pathname in string buffer
sb = new StringBuffer("ftp://");
sb.append("2847");
sb.append(':');
sb.append("Websphere25");
sb.append("@");
sb.append("172.16.1.111");
sb.append('/');
sb.append(input_file_name);
sb.append(";type=i");
try {
URL url = new URL(sb.toString());
URLConnection urlc = url.openConnection();
bos = new BufferedOutputStream(urlc.getOutputStream());
bis = new BufferedInputStream(new FileInputStream(source));
int i;
// Read from the inputstream and write it to the outputstream
while ((i = bis.read()) != -1) {
bos.write(i);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bis != null)
try {
bis.close();
} catch (IOException ioe) {
ioe.printStackTrace();
if (bos != null)
try {
bos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
MY EXCEPTION IS,
Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.net.SocketPermission 172.16.1.111:80 connect,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.getOutputStream(Unknown Source)
at UploadAndDownload.actionPerformed(UploadAndDownload.java:68)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)* Please let me know what problem in my code....
* Thanks in advance....* Thanks for your reply....
* I have signed my policy file by giving AllPermission and mentioned in java.security file in bin folder....
* My question is , by giving AllPermission , can we access and do all permissions like ( SecurityPermission, AWTPermission, SocketPermission, NetPermission, FilePermission, SecurityPermission etc )...
* My policy file is looks like follow,
/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/
/* DO NOT EDIT */
grant {
permission java.security.AllPermission;
};* If i signed the policy like above, and when i run the applet file in InternetExplorer now , it thorws the following exception on my console,
java.net.ProtocolException: cannot write to a URLConnection if doOutput=false - call setDoOutput(true)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.getOutputStream(Unknown Source)
at UploadAndDownload.actionPerformed(UploadAndDownload.java:68)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)* Please let me know , how to solve this and give me your suggestion on the above process...
* Thanks in advance...
Regards,
JavaImran -
Problem with uploading a file in Clustered Environment
Hi,
I have a problem with uploading a file in a clustered environment. I have an iview component which facilitates an upload action of an xml config file. The problem is that the upload of the modified XML file is reflected only in the central instance of the cluster and not in the dialog instances. The dialog instances hold the old config file.
Is there any solution to upload the file to all the nodes in the cluster.
Thanks
KiranHi,
This is a known problem with clustered environment. Remember that your portal component runs on just on dialog instance and it doesn't automatically have access to the other nodes. However, there are some ways to get around this
1. Use KM to store files. KM is a common repository for all application servers and therefore you needn't worry more
2. Use an external batch oriented product (suresync/robocopy) to synch folders on the different DIs. You basically use your existing portal component, but there is a batch job which makes sure the upload folder is identical on all DIs (however, there is a slight delay depending on how often you run the batch job)
3. Store the files on a shared disk directly from the portal component.
Cheers
Dagfinn -
Problem in creating text file from report file
Hello Everybody...
I have problem in creating text file.
I had set System Parameter as below
DESTYPE : File
MODE : Character
DESNAME : gayu.txt
And ruler setting
Units : Character Cells
Character Cell Size : Horiziontal = 7
Vertiacle =12
GridSpacing : 1
no of snap points per grid spacing : 1
but when i run report it will give error
"REP_1219 M_2 or R_2 has no size -- length or width zero"
so is there any solution of that
or another way to convert report into text file?....Hi Folks,
Please don't go after that Error as its a very deceptive one. Please don't go for altering your design Or changing the size of items in your layout.
Similar errors I have come across in reports. I think its due to file transfer type. You might have transferred the file in Binary and your File Mode I am seeing it as CHAR.
This normally happens while making the Report Format as "Text". Either you change that format which I think is possible in your case as your basic requirement is making a report output of CHAR type.
Please check for this error in Metalink and proceed accordingly. I could fix similar errors when I changed Format type to PDF(from text).
Regards
Shibu -
Uploaded text file has a new line added at the top using BSP MVC applicatio
I have a BSP MVC application that uploads data on to the application server. When I open the uploaded text file, the very first line on the file looks like the line below. ->
htmlb:button:click:nullhtmlb_form_1UploadUpload0htmlbdfsdf
But the rest of the file looks okay. This is causing other than .txt files to get corrupted.
Here is the code from my DO_HANDLE_EVENT.
data: entity type ref to if_http_entity,
name type string,
content type xstring,
content_type type string,
idx type i value 1,
v_root(26) value '
houappl131\SRM_Download\',
v_unxfile(100),
v_transfer type xstring,
v_type(6),
v_len type i,
v_dirfile type zfileinfo,
v_ofile(80),
v_guid type guid_32.
class cl_htmlb_manager definition load.
data: v_asn(10) type n.
data: fu type ref to cl_htmlb_fileupload,
file_id type string value 'batchfile'.
data: o_page_context type ref to if_bsp_page_context.
data: parent type ref to cl_bsp_controller2,
lo_model type ref to cl_sus_m_asn_detail.
o_page_context = me->get_page_context( ).
cl_htmlb_manager=>dispatch_event_ex( request = request
page_context = o_page_context
event_handler = me ).
refresh z_batch->message.
if htmlb_event->server_event = 'Upload'.
fu ?= cl_htmlb_manager=>get_data( request = request id = file_id name
= 'fileUpload' ).
if fu->file_name gt space.
z_batch->parameters-fpath = fu->file_name.
v_len = strlen( z_batch->parameters-fpath ).
if v_len gt 4.
v_len = v_len - 3.
endif.
v_type = z_batch->parameters-fpath+v_len(3).
search z_batch->parameters-fpath for '.'.
if sy-fdpos gt 0 and v_len gt 0.
v_len = v_len - sy-fdpos.
v_type = z_batch->parameters-fpath+sy-fdpos(v_len).
endif.
clear v_asn.
v_asn = z_batch->parameters-asnhdr.
concatenate v_asn
z_batch->parameters-asnitem
z_batch->parameters-batch
v_type
into v_unxfile separated by '.'.
concatenate v_root v_unxfile into v_unxfile.
condense v_unxfile no-gaps.
open dataset v_unxfile for output in binary mode.
while idx <= request->num_multiparts( ).
entity = request->get_multipart( idx ).
name = fu->file_name .
if name is not initial.
content_type = entity->get_header_field( 'Content-Type' ).
clear content.
content = entity->get_data( ).
v_transfer = content.
transfer content to v_unxfile.
append content to z_batch->filetab.
endif.
idx = idx + 1.
endwhile.
close dataset v_unxfile.
endif.
endif.
Here is my fileupload button in the view
<htmlb:page title="File Upload " >
<htmlb:form method = "post"
encodingType = "multipart/form-data" >
<htmlb:label id = "Batchnum"
design = "Label"
for = "Batchnumber"
text = "Batch" />
<htmlb:inputField id = "Batchinput"
value = "//zbatch/parameters.batch" />
<htmlb:fileUpload id="batchfile" />
<htmlb:button id = "Upload"
text = "Upload"
onClick = "Upload" />
<htmlb:button id = "Close"
text = "Close window"
onClick = "Close" />
Any of you gurus know why this is happening?I solved it myself
-
Problems while uploading text documents into Unicode Database
I just upgraded our database from 9iR1 to 9iR2 (9.2.0.1.0). The server
character set is AL32UTF8. Now I'm facing a problem when
uploading text documents into the database via a web frontend.
I use the upload table defined for the PL/SQL Database Access Descriptor:
create table TB_UPLOAD (
NAME VARCHAR2(256) not null,
MIME_TYPE VARCHAR2(128),
DOC_SIZE NUMBER,
DAD_CHARSET VARCHAR2(128),
LAST_UPDATED DATE,
CONTENT_TYPE VARCHAR2(128),
BLOB_CONTENT BLOB);
After uploading a text document containing the two words "hallo welt",
the following statement returns not "hallo welt", but "68616C6C6F2077656C74":
declare
b_loc blob;
v_amount integer := 100;
v_buffer varchar2(100);
v_offset integer := 1;
begin
select blob_content into b_loc from tb_upload where name like 'mydoc.txt';
dbms_lob.read(b_loc, v_amount, v_offset, v_buffer);
htp.prn(v_buffer);
end;
What is this? I studied the documentation, but didn't found a solution.
When trying to use Oracle's built-in procedure wpg_docload.download_file,
the content is shown the way it should be. Unfortunately, I can't use
wpg_docload.download_file in order to copy the BLOB content to another table.
Any hints would be appreciated!
Thanks so much in advance!
Roman
E-Mail: [email protected]Hi Roman,
the upload uses a BLOB (Binary Lob). Your Document is
stored as is in the binary representation. If you
use dbms_lob.read on a blob and your buffer is a varchar2 the binary representation is not translated!!!
use a raw for the buffer and utl_raw.cast_to_varchar2
to do the conversion to varchar.
try this
Procedure SHOW_DOC(p_name doc_test.name%TYPE)
IS
v_len number;
v_mime_type tb_upload.mime_type%TYPE;
v_offset integer := 1;
v_Buf_size integer := 32767;
v_buf raw(32767);
v_blob blob;
v_Doc_name varchar2(1000);
BEGIN
v_doc_name := url_Decode(p_name);
select mime_type,doc_size,blob_content
into v_mime_Type,v_len,v_blob
from tb_upload
where name = v_doc_name;
OWA_UTIL.MIME_HEADER(v_Mime_Type);
begin
LOOP
DBMS_LOB.READ(v_blob,v_buf_size,v_offset,v_buf);
HTP.PRN(UTL_RAW.CAST_TO_VARCHAR2(v_buf));
v_offset := v_offset + v_buf_size;
END LOOP;
exception
when no_data_found then
null;
end;
END;
HTH
detlev -
Problems while uploading text documents into Database
I just upgraded our database from 9iR1 to 9iR2 (9.2.0.1.0). The server
character set is AL32UTF8. Now I'm facing a problem when
uploading text documents into the database via a web frontend.
I use the upload table defined for the PL/SQL Database Access Descriptor:
create table TB_UPLOAD (
NAME VARCHAR2(256) not null,
MIME_TYPE VARCHAR2(128),
DOC_SIZE NUMBER,
DAD_CHARSET VARCHAR2(128),
LAST_UPDATED DATE,
CONTENT_TYPE VARCHAR2(128),
BLOB_CONTENT BLOB);
After uploading a text document containing the two words "hallo welt",
the following statement returns not "hallo welt", but "68616C6C6F2077656C74":
declare
b_loc blob;
v_amount integer := 100;
v_buffer varchar2(100);
v_offset integer := 1;
begin
select blob_content into b_loc from tb_upload where name like 'mydoc.txt';
dbms_lob.read(b_loc, v_amount, v_offset, v_buffer);
htp.prn(v_buffer);
end;
What is this? I studied the documentation, but didn't found a solution.
When trying to use Oracle's built-in procedure wpg_docload.download_file,
the content is shown the way it should be. Unfortunately, I can't use
wpg_docload.download_file in order to copy the BLOB content to another table.
Any hints would be appreciated!
Thanks so much in advance!
Roman
E-Mail: [email protected]Hi Roman,
the upload uses a BLOB (Binary Lob). Your Document is
stored as is in the binary representation. If you
use dbms_lob.read on a blob and your buffer is a varchar2 the binary representation is not translated!!!
use a raw for the buffer and utl_raw.cast_to_varchar2
to do the conversion to varchar.
try this
Procedure SHOW_DOC(p_name doc_test.name%TYPE)
IS
v_len number;
v_mime_type tb_upload.mime_type%TYPE;
v_offset integer := 1;
v_Buf_size integer := 32767;
v_buf raw(32767);
v_blob blob;
v_Doc_name varchar2(1000);
BEGIN
v_doc_name := url_Decode(p_name);
select mime_type,doc_size,blob_content
into v_mime_Type,v_len,v_blob
from tb_upload
where name = v_doc_name;
OWA_UTIL.MIME_HEADER(v_Mime_Type);
begin
LOOP
DBMS_LOB.READ(v_blob,v_buf_size,v_offset,v_buf);
HTP.PRN(UTL_RAW.CAST_TO_VARCHAR2(v_buf));
v_offset := v_offset + v_buf_size;
END LOOP;
exception
when no_data_found then
null;
end;
END;
HTH
detlev -
I am facing problem to get text file from application sever
Hi This is lokesh.
Actually my requirement is to craete sales orders by getting file from other server.for that i have used shell script to connect that server.Ok i am connecting to that different server(not sap server) successfully.
But my problem is getting text file from application SERVER.
That different server people will send the file name as 'DDHHMMSS' (Days,Hours,Minutes,Seconds).
Just suppose if they will send today means that file name will come as 20103025. and with in half an hour if they again send that file file means that file name as '20110025'.
like that file name is always varies.So how can i read that type of text files from the application server.
and one more thing that is there chance to read morethan one text file from application server.
Pls guide me if u know the solution.PLs this requirement is urgent.
Regards,
LokeshgoudHi..,
<b>Just execute this program ... this is for the files received in JUST 3 MINS...</b>
change it according to your requirement !!
data time type sy-uzeit value '100000'. <i>"<<----start time</i>
data file(8) type c value '20'.
do 180 times. <i>" <<----- for 3 minutes</i>
add sy-index to time.
concatenate file time into file.
write / file.
OPEN DATASET FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
PERFORM READ_DATASET.
ENDIF.
file = '20'.
time = '100000'.
ENDDO.
<b>form read_dataset.
read the file here with the file name <b>FILE</b>.
endform.</b>
regards,
sai ramesh -
hi
i want to create BDC program for the data uploding.. but i dont hv much knwloadge of about it. i need to sample code the data upload program. i hv to upload text file format. im using gui_upload funtion if u hv any sample plz send me it plz... thnx
regad
nawaCheck the following code:
Selection screen :
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-020.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .
PARAMETERS: p_locl RADIOBUTTON GROUP g1 " desktop file
DEFAULT 'X' USER-COMMAND fil,
p_phys RADIOBUTTON GROUP g1. " appln server file
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .
PARAMETERS: p_ifile TYPE dxfile-filename LOWER CASE, " source file
p_afile TYPE dxfile-filename LOWER CASE, " asset class file
p_cfile TYPE dxfile-filename LOWER CASE, " Cost center file
p_dfile TYPE dxfile-filename LOWER CASE, " Depr key file
p_ofile TYPE dxfile-filename LOWER CASE. " Audit file
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-015.
PARAMETERS: p_test RADIOBUTTON GROUP g2 DEFAULT 'X', " test run
p_create RADIOBUTTON GROUP g2. " data migretion
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN END OF BLOCK b4.
Main program :
REPORT zfaac900
LINE-SIZE 132
LINE-COUNT 65
NO STANDARD PAGE HEADING
MESSAGE-ID ZFAA.
* includes
INCLUDE: zfaac900_top,
zfaac900_selection_screen,
zfaac900_subroutine.
* AT SELECTION SCREEN ON VALUE REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ifile.
PERFORM help_input_file USING p_phys p_locl CHANGING p_ifile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_afile.
PERFORM help_asset_file USING p_phys p_locl CHANGING p_afile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cfile.
PERFORM help_cost_file USING p_phys p_locl CHANGING p_cfile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dfile.
PERFORM help_depr_file USING p_phys p_locl CHANGING p_dfile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ofile.
PERFORM help_audit_file USING p_phys p_locl CHANGING p_ofile.
* AT SELECTION-SCREEN
AT SELECTION-SCREEN.
PERFORM check_screen USING p_ifile p_afile p_cfile p_dfile
p_ofile p_locl p_phys.
* TOP-OF-PAGE
TOP-OF-PAGE.
ULINE.
PERFORM sjm_heading IN PROGRAM zacai0005.
ULINE.
* START_OF_SELECTION
START-OF-SELECTION.
PERFORM get_input USING p_ifile p_afile p_cfile p_dfile
CHANGING i_input i_asset i_cost i_depr.
Subroutines :
*& Form help_input_file
* text
FORM help_input_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_source_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_IFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_source_path.
ENDIF.
ENDFORM. " help_input_file
*& Form help_asset_file
* text
FORM help_asset_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_source_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_AFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_source_path.
ENDIF.
ENDFORM. " help_asset_file
*& Form help_cost_file
* text
FORM help_cost_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_source_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_CFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_source_path.
ENDIF.
ENDFORM. " help_cost_file
*& Form help_depr_file
* text
FORM help_depr_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_source_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_DFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_source_path.
ENDIF.
ENDFORM. " help_depr_file
*& Form help_audit_file
* text
FORM help_audit_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_audit_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_OFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_audit_path.
ENDIF.
ENDFORM. " help_audit_file
*& Form help_local_file
* Local File Path
FORM help_local_file CHANGING p_path TYPE any .
DATA: lt_file_table TYPE filetable,
la_file_table LIKE LINE OF lt_file_table,
l_rc TYPE i,
l_pcdsn TYPE cffile-filename.
REFRESH lt_file_table.
CLEAR la_file_table.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_file_table
rc = l_rc.
READ TABLE lt_file_table INTO la_file_table INDEX 1.
l_pcdsn = la_file_table-filename.
MOVE l_pcdsn TO p_path.
ENDFORM. " help_local_file
*& Form check_phys_file
* Validation of Physical File
FORM check_phys_file USING p_file TYPE any.
DATA: l_str(300) TYPE c.
CLEAR l_str.
OPEN DATASET p_file IN TEXT MODE FOR INPUT ENCODING DEFAULT.
IF sy-subrc <> 0.
IF g_file_flag = 'I'.
MESSAGE e000 WITH text-021.
ELSEIF g_file_flag = 'A'.
MESSAGE e000 WITH text-095.
ELSEIF g_file_flag = 'C'.
MESSAGE e000 WITH text-096.
ELSEIF g_file_flag = 'D'.
MESSAGE e000 WITH text-097.
ENDIF.
ENDIF.
READ DATASET p_file INTO l_str.
IF sy-subrc <> 0.
IF g_file_flag = 'I'.
MESSAGE e000 WITH text-017.
ELSEIF g_file_flag = 'A'.
MESSAGE e000 WITH text-098.
ELSEIF g_file_flag = 'C'.
MESSAGE e000 WITH text-099.
ELSEIF g_file_flag = 'D'.
MESSAGE e000 WITH text-100.
ENDIF.
ENDIF.
CLEAR: g_file_flag.
CLOSE DATASET p_file.
ENDFORM. " check_phys_file
*& Form check_local_file
* Validation of Local File
FORM check_local_file USING p_file TYPE any.
DATA: l_size TYPE i.
CLEAR: l_size.
CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
EXPORTING
fname = p_file
IMPORTING
* exist = l_exist
filesize = l_size
EXCEPTIONS
fileinfo_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
IF g_file_flag = 'I'.
MESSAGE e000 WITH text-016.
ELSEIF g_file_flag = 'A'.
MESSAGE e000 WITH text-101.
ELSEIF g_file_flag = 'C'.
MESSAGE e000 WITH text-102.
ELSEIF g_file_flag = 'D'.
MESSAGE e000 WITH text-103.
ENDIF.
ENDIF.
IF l_size IS INITIAL.
IF g_file_flag = 'I'.
MESSAGE e000 WITH text-024.
ELSEIF g_file_flag = 'A'.
MESSAGE e000 WITH text-107.
ELSEIF g_file_flag = 'C'.
MESSAGE e000 WITH text-108.
ELSEIF g_file_flag = 'D'.
MESSAGE e000 WITH text-109.
ENDIF.
ENDIF.
CLEAR: g_file_flag.
ENDFORM. " check_local_file
*& Form get_input
* To gate input data from local file or from application server
FORM get_input USING p_ifilename TYPE any
p_afilename TYPE any
p_cfilename TYPE any
p_dfilename TYPE any
CHANGING p_input_table TYPE t_input_table
p_asset_table TYPE t_asset_table
p_cost_table TYPE t_cost_table
p_depr_table TYPE t_depr_table.
* to populate the input table
PERFORM upload_file USING p_ifilename CHANGING i_local.
g_file_flag = 'I'.
PERFORM split_localtable CHANGING p_input_table p_asset_table
p_cost_table p_depr_table.
CLEAR g_file_flag.
REFRESH i_local.
* to populate the asset class table
PERFORM upload_file USING p_afilename CHANGING i_local.
g_file_flag = 'A'.
PERFORM split_localtable CHANGING p_input_table p_asset_table
p_cost_table p_depr_table .
CLEAR g_file_flag.
REFRESH i_local.
* to populate the cost center table
PERFORM upload_file USING p_cfilename CHANGING i_local.
g_file_flag = 'C'.
PERFORM split_localtable CHANGING p_input_table p_asset_table
p_cost_table p_depr_table .
CLEAR g_file_flag.
REFRESH i_local.
* to populate the depr key table
PERFORM upload_file USING p_dfilename CHANGING i_local.
g_file_flag = 'D'.
PERFORM split_localtable CHANGING p_input_table p_asset_table
p_cost_table p_depr_table .
CLEAR g_file_flag.
REFRESH i_local.
ENDFORM. " get_input
*& Form upload_file
* text
FORM upload_file USING p_filename TYPE any
CHANGING p_local_table TYPE t_local_table.
* To get the input data from desktop file
IF p_locl = 'X'.
DATA: l_file TYPE string.
CLEAR: l_file,
p_local_table.
l_file = p_filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
TABLES
data_tab = p_local_table
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 e002 WITH l_file.
ENDIF.
ELSE.
* To get the data from application server file
OPEN DATASET p_filename IN TEXT MODE FOR INPUT ENCODING DEFAULT.
IF sy-subrc <> 0.
MESSAGE e001 WITH p_filename.
ENDIF.
CLEAR: wa_local.
DO.
READ DATASET p_filename INTO wa_local.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND wa_local TO p_local_table.
CLEAR: wa_local.
ENDDO.
CLOSE DATASET p_filename.
ENDIF.
ENDFORM. " upload_file
*& Form split_localtable
* text
FORM split_localtable CHANGING p_input_tab TYPE t_input_table
p_asset_tab TYPE t_asset_table
p_cost_tab TYPE t_cost_table
p_depr_tab TYPE t_depr_table.
DATA: l_cnt TYPE i.
CLEAR: l_cnt, wa_local.
LOOP AT i_local INTO wa_local.
REFRESH i_split[].
SPLIT wa_local AT c_tab INTO TABLE i_split.
CLEAR l_cnt.
ADD 1 TO l_cnt.
CLEAR wa_split.
LOOP AT i_split INTO wa_split.
IF g_file_flag = 'I'.
ASSIGN COMPONENT l_cnt OF STRUCTURE wa_input TO <fs_field>.
ELSEIF g_file_flag = 'A'.
ASSIGN COMPONENT l_cnt OF STRUCTURE wa_asset TO <fs_field>.
ELSEIF g_file_flag = 'C'.
ASSIGN COMPONENT l_cnt OF STRUCTURE wa_cost TO <fs_field>.
ELSEIF g_file_flag = 'D'.
ASSIGN COMPONENT l_cnt OF STRUCTURE wa_depr TO <fs_field>.
ENDIF.
CLEAR <fs_field>.
<fs_field> = wa_split-col.
ADD 1 TO l_cnt.
CLEAR wa_split.
ENDLOOP.
IF g_file_flag = 'I'.
APPEND wa_input TO p_input_tab.
CLEAR: wa_input .
ELSEIF g_file_flag = 'A'.
APPEND wa_asset TO p_asset_tab.
CLEAR: wa_asset .
ELSEIF g_file_flag = 'C'.
APPEND wa_cost TO p_cost_tab.
CLEAR: wa_cost .
ELSEIF g_file_flag = 'D'.
APPEND wa_depr TO p_depr_tab.
CLEAR: wa_depr .
ENDIF.
CLEAR: wa_local .
ENDLOOP.
ENDFORM. " split_localtable -
Hi All,
I did one application on file upload using the tutorial given in the ****************.
But i am unable to run my application due to the function module 'HR_KR_XSTRING_TO_STRING'
that does not exist.Can anybody plz tell me the name of the function module to convert xstring to string or an idea to solve this problem.
Thanks in Advance.If you want to upload an EXCEL file. you can achive it by first saving excel as
tab delimeted text file. This is simple open excel from save as choose
save as type Text( Tab delimeted).txt.
Now use file upload UI element from webdynpro abap. within the context declare
a context node lets call it NODE with attribute File type XSTRING. Bind
the data property of file upload UI element to the attribute 'File'.
Create a button upload and on its action write the following code.
Data: s_cont type string,
x_cont type xstring,
convt type ref to cl_abap_conv_in_ce,
item_file type xstringval.
data: input_string type string,
fields type string_table,
fields2 type string_table,
tbl_fields type string_table,
s_table type string_table,
ls_table like line of s_table,
ls like line of fields,
lv_kunnr type kunnr,
lv_ret type boolean,
lv_num_cols type i.
field-symbols: <wa_table> like line of s_table.
DATA:
node_file TYPE REF TO if_wd_context_node,
elem_file TYPE REF TO if_wd_context_element,
stru_file TYPE if_v_upload=>element_file ,
item_file LIKE stru_file-file.
* navigate from <CONTEXT> to <NODE> via lead selection
node_file = wd_context->get_child_node( name = if_v_upload=>wdctx_node ).
* get element via lead selection
elem_file = node_file->get_element( ).
* get single attribute
elem_file->get_attribute(
EXPORTING
name = `FILE`
IMPORTING
value = item_file ).
convt = cl_abap_conv_in_ce=>create( input = item_file ).
convt->read( importing data = s_cont ).
"Column headers
split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.
read table s_table into ls_table index 1.
" delete column header
delete s_table index 1.
loop at s_table assigning <wa_table>.
split <wa_table> at cl_abap_char_utilities=>horizontal_tab into : ls_data-recordid
ls_data-candno
ls_data-fname
ls_data-inits
ls_data-lname
ls_data-gesch
ls_data-gbdat
ls_data-uln.
append ls_data to lt_data.
clear ls_data.
endloop.
wd_this->m_node_data->bind_table(
exporting
new_items = lt_data
set_initial_elements = abap_true ).
endmethod.
Greetings Prashant
P.S. Points welcome
Maybe you are looking for
-
My iTunes Library has disappeared. Help!
My entire iTunes library has disappeared. From reading other posts I see that this has been an issue. I'm not sure if it's related to AVG antivirus (but I deleted it anyway) or due to iTunes update. I noticed a week or 2 ago but haven't been back in
-
How can i open pdf on safari with reader 11,0,07
i've got Imac with OSX 10,9,4 and adobe reader 11,0,07. i can't read pdf on website. i've got this error message : Before proceeding you must first launch Adobe Acrobat and accept the End User License Agreement. but i don't know where i can accept th
-
Might sound stupid to some, but how do you see the master levels?
I see audio levels for every single track, audio and midi, but for the master fader, i just see the fader. Surely there must be a way to see the level, right?
-
Modification to Sales Office in Sales Order not resulting in Delta in BI
Hello, I am experiencing a issue in delta update to 0SD_C03. Any changes to the Sales Office in a Sales Order are not resulting in a delta update in 2LIS_11_VATIM OR 2LIS_11_VADHR. This is resulting in erroneous reporting when looking at Sales Orders
-
My ipod touch is locked up and non-responsive
I have tried to reset by holding lock and power buttons at the same time with no success. I have a white screen and the ipod is non-responsive to anything.