Header information in text files
I have a VI which logs information every ten minutes into a text file. I want to add a header to the beginning of the file only once, not every ten minutes as with the rest of the information. How can I accomplish this.
At the beginning of your test create the file outside a loop and write the header information to it. Then inside the loop, keep the file open then every 10 minutes append your data to it, then close the file when finished.
Similar Messages
-
How can I add a header to a text file without mapping? [Using only ID]
Hi Experts,
I am doing a scenario in which I want to add a dynamic header to a text file, due to the complications related to the structure, I dont want to create a message type, data type etc so I cant use mapping.
I want to do all the manipuations in Integration Directory itself.
Can you all please help me out in this?
Thanks in advance
ThomasHi Experts,
I am new to XI, so only elaborate answers would help me
This is the specific requirement i want;
There is a 'source text file' which is a collection of 1000+ records, I want to make a 'target file' which is a combination of 2 fields, one field will be the dynamically generated name [for the target file] and the other field will be the whole 'source file' content.
From the last response for my question, I understand the dynamic file generation part can be done using java mapping.
Is there anyway by which I can get in the whole content of the source file into a field in the target file?
Thanks in Advance
Thomas -
Hi All,
I am downloading some data into a text file using GUI_DOWNLOAD FM.
Is there any way that i can add a header line on top of the file? In excel file, it is possible, but how do i do it for a *.txt file?
Regards
Abhijith HHi Abhijith,
The below code is to download a CSV txt file. If u want u can get the excel file also by just changing the extension from .txt to .exl Try in the way given below. U will be able to insert the required header too and get the excel file also.
*& Form gui_download
Called to download the data selected
FORM gui_download.
*--Local data declaration
DATA : l_count TYPE i,
l_filename TYPE string.
FIELD-SYMBOLS: <fs_download>.
*--Count the number of fields
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_inputtab TO <fs_download>.
IF sy-subrc <> 0.
EXIT.
ELSE.
l_count = l_count + 1.
ENDIF.
ENDDO.
CLEAR wa_inputtab.
*--Inserting the fields to the internal table in the required format
LOOP AT inputtab INTO wa_inputtab.
DO l_count TIMES. " Adding the delimiter in required places
ASSIGN COMPONENT sy-index OF STRUCTURE wa_inputtab TO
<fs_download>.
CONCATENATE wa_csv_output ',' <fs_download> INTO wa_csv_output.
ENDDO.
SHIFT wa_csv_output.
APPEND wa_csv_output TO itab_csv_output.
CLEAR wa_csv_output.
ENDLOOP.
*--Inserting the header to the internal table.
CONCATENATE 'DTAFF#' 'DTPRAC' 'DTPPP' 'DTREP' 'DTCURR' 'DTNATL'
'DTLAMT' 'DTFMD' 'DT$AMT' 'DTUNIT' 'DTRATE'
INTO wa_csv_output SEPARATED BY ','.
INSERT wa_csv_output INTO itab_csv_output INDEX 1.
IF NOT itab_csv_output[] IS INITIAL.
*--Download Data
l_filename = p_output.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_filename
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab_csv_output
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.
Reward if useful,
Cheers,
Sharadendu -
I have downloaded a trial version of Aperture because I would like to switch from using Picasa and gimp to using Aperture. I already know that I want to use Aperture, and that I cannot learn how in 30 days. I want to use the 30 days to see if I can solve a different problem: bulk export of all information except edits and versions from Aperture.
I want to avoid locking information (other than than the edits and version information that Aperture maintains) about my photos into any one piece of software.
Picasa stores a copy of almost all its information in text filies (mostly XML or .ini format) that are scattered through its picture library. These files can be scanned and found by use of Mac OS X tools that are availabe in Terminal (at the bash command line). All of the information about albums, faces, etc can be exported by a single command (after wtiting the progams that the command will initiate. I have not yest found any similar files in Aperture.
Aperture supports the export of EXIF and IPTC metadata, but only for selected photos, and does not appear to support the export of other information at all.
What I would like to do with a single operation, from either Aperture or Terminal, is to export the entire arrangement of phost ins albums and projects, lists of albums, projects and phots with all metadata (including added keywords) attached to each, and for referenced photos, the external file name. I do not care if would be in one file or many different text files, because Mac OS X provides all the tools I would need to extract the information I would want from any number of text files.
This would allow me to reconstruct all of the information about my photos (except for edits and versions) outside Aperture, and to use that info in a database outside Aperture. I would then be able to use Aperture while still being able to do everything that I could do with Picasa.
The most helpful form of an answer to this question might be a list of places to look in the Apple support and Apple developer documentation. It is difficult to teach me anything complicated, but I am fairly good at figuring out things from documentation.The following script recursively lists the content of an Aperture library. The output is simple, for demonstration puposes, but could be modified to XML. If the XML were that of a PLIST, the Apple Property List viewer oculd be used to diaplsy the output.
A simlar script produces all of the keywords and tags for all of the images in Aperture.
The scripts run much faster in the shell than in the AppleScript Editor bcause the shwll produces no debugging or monitoring information.
#!/usr/bin/env osascript
(* Demo: list the containment hierarchy in Aperture, starting from libraries.
Runs from AppleScript Editor, or as a shell command
References:
Aperture 3 AppleScript Reference Manual,
particularly the Containment Diagram in Appendix A
from the link on "Aperture Resources" web page at http://images.apple.com/aperture/resources/
Aperture AppleScript Dictionary, accessed from AppleScript Editor
Ian E. Gorman
global outputFile
set outputFilePath to "/Users/ian/prj/sw/AppleScript/ApertureContainment.txt"
global lineEnd
set lineEnd to "
global tabChar
set tabChar to " "
on writeText(str)
write str to outputFile
end writeText
# Open the file, guarantee closure after any error, and list the contents of Aperture libraries
try
set outputFile to open for access POSIX file outputFilePath with write permission
set eof outputFile to 0 # truncate the file, if it already exists
my listAll()
close access outputFile
on error errorMsg number errNum from offendingObj partial result resutList to expectedType
try
display alert "Operation failed, attempting to close output file" & lineEnd & "Error number " & errNum & ": " & errorMsg
close access outputFile
display alert "Operation failed, but output file has been closed"
on error
display alert "Operation failed, also failed to close output file"
end try
end try
# top-level in Aperture
on listAll()
tell application "Aperture"
repeat with eachLibrary in libraries
my listLibrary(0, eachLibrary)
end repeat
end tell
end listAll
on listLibrary(level, thisLibrary)
local newLevel
set newLevel to 1 + (level as integer)
tell application "Aperture"
my writeText((newLevel as rich text) & tabChar & "library" & tabChar & (name of thisLibrary) & lineEnd)
repeat with eachAlbum in albums of thisLibrary
my listAlbum(newLevel, eachAlbum)
end repeat
repeat with eachFolder in folders of thisLibrary
my listFolder(newLevel, eachFolder)
end repeat
repeat with eachProject in projects of thisLibrary
my listProject(newLevel, eachProject)
end repeat
repeat with eachImageVersion in image versions of thisLibrary
my listImageVersion(newLevel, eachImageVersion)
end repeat
end tell
end listLibrary
on listAlbum(level, thisAlbum)
local newLevel
set newLevel to 1 + (level as integer)
tell application "Aperture"
my writeText((newLevel as rich text) & tabChar & "album" & tabChar & (name of thisAlbum) & lineEnd)
repeat with eachImageVersion in image versions of thisAlbum
my listImageVersion(newLevel, eachImageVersion)
end repeat
end tell
end listAlbum
on listFolder(level, thisFolder)
local newLevel
set newLevel to 1 + (level as integer)
tell application "Aperture"
my writeText((newLevel as rich text) & tabChar & "folder" & tabChar & (name of thisFolder) & lineEnd)
repeat with eachAlbum in albums of thisFolder
my listAlbum(newLevel, eachAlbum)
end repeat
repeat with eachFolder in folders of thisFolder
my listFolder(newLevel, eachFolder)
end repeat
repeat with eachProject in projects of thisFolder
my listProject(newLevel, eachProject)
end repeat
repeat with eachImageVersion in image versions of thisFolder
my listImageVersion(newLevel, eachImageVersion)
end repeat
end tell
end listFolder
on listProject(level, thisProject)
local newLevel
set newLevel to 1 + (level as integer)
tell application "Aperture"
my writeText((newLevel as rich text) & tabChar & "project" & tabChar & (name of thisProject) & lineEnd)
repeat with eachAlbum in albums of thisProject
my listAlbum(newLevel, eachAlbum)
end repeat
repeat with eachSubfolder in subfolders of thisProject
my listSubfolder(newLevel, eachSubfolder)
end repeat
repeat with eachImageVersion in image versions of thisProject
my listImageVersion(newLevel, eachImageVersion)
end repeat
end tell
end listProject
on listSubfolder(level, thisSubfolder)
local newLevel
set newLevel to 1 + (level as integer)
tell application "Aperture"
my writeText((newLevel as rich text) & tabChar & "subfolder" & tabChar & (name of thisSubfolder) & lineEnd)
repeat with eachAlbum in albums of thisSubfolder
my listAlbum(newLevel, eachAlbum)
end repeat
repeat with eachSubfolder in subfolders of thisSubfolder
my listSubfolder(newLevel, eachSubfolder)
end repeat
repeat with eachImageVersion in image versions of thisSubfolder
my listImageVersion(newLevel, eachImageVersion)
end repeat
end tell
end listSubfolder
on listImageVersion(level, thisImageVersion)
local newLevel
set newLevel to 1 + (level as integer)
tell application "Aperture"
my writeText((newLevel as rich text) & tabChar & "image version" & tabChar & (name of thisImageVersion) & lineEnd)
end tell
end listImageVersion -
Header and Item Texts for Sales Order
Hi,
Can any one help me on Header Text and Item Text...........
<b>STXH & STXL</b>
TDOBJECT :__________
TDID:_____________
TDNAME :_______________
Regards,
Raghunath.SHi
Double click on the related text
it will open Text editor
from Menu GOTO-> header
for SO HEADER Texts
then you see the 4 paramters like OBJECT (VBBK),ID,OBJECTNAME (sales Order No) and LANG
FOR SO ITEM texts
OBJECT (VBBP table), ID, OBJECTNAME(SO no plus ITEM No) and LANG
You have to pass these 4 parameters to READ_TEXT fun module to fetch the corresponding texts
see the doc on READ_TEXT
READ_TEXT
READ_TEXT provides a text for the application program in the specified work areas.
The function module reads the desired text from the text file, the text memory, or the archive. You must fully specify the text using OBJECT, NAME, ID, and LANGUAGE. An internal work area can hold only one text; therefore, generic specifications are not allowed with these options.
After successful reading, the system places header information and text lines into the work areas specified with HEADER and LINES.
If a reference text is used, SAPscript automatically processes the reference chain and provides the text lines found in the text at the end of the chain. If an error occurs, the system leaves the function module and triggers the exception REFERENCE_CHECK.
Function call:
CALL FUNCTION 'READ_TEXT'
EXPORTING CLIENT = SY-MANDT
OBJECT = ?...
NAME = ?...
ID = ?...
LANGUAGE = ?...
ARCHIVE_HANDLE = 0
IMPORTING HEADER =
TABLES LINES = ?...
EXCEPTIONS ID =
LANGUAGE =
NAME =
NOT_FOUND =
OBJECT =
REFERENCE_CHECK =
WRONG_ACCESS_TO_ARCHIVE =
Export parameters:
CLIENT
Specify the client under which the text is stored. If you omit this parameter, the system uses the current client as default.
Reference field: SY-MANDT
Default value: SY-MANDT
OBJECT
Enter the name of the text object to which the text is allocated. Table TTXOB contains the valid objects.
Reference field: THEAD-TDOBJECT
NAME
Enter the name of the text module. The name may be up to 70 characters long. Its internal structure depends on the text object used.
Reference field: THEAD-TDNAME
ID
Enter the text ID of the text module. Table TTXID contains the valid text IDs, depending on the text object.
Reference field: THEAD-TDID
LANGUAGE
Enter the language key of the text module. The system accepts only languages that are defined in table T002.
Reference field: THEAD-TDSPRAS
ARCHIVE_HANDLE
If you want to read the text from the archive, you must enter a handle here. The system uses it to access the archive. You can create the handle using the function module ACHIVE_OPEN_FOR_READ.
The value '0' indicates that you do not want to read the text from the archive.
Reference field: SY-TABIX
Default value: 0
Import parameters:
HEADER
If the system finds the desired text, it returns the text header in this parameter.
Structure: THEAD
Table parameters:
LINES
The table contains all text lines that belong to the text read.
Structure: TLINE
Exceptions:
ID
The text ID specified in the parameter ID does not exist in table TTXID. It must be defined there together with the object of the text module.
LANGUAGE
The parameter LANGUAGE contains a language key that does not exist in table T002.
NAME
The parameter NAME contains the name of a text module that does not correspond to the SAPscript conventions.
Possible errors:
The field contains only blanks.
The field contains the invalid characters * or ,.
OBJECT
The parameter OBJECT contains the name of a text object that does not exist in table TTXOB.
NOT_FOUND
The system did not find the specified text module.
REFERENCE_CHECK
The text module to be read has no text lines of its own but refers to the lines of another text module. This reference chain can include several levels. For the current text, the chain is interrupted, that is, one of the text modules referred to in the chain no longer exists.
WRONG_ACCESS_ TO_ARCHIVE
The exception WRONG_ACCESS_TO_ARCHIVE is triggered if an archive is accessed using an incorrect or non-existing archive handle or an incorrect mode (that is, read if the archive is open for writing or vice versa).
<b>Reward points for useful Answers</b>
Regards
Anji -
Fill a text file from java code
Hello,
I've written a java code to insert some informations in a database and
I also want to save the same informations in text files (.txt).
Thanks you for your suggestions or your advice of a tutorial that can help me to perform successfully this task.
J.S.Writing to a file is pretty easy in Java. A simple way is to use the PrintStream class.import java.io.*;
public class MyClass {
public static void main(String[] arg) throws IOException {
PrintStream ps=new PrintStream(new FileOutputStream(new File("someTextFile.txt")));
//now use println(String) to write lines of text to the file
ps.println("This is a line in the file");
//always close the PrintStream when finished
ps.close();
}Alternatively, for a good tutorial, click the 'Tutorials' link in the left column on this page. -
We are trying to import data from a text file into fields in a form using the importTextData method for the Doc object. The script we are using looks like this:
var doc = event.target;
var returnCode = doc.importTextData("datafile.txt",0);
The text file "datafile.txt" contains tab separated values in a header row (which corresonds to field names in the form) followed by tab separated datarows - all according to instructions in the API.
The returnCode will result in an integer value, which in our case represent "Error: Invalid Row". It would help us a lot if anyone could give us a hint on what may be wrong or even better post a working solution.
We have also tried using the importTextData method without any parameters (the user is then prompted to select the text file and then the specific row) but the result remains the same. The fields in the form are not populated with data and the message "Error: Invalid Row" is returned.
Annika LindqvistThe problem you're experiencing is that importTextData is an Acrobat API call. As such, it executes on the AcroForm field equivalents to the XFA fields you've placed on the form. What's not indicated in the API for importTextData is that the names in the fields in the header of the text file must be the
full AcroForm SOM expression.
I've created a working sample to explain this.
First, I created a form with a table with one row in it containing 3 columns named FirstName, LastName and Country.
Then I created a data.txt file like this:
FirstName LastName Country
Fred Jones USA
Kyle Francis Canada
Sam Roberts UK
I then placed a button on the form which calls "event.target.importTextData();" and ran the form in Preview.
Of course, when I selected a row for import, nothing happened.
I then used the "Avanced | Forms | Export Data from Form..." menu option in Acrobat after filling-in the fields in the table with some text and looked at the generated text file (note that you have to specify text as the output format). In there, I was able to figure-out what the full AcroFrom SOM expression was for each field I wanted to import data into.
I changed my data file to look like this:
form1[0].#subform[0].Table1[0].Row1[0].FirstName[0] form1[0].#subform[0].Table1[0].Row1[0].LastName[0] form1[0].#subform[0].Table1[0].Row1[0].Country[0]
Fred Jones USA
Kyle Francis Canada
Sam Roberts UK
Afther that, importTextData worked as expected without any errors.
Stefan
Adobe Systems -
How to add header and fooder in text file
Hi,
i have created simple application for generate report from database into text file.
But i need to add header and fooder in text file. I dont know is there any API for adding these.
Can anyone help me to create header and fooder in text file.
the below text are needs to be print in the header
name of the table :
Recorder type :
file creation time:
the below text are needs to be print in the footer
Recorder Number:
Record Type;
the actual code is
pst = con.prepareStatement("select REQUEST, DOMAIN_NAME, TRUNC(DATE_OF_CONFIGURATION) AS dateofConfig FROM employee where id=300");
rs = pst.executeQuery();
while (rs.next()) {
request = rs.getString("REQUEST");
domain_name = rs.getString("DOMAIN_NAME");
dateofconfig = rs.getString("dateofConfig");
System.out.println(request + " " + domain_name + " " + dateofconfig);
data.add(request + " " + domain_name + " " + dateofconfig);
System.out.println("before calling method");
writeToFile(data, "c:/Employee.txt");
System.out.println("file created successfull");
rs.close();
pst.close();
private static void writeToFile(List list, String path) {
BufferedWriter out = null;
try {
File file = new File(path);
out = new BufferedWriter(new FileWriter(file, true));
for (Object obj : list) {
String s= obj.toString();
out.write(s);
out.newLine();
out.close();
} catch (IOException e) {
}Thanks
Jasmin
Edited by: user13836688 on Mar 21, 2011 4:06 AM
Edited by: user13836688 on Mar 21, 2011 4:07 AM
Edited by: user13836688 on Mar 21, 2011 4:08 AMuser13836688 wrote:
i have created simple application for generate report from database into text file.First off, when posting code, use [code]...[/code]. or '' tags, not '<code>'.
But i need to add header and fooder in text file. I dont know is there any API for adding these.
Can anyone help me to create header and fooder in text file.Well you plainly have the code to write the file contents; and furthermore your report seems to be contained in a List called 'data'. Why not just add the header and footer lines to it? I'd also suggest making 'data' a LinkedList. That way you can add the header afterwards with no performance hit, just in case the information it contains isn't available at the start of your report loop.
Winston -
I've reformatted c drive and forgot to keep bookmark backup file. So I'm trying to recover, but the bookmark is a .json type file and I need to add this to the list of files Rescue My Files recognises. To do this I need to input the file header information. Does anybody know how to get the file header information for a .json file
A JSON backup is a text file that contains data in JavaScript Object Notation format and doesn't have a specific header like an HTML backup has.<br />
The file should start with: <b><nowiki>{"title":"","id":1,"dateAdded":</nowiki></b><br />
All following data likes dates is specific to each backup.
* http://en.wikipedia.org/wiki/JSON -
How can I include the Header Information....for a File to IDOC Scenario
Hi,
I made a File to IDOC Scenario with DEBMDM06 for MDM>XI>SAP R/3. The Header Information in the XML File which is at the XI end is Missing. For that reason In Tcode SXMB_MONI we are getting an Error that <b>"HEADER Information Missing: Message should Start with EDI_DC40"</b> i.e the Header Information.
My Question is that whether we can do some changes in the Message mapping Step in the Integration Repository. I HardCoded the Few mandatory Fields that were there but it Again gave me the Same Error as above.
Can you please Suggest some Solution for this. Since the data is Coming in from MDM part the Header information is not there but It actually Important as it has got all the Port Information.
Kindly Inform me some Solutions.
Thanks & Regards
SomnathHi Suraj,
Thanks for ur Reply, but Since we are Doing a File to IDOC Scenario the IDOC DEBMDM is on the Right Side in Message Mapping and as U know it is Mandatory to Map an IDOC on the Right Part. EDI_DC40 is coming as it is there in the IDOC but our XML File Does not have that. If we Don't Map then it Becomes RED, which is an Error.
Furthermore in the Receiver Agreement we have put the Necessary Details such as Sender Service and Receiver Service along with the IDOC Communication Channels.
Can U give as a Better Insight on this Note how to check the Header Part as it is mandatory to MAP.We also tried to HARDCODE it by putting those Values and Mapping them to a Constant but it is Giving the Same Error.
Thanks and Regards
Somnath -
Hi Experts,
I need your HELP to include headings START_DATE, NUM_LOGS,MBYES,RSIZE in my text file "redo_history.log" below.
05-3-2009,36, 3600,100
05-4-2009,191, 19100,100
05-5-2009,56, 5600,100
06-1-2009,220, 22000,100
06-2-2009,245, 24500,100
06-3-2009,217, 21700,100
My desired output text file (redo_history.log) should be on below:
START_DATE, NUM_LOGS,MBYES,RSIZE
05-3-2009,36, 3600,100
05-4-2009,191, 19100,100
05-5-2009,56, 5600,100
06-1-2009,220, 22000,100
06-2-2009,245, 24500,100
06-3-2009,217, 21700,100
Im executing the following script below to generate text file named redo_history.log:
select dump_csv('SELECT Start_Date,
Num_Logs,
to_char(Round(Num_Logs * (Vl.Bytes / (1024 * 1024)),2),''999999999'') AS Mbytes,
Vl.Bytes / (1024*1024) AS RSize
FROM (SELECT To_Char(Vlh.First_Time,''MM-W-YYYY'') AS Start_Date,
COUNT(Vlh.Thread#) Num_Logs
FROM V$log_History Vlh
WHERE Vlh.First_Time > current_date - interval ''30'' day
GROUP BY To_Char(Vlh.First_Time,''MM-W-YYYY'')) log_hist,
( select distinct bytes from V$log ) Vl
ORDER BY Log_Hist.Start_Date',',','EXT_TABLES','redo_history.log')
from dual;
Please find below dump_csv.sql:
CREATE OR REPLACE function dump_csv( p_query in varchar2,
p_separator in varchar2
default ',',
P_DIR in varchar2 ,
p_filename in varchar2 )
return number
AUTHID CURRENT_USER
is
l_output utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(2000);
l_status integer;
l_colCnt number default 0;
l_separator varchar2(10) default '';
l_cnt number default 0;
begin
l_output := utl_file.fopen( P_DIR, p_filename, 'w' );
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
for i in 1 .. 255 loop
begin
dbms_sql.define_column( l_theCursor, i,
l_columnValue, 2000 );
l_colCnt := i;
exception
when others then
if ( sqlcode = -1007 ) then exit;
else
raise;
end if;
end;
end loop;
dbms_sql.define_column( l_theCursor, 1, l_columnValue,
2000 );
l_status := dbms_sql.execute(l_theCursor);
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
l_separator := '';
for i in 1 .. l_colCnt loop
dbms_sql.column_value( l_theCursor, i,
l_columnValue );
utl_file.put( l_output, l_separator ||
l_columnValue );
l_separator := p_separator;
end loop;
utl_file.new_line( l_output );
l_cnt := l_cnt+1;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
return l_cnt;
end dump_csv;
Thanks in advance for you HELP.
Regards,
Eddieow005731 wrote:
No, I am not asking how to know the column name.
I am questioning why go through all the hassles to determine the column names, while they are already known.
When the user prepares the query to pass on to dump_csv():
SELECT Start_Date,
Num_Logs,
to_char(Round(Num_Logs * (Vl.Bytes / (1024 * 1024)),2),''999999999'') AS Mbytes,
Vl.Bytes / (1024*1024) AS RSize
FROM ...
he obviously specifies/knows the column names. (It's not like he was doing select * ...)But what if he was doing select *? And why hard code column names for this query and then have to change them if the query changes when you can write it to be completely dynamic?
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10 -
Is it possible to import a Fixed Text file that does not have a header?
I'm trying to import a Fixed Text file through Import Manager, but the text file I am receiving does not have a header on it (the first row is valid data). When I try importing this, Import Manager uses the first row of data as the headings. Is there any way to turn this off and tell Import Manager there is no header data in the file?
Thanks!Hi Ryan ,ur requirement can be met only when u import the file as ODBC .for this follow the below steps.
1)Go to control panel,in ur settings,select administrative tools
2) In that select DATA SOURCE(ODBC ).
3)Go to SYSTEM DSN tab select tab .
4)Select ur file type MICROSOFT TEST DRIVER (.txt,.csv)
5)Double click on "Import DSN" and in the blank give the name of DATA SOURCE NAME any name u want to give.
6)Uncheck the use current directory box and select the directory ur file is it will automatically show ur source file select it and click ok.
7) Now when u import ur file as ODBC give the name of ur DATA source name which u have given and it will show ur file in the source preview itself .
In this way u can import ur file as ODBC.
Hope this may help u.
Regards
Ankit -
Add header line to the text file in receiver file adapter
Hello Experts,
I have to add a new line to the text file generated at the receiver end.
My structure is
Record
Item......0-unbounded
field1
field2
field3
I have defined below parameters in receiver FCC.
RecordSet Structure : Record,Item
Item.fieldSeparator : ;
Record.fieldSeparator : nl
Record.endSeparator : '0x0D''0x0A' ( this is to get a carriage return at the end of the file)
Item.addHeaderLine : 1
With the above configuration, i am getting the desired output with NO header line.
Please help.
Thanks,
Swetha.Hi, it looks like that the headerline "specification is only permitted if exactly one structure is defined." Please check [SAP help under Define Parameters for Recordset Structures|http://help.sap.com/saphelp_nw73/helpdata/en/44/686e687f2a6d12e10000000a1553f6/frameset.htm].
One solution would be to generate the header fields in the message payload. Generate an additional first line containing the header names, e.g.
<Item>
<field1>Header1
<field2>Header2
<field3>Header3 -
Hi expert,
wn i m downloading a text file into presentation server , hw can i add header there for heading of the particular fieds which is showing in file.plz suggest.
thanx and regards...
sunil.hello,
you can try doing as mentioned above
however, in some cases, the datatype of the internal table may not allow you to entire the text header string that you need
in such cases you can use this method
what i have done here, is to make a simple internal table with text values to insert the text
i used that table with the FM first
then i called the function module again and passed the data
in the second call, i set the append parameter to 'X'.
types: begin of header_type,
field1(20),
field2(20),
field3(20),
end of header_type.
data: it_header type header_type occurs 0 with header line.
it_header-field1 = 'field_1'.
it_header-field2 = 'field_2'.
it_header-field3 = 'field_3'.
append it_header.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'c:\test_xls.xls'
filetype = 'ASC'
write_field_separator = 'X'
DAT_MODE = 'X'
TRUNC_TRAILING_BLANKS = 'X'
TABLES
data_tab = it_header.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'c:\test_xls.xls'
filetype = 'ASC'
append = 'X'
write_field_separator = 'X'
DAT_MODE = 'X'
TRUNC_TRAILING_BLANKS = 'X'
TABLES
data_tab = itab. -
Oracle Alerts - Suppressing Mime-Header information in plain text emails
Hi there
Is there a way to suppress Mime-header information at the top of an alert email? I mean this stuff:
>
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_17_6226724.1264085542237"
Content-Language: en
X-oracle-workflow-nid: ALR[1/0000@DEVE]
------=_Part_17_6226724.1264085542237
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
Content-Language: en
For some reason, it is appearing in some emails, but not others, and detracts from the readability of the alert text.
Any help appreciated.
Regards
CK852970 wrote:
Am still new in Oracle and am trying to find the solution for this i.e note 472822.1 - Odd Email Header And Footer In 11.5.10.2 Alert. How can locate this?? thanx alot
My Oracle Support website -- https://support.oracle.com
You need to valid username/password to access the site/doc.
Thanks,
Hussein
Maybe you are looking for
-
IPhone 5, Is there a way to stop screen rotation for specific apps?
The automatic screen rotation feature is useful - sometimes, and just plain annoying other times. I prefer to read my e-mail in portrait mode, however the slightest movement or rotation while doing so will cause the screen to rotate (with the phone
-
I need help Centering a div box to a background image using dreamweaver cs5.5.
I need help Centering a div box to a background image using dreamweaver cs5.5. Everything shift left when viewing on different size monitors? See what I mean at www.woodlandhospice.com
-
Multiple Oracle Homes - Oracle Listener failes to start after installation
Just in case the listener fails to start after an oracle installation, please check the oracle ports in the listener.ora and tnsnames.ora, both of which are present in the following directory: ...\oracle\<SID>\<Ver>\NETWORK\ADMIN All installations sh
-
Multiple line items in created delivery
Hi all, I am executing the transaction VL10E and after reducing the quantity of material( Say from 500 to 50) I am craeting delivery by clicking the push button 'BACKGROUND' but when i check the delivery created in VL02n. It is showing the same mate
-
IPhone: NavigationController Back Button
The back button on a navigationController is supposed to be automatic, right? I have a table view hierarchy with a navigation controller that has two table views. I can click on a cell in the root view and it does the transition to the next view. How