FileAdapter to read "|" (pipe) seperated file
Hi all,
when using "file content conversion" in the sender file adapter and having a "," or ";" as a seperator everything is fine.
But I now have a "|" (pipe symbol) as the seperator character. The adapter does not seem to recognize this "|" as a single character and keeps the original line unchanged, that I don't get my XML I wanted
I tried various other settings like the hex-representation, '|', "|" or | without qoutes, but not success so far.
So if someone has come across this already and solved it ... please post.
Thx
Uwe
Hi all,
these settings are working :
line.fieldSeparator |
line.fieldNames <field1>,<field2>,<field3>
line.processFieldNames fromConfiguration
line.endSeparator 'nl'
I have seperated the fieldNames as well with |
thanks a lot to all
Uwe
Similar Messages
-
How to upload pipe seperated file
hi friends,
i want to upload the pipe delimited file (which generated from unix server) for bdc program.
can you please tell me how can i upload this file?
can i use 'open dataset'??
thanks in advance
ankitIf you are uploading from the application server, then you would use the OPEN DATASET, if you uploading from the frontend(pc), then you would use GUI_UPLOAD.
Here is an example program which is uploading from the frontend.
report zrich_0001.
types: begin of ttab,
rec(1000) type c,
end of ttab.
types: begin of tdat,
fld1(10) type c,
fld2(10) type c,
fld3(10) type c,
end of tdat.
data: itab type table of ttab with header line.
data: idat type table of tdat with header line.
data: file_str type string.
parameters: p_file type localfile.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
file_str = p_file.
call function 'GUI_UPLOAD'
exporting
filename = file_str
tables
data_tab = itab
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.
loop at itab.
clear idat.
split itab-rec at '|' into idat-fld1
idat-fld2
idat-fld3.
append idat.
endloop.
loop at idat.
write:/ idat-fld1, idat-fld2, idat-fld3.
endloop.
Regards,
Rich Heilman -
Function module to read Comma Seperated File (CSV)
Hi,
Is there any Function module to read CSV file from presentation server or Application server?
Regards,
MadhuHi madhukeshwar,
1. Exactly for this purpose,
i have developed an independent FORM
where we give inputs
a) file name (eg. abcd.txt)
b) separator (eg , COMMA in your case)
c) internal table (eg. t001)
2. It will provide the data
in proper format
(no matter what the separator)
(it can work with any kind of separator)
3. just copy paste in new program.
REPORT abc.
change your table declaration and file name
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
PERFORM myupload TABLES t001 USING 'd:\t001.txt' ','.
BREAK-POINT.
in debug see t001
INDEPENDENT FORM
FORM myupload TABLES orgtab
USING filename separator.
Data
DATA : BEGIN OF itab OCCURS 0,
myline(1000) TYPE c,
END OF itab.
DATA : extension(5) TYPE c.
DATA : name(100) TYPE c.
DATA : newfilename TYPE string.
Step 1
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
TABLES
data_tab = itab.
Step 2
LOOP AT itab.
REPLACE ALL OCCURRENCES OF separator IN itab-myline WITH
cl_abap_char_utilities=>horizontal_tab.
MODIFY itab.
ENDLOOP.
Step 3
DATA : path LIKE pcfile-path.
path = filename.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
extension = extension
name = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
invalid_drive = 1
invalid_extension = 2
invalid_name = 3
invalid_path = 4
OTHERS = 5
Step 4
newfilename = filename.
REPLACE name IN newfilename WITH 'temp'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = newfilename
TABLES
data_tab = itab
FIELDNAMES =
Step 5
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = newfilename
has_field_separator = 'X'
TABLES
data_tab = orgtab.
ENDFORM. "myupload
3.
regards,
amit m. -
BPEL reading/writing a file
Hi,
To test my BPEL process, I am using FileAdapter to read from a file/write to a file. It works fine with my localhost as the SOA server. When I deploy to the development server, is there anyway I can put the file inside the project and deploy it as part of the jar file?
Thanks
JohnYes it sounds strange that you want move the file you are reading. This can be done via the ant script although I haven't used the FTP task. Create a pre-build.xml file. this will be called by the build.xml. Have a look at this link http://ant.apache.org/manual/index.html
Otherwise if you just want to change the directory location based on the environment, use the logical path this means you can update the location in the BPEL console.
You can also use a parameter in the properties file. you need a pre-build.xml and post-build.xml
pre-build.xml
<?xml version="1.0"?>
<project name="bpel.pre-build" default="pre-build" basedir="./bpel">
<property name="xxsoa_log_dir_deploy" value="${xxsoaLogDir}"/>
<target name="pre-build">
<bpelc input="${basedir}/bpel.xml" rev="${rev}" deploy="${domain}" force="true">
<customize>
<partnerLinkBinding name="WriteHTMLService">
<property name="wsdlLocation">WriteHTMLService.wsdl</property>
<property name="XXSOA_LOG_DIRECTORY">${xxsoa_log_dir_deploy}</property>
<property name="retryInterval">60</property>
</partnerLinkBinding>
</customize>
</bpelc>
<copy file="bpel.xml" tofile="bpel_orig.xml" overwrite="true"/>
<copy file="_bpel.xml" tofile="bpel.xml" overwrite="true"/>
</target>
</project>
post-build.xml
<?xml version="1.0"?>
<project name="bpel.post-build" default="post-build" basedir="./bpel">
<target name="post-build">
<echo>
| Copying bpel_orig.xml to bpel.xml
</echo>
<copy file="bpel_orig.xml" tofile="bpel.xml" overwrite="true"/>
</target>
</project> -
What is the best and most efficient way to read a .xls File and create a pipe-delimited .csv File?
Thanks in advance for your review and am hopeful for a reply.
ITBobbyP85You should have no trouble doing this in SSIS. Simply add a data flow with connection managers to an existing .xls file (excel connection manager) and a new .csv file (flat file). Add a source to the xls and destination to the csv, and set the destination
csv parameter "delay validation" to true. Use an expression to define the name of the new .csv file.
In the flat file connection manager, set the column delimiter to the pipe character. -
Target flat file with pipe seperated
Hi
I want to load the data in flat file , i don't see pipe "|" seperation values to create a flat file in this format. how can i achive and how can i also how can i create file name dynamically
ThanksJust type in your desired character.
Cheers
David -
Need to read data from pipe separated file using POJO?
Hi,
I need to read data from pipe separated file using POJO.
There is config.properties file which consists of the
data mapping.
Can you help me with sample code or help?
Regards
Regards
Taton
Edited by: Taton on Mar 7, 2009 4:41 PMIt's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
[http://java.sun.com/docs/books/tutorial/essential/io/]
*Unless you write a bunch of JNI code to replicate what the java.io classes are doing. -
HI Guys,
can some body explain what a pipe delimited file format is.
thanks
Column Name = WRKAREA_CODE
Format of Pipe Delimited File = 20 Digits
SAP DB Type = CHAR (20)
Description = Work Area Code
WRKAREA_CODE is a field of the table WFAV_WRKAREAHI,
a pipe delimited file is a file in which the content of the file is seperated by a pipe symbol..
example
100|Name|School|age|
*-- Read the File From PC
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V_FILENAME
TABLES
DATA_TAB = I_FILE
EXCEPTIONS
OTHERS = 17.
*-- Split the Record into Individual Fields
SPLIT X_FILE-LINE AT '|' INTO X_PRSTR-VCODE
X_PRSTR-CURR
X_PRSTR-ODLEVEL
X_PRSTR-DLEVEL
X_PRSTR-EDATE
X_PRSTR-SCODE
X_PRSTR-TCODE
X_PRSTR-DCODE
Thanks
Mahesh
Thanks
Mahesh -
Adobe AIR 4 Not reading a XML file larger than 10MB
I have an application where the XML file could be over 10MB in size. I am using XMLHttpRequest to read the file in. However, on Air 4, it results in null when the file is greater than 10MB in size. This was working until I updated to AIR 4. I can go back to a previous version of AIR and the loading of large file works.
xml = new XMLHttpRequest( );
xml.onreadystatechange = function( ){
if( xml.readyState == 4 && xml.status == 200){
b[language] = xml.responseXML.documentElement; //Results in NULL when file size is greater than 10MB
var tempTxt = "Loaded Database";
xml.open( "GET", file.url, false);
xml.send( null );
Why AIR limited the file size and any work around for this? The Request processes fine and readyState will become 4. However, xml.responseXML.documentElement will respond with a NULL.
Thank you
Binu
www.verseview.infoIt's difficult to tell what it is, it looks like a binary
pipe symbol but I can copy it from TextPad for example. Some of the
characters following it cannot be copied from TextPad which I
assume is because it's null. I can read the whole file in C#/.Net
and assign it to a string variable without any problems but perhaps
Air is somewhat limited to binary content. -
Pipe delimited file on application server.
Hi , i m creating a text file on application server, i have written below code and file is getting created correctly. however, i want to create pipe delimited file. is there any method for this?
DATA : lv_line(173).
DATA : l_wa_itab_length(4) TYPE c VALUE '173'.
IF NOT p_tab[] IS INITIAL.
SORT p_tab.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
IF sy-subrc NE 0.
MESSAGE 'Error on output file read' TYPE 'E'.
ELSE.
LOOP AT p_tab.
lv_line = p_tab.
TRANSFER lv_line TO p_file LENGTH l_wa_itab_length.
CLEAR p_tab.
CLEAR lv_line.
ENDLOOP.
CLOSE DATASET p_file.
ENDIF.
ENDIF.
REFRESH p_tab.i m pasting below my entire code.
REPORT zmigration_data_download.
FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE.
DATA: d_table_ref TYPE REF TO data.
DATA: d_rfc_db_opt TYPE rfc_db_opt.
DATA: it_opt LIKE rfc_db_opt OCCURS 0 WITH HEADER LINE.
DATA: d_file TYPE string.
PARAMETERS: p_tab TYPE dd02l-tabname OBLIGATORY.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY DEFAULT '/usr/sap/tmp/test.txt'.
SELECT-OPTIONS: s_opt FOR d_rfc_db_opt NO INTERVALS.
START-OF-SELECTION.
REFRESH it_opt.
LOOP AT s_opt WHERE sign = 'I' OR option = 'EQ'.
it_opt-text = s_opt-low.
APPEND it_opt.
ENDLOOP.
CREATE DATA d_table_ref TYPE TABLE OF (p_tab).
UNASSIGN <fs_table>.
ASSIGN d_table_ref->* TO <fs_table>.
IF <fs_table> IS ASSIGNED.
CLEAR <fs_table>.
SELECT * FROM (p_tab) INTO TABLE <fs_table>
WHERE (it_opt).
IF sy-subrc EQ 0.
PERFORM download_file TABLES <fs_table> USING p_file.
MESSAGE i398(00) WITH 'Upload from SAP Successfull'.
ENDIF.
ENDIF.
*& Form download_file
text
-->P_<FS_TABLE> text
-->P_P_FILE text
FORM download_file TABLES p_tab USING p_file.
DATA : lv_line(173).
DATA : l_wa_itab_length(4) TYPE c VALUE '173'.
IF NOT p_tab[] IS INITIAL.
SORT p_tab.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
IF sy-subrc NE 0.
MESSAGE 'Error on output file read' TYPE 'E'.
ELSE.
LOOP AT p_tab.
lv_line = p_tab.
TRANSFER lv_line TO p_file LENGTH l_wa_itab_length.
CLEAR p_tab.
CLEAR lv_line.
ENDLOOP.
CLOSE DATASET p_file.
ENDIF.
ENDIF.
REFRESH p_tab.
ENDFORM. " download_file -
9iJSP Report output to a comma seperated file
Hi,
Is it possible to create a comma seperated file with output data from a 9iJSP report. If yes, can anyone tell me how ??
thanks in advance
UnmeshHello Unmesh,
If your JSP report has a paper layout, then you can use Reports Builder or the client/servlet/runtime executables to generate the paper layout to CSV formatted output with the DESFORMAT=DELIMITEDDATA and DELIMITER=, command-line options. If you have only a web layout , it will generate its output only in HTML format.
You can add a paper/web layout to your JSP report, if it already doesn't have one, by opening it in Reports Builder, and inserting a report block in the paper layout view/web source view. This JSP report can then be used both to generate to CSV format using rwservlet, and to the web when deployed as a JSP.
Thanks,
The Oracle Reports Team. -
Extract data from Pipe Delimited file
Hi everybody,
Could someone provide me the command to extract data from a pipe delimited file ("|") using Open/Read Data set.
I mean eliminating the delimiter ("|") and just picking the data.
Thanks
MHere you go.. this code snippet parses the input file record by using pipe (variable lv_pipe) as separator, for tab separated file you can use lv_tab like wise...
TYPES: BEGIN OF ts_field,
field(50) TYPE c,
END OF ts_field,
tt_field TYPE TABLE OF ts_field.
DATA: ls_record TYPE string,
ls_input_data TYPE ts_input_data,
lv_tab TYPE x VALUE '09',
lv_pipe TYPE C VALUE '|',
ls_field TYPE ts_field,
lt_field_tab TYPE tt_field,
lv_field_index TYPE syindex,
lv_record_no TYPE syindex.
FIELD-SYMBOLS: <fs_field> TYPE ANY.
OPEN DATASET fv_file_path IN TEXT MODE FOR INPUT.
IF sy-subrc = 0.
DO.
lv_record_no = lv_record_no + 1.
READ DATASET fv_file_path INTO ls_record.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT ls_record AT lv_pipe INTO TABLE lt_field_tab.
CLEAR: lv_field_index, ls_input_data.
LOOP AT lt_field_tab INTO ls_field.
lv_field_index = lv_field_index + 1.
ASSIGN COMPONENT lv_field_index OF STRUCTURE
ls_input_data TO <fs_field>.
IF sy-subrc = 0.
<fs_field> = ls_field-field.
ENDIF.
ENDLOOP.
APPEND ls_input_data TO ft_input_data.
ENDIF.
ENDDO.
CLOSE DATASET fv_file_path. -
Hello all.
I wonder if there is an easy way to read from a file so that the currect contents of the file are always available within a Java program.
For instance:
1. The file "text.txt" has one line: "hello"
2. Open the file from a Java program; it has the line "hello"
3. Somebody adds another line to the file: "bye"
4. The Java program is noticed about 3. so that the line "bye" can be read
Something like "tail -f" or a named pipe (fifo) in Unix.
Thanks in advance.
God bless,
JaimeNo, this is NOT a solution. Once FileReader has encountered an EOF condition once, it will never go back to the file descriptor to see if there might be some more available. (For that reason, also reader.ready() will never return true again, no matter how much is appended to the file.) I tried this on Java 1.5.0_11 on Solaris.
The other proposed solution, checking the file length periodically using the File length() method and then re-opening the file if the length is different, is also seriously flawed for several reasons:
(a) If the file is renamed, you have no way of telling whether the file you already opened is modified -- the next time you call file.length(), it would fail since the old name doesn't exist any more, or, even worse, if meanwhile a new file was created under the old name, you'd be looking at a different file, not the one you've opened for reading!
(b) If you do detect a change, having to reopen the file as a RandomAccessFile to be able to seek to the last read position is bad because you have to implement your own buffering (can't wrap BufferedReader around it, obviously), AND it suffers from the same file rename problem! The file you re-open might be a different one, so seeking to the last read position would land you at an arbitrary spot in a different file, and you wouldn't even know it!!!
As a conclusion, it is apparently not possible to implement something as elementary as "tail -f" in Java correctly!
Someone will have to think about that. Yes, I saw the argument that this may not be implementable on ALL kinds of file systems and hence not portable, but just because Windows file handling is broken, this shouldn't mean that Java file handling has to be broken on all decent platforms as well!
:-( -
Reading a binary file to string variable does not populate correctly
Hi, I am new to Adobe Air/Flex and I'm trying to read a
binary file which also contains text in "cleartext". The problem
I'm having is that when I call FileStream.readUTFBytes method, only
the first 6 characters are showing up in my string variable
"contents" when I debug it in FlexBuilder or use a trace command
and debug it. I have also tried with other types of files but I
have a similar problem unless it's a non-binary file.
Am I doing something incorrectly or should I be reading a
binary file differently than the way I'm reading it currently?
The source code is shown below.
TIA,
Magnus
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import flash.filesystem.File;
private function readFiles():void{
var feedFile:File = File.userDirectory.resolvePath( "Local
Settings/Application Data/Microsoft/Feeds/AppScout~.feed-ms" );
var stream:FileStream = new FileStream();
stream.open( feedFile, FileMode.READ );
var contents:String =
stream.readUTFBytes(stream.bytesAvailable);
trace(contents);
stream.close();
]]>
</mx:Script>
<mx:Button x="121" y="66" label="Button"
click="readFiles()" />
</mx:WindowedApplication>It's difficult to tell what it is, it looks like a binary
pipe symbol but I can copy it from TextPad for example. Some of the
characters following it cannot be copied from TextPad which I
assume is because it's null. I can read the whole file in C#/.Net
and assign it to a string variable without any problems but perhaps
Air is somewhat limited to binary content. -
Reading Windows text file in Fortran?
Is there a way to make the f90 compiler read Windows text files properly? I made a simple test with a text file created on a Windows system containing these three lines:
This is a Windows text file.
It has some extra control characters.
Unix does not have those.
The output I got was:
<-ext file.
<-e extra control characters.
<-se.
KevinThat makes more sense. The problem isn't with the Fortran program, but with the Unix terminal (xterm, or whatever you're using to display the output). If you pipe the output through od like this you'll see all the characters, including the ^M:
bash-3.00$ fortranread | od -c
0000000 w i n f i l e i s - > T h
0000020 i s i s a W i n d o w s
0000040 t e x t f i l e . \r
0000060
0000100 < - \n w i
0000120 n f i l e i s - > I t h a
0000140 s s o m e e x t r a c o n
0000160 t r o l c h a r a c t e r s .
0000200 \r
0000220 < - \n w i n f i
0000240 l e i s - > U n i x d o e
0000260 s n o t h a v e t h o s e
0000300 . \r
0000320
0000340 < - \n
0000347When the terminal sees the ^M character, it does a carriage return. That means that the next character gets written in the first column. Since the characters after the ^M are spaces, that makes the beginning of the lines appear blank.
If you want to see the output you expect, you need to pipe it through "tr -d '\015'", or you need to make the Fortran program itself delete the ^M characters. For example, you could write "myline(1:len_trim(myline)-1)" to always strip the last character of the line.
We should consider making formatted reads strip the ^M by default. I don't know whether any program would actually want them.
Maybe you are looking for
-
Creating a Kindle-friendly table of contents with pages
I'm trying to figure out how in Pages (I just recently bought it and want to use it instead of Word) to create a Kindle-friendly table of contents, so readers can click on a chapter title and go straight to that chapter, for the fiction I want to pub
-
Automatic Post Goods Issue Of Stock Transport Order
Here is the scenario: We are using stock transport order to logically move inventory from one company to another company inside the same physical location. The material# is the same but the plant# is different. Process is as follows: Associate enters
-
Homesharing with iTunes 11.2.2
Homesharing does not work anymore with iTunes 11.2.2 - does anybody have a solution to the problem? I have all suggested solutions that I could find online, but nothing seems to work.
-
Can i have vat condition on freight charges
Hi, One of my client requirement is a special one we . As per the requirement he needs VAT to be calculated on freight only. Example This is my pricing proceedure 10 Pcs P00
-
Fetch records in the last 12 months
Hi All, I have an activity metrix field which returns the total number of completed activities for an account. My requirement is , I need only the total number of activities completed in the last 12 months from today. So if a user views the same repo