Writing to a flat file using UTL in a procedure
Hello All,
I am creating a procedure in which I am trying to write data to a flat file using UTL. Code is shown below:
CREATE OR REPLACE PROCEDURE wrt_lifungduty IS
sql_stmt varchar2(200);
sql_stmt1 varchar2(200);
sql_stmt2 varchar2(200);
v_cur_hdl integer;
v_rows_processed BINARY_INTEGER;
V_file UTL_FILE.FILE_TYPE;
V_flatfile_line VARCHAR2(98) := NULL;
V_OBLIGATION_KEY NUMBER(10);
V_OBLIGATION_LEVEL VARCHAR2(6);
V_KEY_VALUE_1 VARCHAR2(20);
V_KEY_VALUE_2 VARCHAR2(20);
V_PARTNER_TYPE VARCHAR2(6);
V_PARTNER_ID VARCHAR2(10);
V_EXT_INVC_NO VARCHAR2(30);
V_EXT_INVC_DATE DATE;
V_PAID_DATE DATE;
V_PAID_AMT NUMBER(20,4);
V_COMP_ID VARCHAR2(10);
V_RECEIPT_DATE DATE;
V_ORDER_QTY NUMBER(12,4);
V_RECEIPT_QTY NUMBER(12,4);
V_FRT NUMBER;
V_DUTY NUMBER;
V_SUPPLIER NUMBER;
V_FLAG VARCHAR2(1);
V_ELC_COST NUMBER;
V_ADJ_ELC NUMBER;
Cursor x is
select OBLIGATION_KEY,OBLIGATION_LEVEL,KEY_VALUE_1,KEY_VALUE_2,PARTNER_TYPE,PARTNER_ID,EXT_INVC_NO,EXT_INVC_DATE
,PAID_DATE,PAID_AMT,COMP_ID,RECEIPT_DATE,ORDER_QTY,RECEIPT_QTY,FRT,DUTY,SUPPLIER,FLAG,ELC_COST,ADJ_ELC
from RMSBIZ.CT_ANALYZE_LIFUNG_DUTY;
BEGIN
if not UTL_FILE.IS_OPEN(V_file) then
V_file := UTL_FILE.FOPEN('/exchange/biz/rms2lan','sb_duty.dat','w'); --need to give the location for testing
end if;
for x1 in x loop
V_OBLIGATION_KEY :=1;
V_OBLIGATION_LEVEL :='test';
V_OBLIGATION_KEY :=x1.OBLIGATION_KEY;
V_OBLIGATION_LEVEL :=x1.OBLIGATION_LEVEL;
V_KEY_VALUE_1 :=x1.KEY_VALUE_1;
V_KEY_VALUE_2 :=x1.KEY_VALUE_2;
V_PARTNER_TYPE :=x1.PARTNER_TYPE;
V_PARTNER_ID :=x1.PARTNER_ID;
V_EXT_INVC_NO :=x1.EXT_INVC_NO;
V_EXT_INVC_DATE :=x1.EXT_INVC_DATE;
V_PAID_DATE :=x1.PAID_DATE;
V_PAID_AMT :=x1.PAID_AMT;
V_COMP_ID :=x1.COMP_ID;
V_RECEIPT_DATE :=x1.RECEIPT_DATE;
V_ORDER_QTY :=x1.ORDER_QTY;
V_RECEIPT_QTY :=x1.RECEIPT_QTY;
V_FRT :=x1.FRT;
V_DUTY :=x1.DUTY;
V_SUPPLIER :=x1.SUPPLIER;
V_FLAG :=x1.FLAG;
V_ELC_COST :=x1.ELC_COST;
V_ADJ_ELC :=x1.ADJ_ELC;
V_flatfile_line:= V_OBLIGATION_KEY||','||
V_OBLIGATION_LEVEL ||','||
V_KEY_VALUE_1 ||','||
V_KEY_VALUE_2 ||','||
V_PARTNER_TYPE ||','||
V_PARTNER_ID ||','||
V_EXT_INVC_NO ||','||
V_EXT_INVC_DATE ||','||
V_PAID_DATE ||','||
V_PAID_AMT ||','||
V_COMP_ID ||','||
V_RECEIPT_DATE ||','||
V_ORDER_QTY ||','||
V_RECEIPT_QTY ||','||
V_FRT ||','||
V_DUTY ||','||
V_SUPPLIER ||','||
V_FLAG ||','||
V_ELC_COST ||','||
V_ADJ_ELC;
V_flatfile_line:= V_OBLIGATION_KEY||','|| V_OBLIGATION_LEVEL;
UTL_FILE.PUT_LINE(V_file, V_flatfile_line);
end loop
commit;
UTL_FILE.fclose(V_file);
END;
Getting the following errors:
SQL>Welcome-->
ERROR at line 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.UTL_FILE", line 98
ORA-06512: at "SYS.UTL_FILE", line 157
ORA-06512: at "RMSBIZ.WRT_LIFUNGDUTY", line 39
ORA-06512: at line 1
SQL>Welcome-->39
39* V_file := UTL_FILE.FOPEN('/exchange/biz/rms2lan','sb_duty.dat','w');
SQL>Welcome-->
Does any one know why it is erroring out?
Thanks,
Chiru
the code below works if i take out the last 3 columns while writing to the flat file line.
CREATE OR REPLACE PROCEDURE wrt_lifungduty IS
sql_stmt varchar2(200);
sql_stmt1 varchar2(200);
sql_stmt2 varchar2(200);
v_cur_hdl integer;
v_rows_processed BINARY_INTEGER;
V_file UTL_FILE.FILE_TYPE;
V_flatfile_line VARCHAR2(98) := NULL;
V_OBLIGATION_KEY NUMBER(10);
V_OBLIGATION_LEVEL VARCHAR2(6);
V_KEY_VALUE_1 VARCHAR2(20);
V_KEY_VALUE_2 VARCHAR2(20);
V_PARTNER_TYPE VARCHAR2(6);
V_PARTNER_ID VARCHAR2(10);
V_EXT_INVC_NO VARCHAR2(30);
V_EXT_INVC_DATE DATE;
V_PAID_DATE DATE;
V_PAID_AMT NUMBER(20,4);
V_COMP_ID VARCHAR2(10);
V_RECEIPT_DATE DATE;
V_ORDER_QTY NUMBER(12,4);
V_RECEIPT_QTY NUMBER(12,4);
V_FRT NUMBER;
V_DUTY NUMBER;
V_SUPPLIER NUMBER;
V_FLAG VARCHAR2(1);
V_ELC_COST VARCHAR2(20);
V_ADJ_ELC VARCHAR2(20);
Cursor x is
select OBLIGATION_KEY,OBLIGATION_LEVEL,KEY_VALUE_1,KEY_VALUE_2,PARTNER_TYPE,PARTNER_ID,EXT_INVC_NO,EXT_INVC_DATE
,PAID_DATE,PAID_AMT,COMP_ID,RECEIPT_DATE,ORDER_QTY,RECEIPT_QTY,FRT,DUTY,SUPPLIER,FLAG,ELC_COST,ADJ_ELC
from RMSBIZ.CT_ANALYZE_LIFUNG_DUTY;
BEGIN
if not UTL_FILE.IS_OPEN(V_file) then
V_file := UTL_FILE.FOPEN('/rmsapps/rms803/biz/data/utl_files','sb_duty.csv','w'); --need to give the location for testing
end if;
for x1 in x loop
V_OBLIGATION_KEY :=nvl(x1.OBLIGATION_KEY,null);
V_OBLIGATION_LEVEL :=nvl(x1.OBLIGATION_LEVEL,null);
V_KEY_VALUE_1 :=x1.KEY_VALUE_1;
V_KEY_VALUE_2 :=x1.KEY_VALUE_2;
V_PARTNER_TYPE :=x1.PARTNER_TYPE;
V_PARTNER_ID :=x1.PARTNER_ID;
V_EXT_INVC_NO :=x1.EXT_INVC_NO;
V_EXT_INVC_DATE :=x1.EXT_INVC_DATE;
V_PAID_DATE :=x1.PAID_DATE;
V_PAID_AMT :=x1.PAID_AMT;
V_COMP_ID :=x1.COMP_ID;
V_RECEIPT_DATE :=x1.RECEIPT_DATE;
V_ORDER_QTY :=x1.ORDER_QTY;
V_RECEIPT_QTY :=x1.RECEIPT_QTY;
V_FRT :=x1.FRT;
V_DUTY :=x1.DUTY;
V_SUPPLIER :=x1.SUPPLIER;
V_FLAG :=nvl(x1.FLAG,'0');
V_ELC_COST :=to_char(nvl(x1.ELC_COST,0));
V_ADJ_ELC :=to_char(nvl(x1.ADJ_ELC,0));
V_flatfile_line:= V_OBLIGATION_KEY||','||
V_OBLIGATION_LEVEL ||','||
V_KEY_VALUE_1 ||','||
V_KEY_VALUE_2 ||','||
V_PARTNER_TYPE ||','||
V_PARTNER_ID ||','||
V_EXT_INVC_NO ||','||
V_EXT_INVC_DATE ||','||
V_PAID_DATE ||','||
V_PAID_AMT ||','||
V_COMP_ID ||','||
V_RECEIPT_DATE ||','||
V_ORDER_QTY ||','||
V_RECEIPT_QTY ||','||
V_FRT ||','||
V_DUTY ||','||
V_SUPPLIER ||','||
-- V_FLAG ||','||
V_ELC_COST ||','||
V_ADJ_ELC;
UTL_FILE.PUT_LINE(V_file, V_flatfile_line);
end loop
commit;
UTL_FILE.fclose(V_file);
EXCEPTION
WHEN UTL_FILE.INVALID_PATH
THEN
DBMS_OUTPUT.PUT_LINE ('error: INVALID_PATH');
WHEN UTL_FILE.INVALID_MODE
THEN
DBMS_OUTPUT.PUT_LINE ('error: INVALID_MODE');
WHEN UTL_FILE.INVALID_FILEHANDLE
THEN
DBMS_OUTPUT.PUT_LINE ('error: INVALID_FILEHANDLE');
WHEN UTL_FILE.INVALID_OPERATION
THEN
DBMS_OUTPUT.PUT_LINE ('error: INVALID_OPERATION');
WHEN UTL_FILE.READ_ERROR
THEN
DBMS_OUTPUT.PUT_LINE ('error: READ_ERROR');
WHEN UTL_FILE.WRITE_ERROR
THEN
DBMS_OUTPUT.PUT_LINE ('error: WRITE_ERROR');
WHEN UTL_FILE.INTERNAL_ERROR
THEN
DBMS_OUTPUT.PUT_LINE ('error: INTERNAL_ERROR');
WHEN OTHERS THEN
-- v_error_code := SQLCODE;
-- v_error_message := SQLERRM;
-- dbms_output.put_line('ERROR: '||v_error_code);
-- dbms_output.put_line('ERROR: '||v_error_message);
RAISE_APPLICATION_ERROR(-20003,'sbduty - aborted');
END;
/It fails as soon as it encounters the V_FLAG in the V_flat_file_line. The data in the table has nulls for the FLAG, and some -ve numbers for the ELC_COST,ADJ_ELC..but that should'nt cause any problems does it?
Whats wrong with those 3 columns?
Errors that i get are:
SQL>Welcome-->BEGIN wrt_lifungduty; END;
ERROR at line 1:
ORA-20003: sbduty - aborted
ORA-06512: at "RMSBIZ.WRT_LIFUNGDUTY", line 117
ORA-06512: at line 1
SQL>Welcome-->117
117* RAISE_APPLICATION_ERROR(-20003,'sbduty - aborted');
SQL>Welcome-->
Thanks,
Chiru
Similar Messages
-
EFT Payment Program. Writing to a flat file using UTL Package
Hi guys
I wonder if someone can help me. I'm battling with something in pl/sql. I have a procedure that writes to a flat file. Each procedure I call writes a single section of the file, e.g "create_hdr_rec_line_fn" writes the header on top of the file and "create_std_trx_rec_line_fn" writes the body below the header. Then lastly the procedure that writes the trailer at the bottom of the file.
My problem comes here: I have a proc that calculates the hash total.
This is done by " utl_file.put_line(g_file_id, g_seed_number)". I want to write the hash total next to the trailer section of the file and not below it. How can I do this? Here's the example of the flat file produced. The very last line is the hash total, but I my hash total to be on the same line as the (Trailer). I want it to be just next to the trailer. I hope my question is clear. Please see my procedure below the flat file.
Thanking you in advance....
My flat file
FHSSVSDIM15000932008102810483220081028T (header)
SD0009300100001D19874200019873402211ACSA JOHANNESBURG INTERNATIONA (Line1-Detail)SC00093001D14540500014540057261IS H/O MAIN ACCOUNT 0000000124959315207 (Line-Transaction)
ST00093000000700000000070000000000020000001806378410000000000000000000001806378 (Trailer)
58298239848772973764654319387982 (hash total)
My procedure
PROCEDURE eft(errbuf OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY NUMBER,
p_payment_batch IN VARCHAR2) IS
v_eft_date VARCHAR2(100);
BEGIN
v_eft_date := TO_CHAR(SYSDATE, 'DD-MON-RRRR_HH24_MI_SS');
g_payment_batch := p_payment_batch;
g_file_name := 'EFT'||v_eft_date||'.txt';
g_file_id := utl_file.fopen(g_dir_name,
g_file_name,
'W');
utl_file.put_line(g_file_id,
create_hdr_rec_line_fn);
create_std_trx_rec_line_fn(g_file_id);
create_std_contra_rec_line_fn(g_file_id);
create_std_trailer_fn(g_file_id);
utl_file.put_line(g_file_id,
g_seed_number);
utl_file.fclose_all;
IF (update_tables != TRUE) THEN
Fnd_File.put_line(Fnd_File.LOG, 'Failed to update payment batch tables. Cancel the batch');
END IF;
EXCEPTION
WHEN OTHERS THEN
Fnd_File.put_line(Fnd_File.LOG, 'Print Error - eft' || SUBSTR(SQLERRM, 1, 250));
END eft;user643734 wrote:
Hi cdkumar
I'm not quite sure if I understand what you mean. Are you saying that I should use the "PUT" to write 'create_std_trailer_fn' and and then use the "PUT_LINE" to write 'g_seed_number'? Could you please show me what you mean by changing the proc I posted on my question with your suggestions.How about, rather than use code it for you, you try changing the code and giving it a go yourself.
Essentially PUT_LINE will write out the data and put a "new line" character on the end so the next output will appear on the following line; PUT will just output the data without terminating the line, so any subsequent output will just append to the end.
It's very simple. Give it a go. -
Delete data from a flat file using PL/SQL -- Please help.. urgent
Hi All,
We are writing data to a flat file using Text_IO.Put_Line command. We want to delete data / record from that file after data is written onto it.
Please let us know if this is possible.
Thanks in advance.
VaishaliThere's nothing in UTL_FILE to do this, so your options are either to write a Java stored procedure to do it or to use whatever mechanism the host operating system supports for editing files.
Alternatively, you could write a PL/SQL procedure to read each line in from the file and then write them out to a second file, discarding the line you don't want along the way. -
How to Create a Flat File using FTP/File Adapter
Can any body done workaround on creating the Flat file using FTP/File Adapter?.
I need to create a simple FlatFile either using of delimiter/Fixed length. using the above said adapters we can create XML file, i tried concatinating all the values into a single String and writing into a file, but it does not have proper structure
Can any body help me out on this..
Thanks
RamYou can create a text schema while creating a File Adapter. If schema is specified for File Adapter, it takes care of converting XML into fixed length or delimited format.
Thanks,
-Ng. -
How to get field separator in flat file using GUI_DOWNLOAD function
hi,
how to get field separator in flat file using GUI_DOWNLOAD function.
thanking you.Hi,
Use WRITE_FIELD_SEPARATOR = 'X'.
Check this sample code
REPORT z_file_download.
DATA: w_name(90) TYPE c.
DATA:
BEGIN OF fs_flight,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
price LIKE sflight-price,
currency LIKE sflight-currency,
END OF fs_flight.
DATA:
BEGIN OF fs_head,
carrid(10) TYPE c,
connid(10) TYPE c,
fldate(10) TYPE c,
price(10) TYPE c,
curr(10) TYPE c,
END OF fs_head.
DATA:
t_head LIKE
TABLE OF
fs_head.
DATA:
t_flight LIKE
TABLE OF
fs_flight.
fs_head-carrid = 'CARRID'.
fs_head-connid = 'CONNID'.
fs_head-fldate = 'FLDATE'.
fs_head-price = 'PRICE'.
fs_head-curr = 'CURRENCY'.
APPEND fs_head TO t_head.
SELECT-OPTIONS:
s_carrid FOR fs_flight-carrid.
START-OF-SELECTION.
SELECT carrid
connid
fldate
price
currency
FROM sflight
INTO TABLE t_flight
WHERE carrid IN s_carrid.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'D:\flight.xls'
FILETYPE = 'ASC'
* APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = t_head
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'D:\flight.xls'
filetype = 'ASC'
append = 'X'
write_field_separator = 'X'
TABLES
data_tab = t_flight
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc EQ 0.
MESSAGE 'Download successful' TYPE 'I'.
ENDIF.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Idoc to flat file using Integration process does not show up at all
Hello All,
I created a scenario IDOC to Flat File using Integration Process and one without IntegrationProcess. I am able to execute the one without Integration Process easily.
However when I send the IDOC from SAP then the Integration Process scenario just does not work.
I Checked SXMB_MONI There is no entry for the Integration Process.I can see entry for other without Integration Process.
SXI_CACHE : I can see my Integration Process active
SWEQADM : I have activated the Event Queue and Background job
SWF_XI_ADM_BPE : ALL BPE is showing green status.
All syntax check on IP are fine.
There is no Basis Help for me so there could be some additional basis steps which need to be configured. Has anyone faced such an issue with Integration Process?
Regards
PrashantaHope this might help you. when u configure an IDoc as Sender with BPM this is how you proceed.
<b>1<b>. let us split the scenario into two</b>.</b>
a. <b>Sender to BPM</b> ( Integration Process).
b. <b>BPM to Receiver</b>.
<b>2. First let us configure the first Sender to BPM.</b>
a. Sender Agreement( <b>Not required</b> ).
b. Receiver Agreement( <b>NOT Required</b>).
c. Receiver Determination( Sender Service, Outbound Interface, Receiver Service(<b>Integration Process</b>).
d. Interface Determination( Inbound Interface(Sender Abstract Interface), Message Mapping(NOT Required if your using transformation stepin Integration Process)).
<b>3. Now let us configure the Second BPM to Receiver.</b>
a. Sender Agreement( <b>NOT Required</b>)
b. Receiver Agreement( Sender Service(<b>Integration process</b>), Receiver Abstarct Interface,Receiver service, Inbound Interface).
c. Receiver Determination( Sender Service(Integration Process), Receiver Abstarct Interface,Receiver Service).
d. Interface Determination( Inbound Interface, Message Mapping(<b>NOT Required</b>)).
So Finally we have <b>One Receiver Agreement</b>, <b>Two Receiver Determinations</b>, <b>Two Interface Determinations</b>.
Please let me know if you have any more queries.
Regards
Gopi -
How to extract data from Essbase to Flat File using ODI
Hi,
Anyone know how to extract data from Essbase to Flat File using ODI?
Thanks in advance.
Regards,
SumardiHi,
Have you read through :-
Oracle Data Integrator Adapter for Hyperion Essbase Getting Started - http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/odiess_getting_started.pdf
Oracle Data Integrator Adapter for Hyperion Essbase User's Guide - http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/odiess_users.pdf
If you have read them and are still have a problem at what stage are you having the issues?
Cheers
John
http://john-goodwin.blogspot.com/ -
Problem while writing data on xls file using jxl API
Hi,
I am getting problem while writing data on excel file using jxl api.
When i write data on file and all handles associated to the file are closed, file size increases but when i open the file nothing is written in it and when file is closed manually from excel window, file size decreased to its original that was before writing data.
here is code:
FileOutputStream os = new FileOutputStream(this.dirPath + this.fileName, true);
WritableWorkbook this.workbook = Workbook.createWorkbook(os);
after writing data following handler are closed:
this.os.flush();
this.workbook.write();
this.workbook.close();
this.os.close();
this.os = null;
can any body help me.
Thanks in advanceErr, I did help you. I did understand your problem; and I solved it for you. What was missing was that you apparently made no effort to understand what you were being told. Or even consider it. You just argued about it, as though you were the one with the solution, instead of the one whose code didn't work.
And the other thing that was missing was the part where you said 'thank you' to me for solving your problem. Somewhat more appropriate than biting the hand that fed you, frankly. I do this for nothing, on my own gas, and it's extremely irritating when people keep asking about problems I have already solved for them. I am entitled to discourage that. It's part of making them more efficient actually.
But it happens often enough that it also makes me think I'm just wasting my time. Probably I am. -
DB2 Version 8 to Flat Files using ODI
Hi,
We are trying to load data from DB2 V8 to flat files using ODI.
Can anybody help me in this to configure server in Topology.
Thanks
AshwiniHi,
How are you? Let me try contribute a little...
A)
1) The OS isn't a problem, once you link it at topology will be OK.
2) If you have a fix name just create a datastore to it, if not, there are techniques to got dynamic file names
3) When you say "*.dat, *.cvs" maybe you refer to the internal format of file (record separator, decimal point, etc) all of this is configurable on datastore that represents the file at ODI.
B) Yes, the only requisite is to have the write and read rights.
C) The most simple way is create a refresh variable that get the data in any format you wish..
Does it make any sense to you?
Cezar Santos -
Error writing data in a flat file using UTL_FILE feature
Hi All,
I have written a package which fetches data from four different cursors and inserts into a temporary table.
Now this temporary table is used to write data in a file using the UTL_FILE feature.
fhandler :=
UTL_FILE.fopen (l_path,'Demand_Transactions_'
|| TO_CHAR (SYSDATE, 'YYYYMMDDHH24MI')
|| '.txt',
'w',
max_linesize => 32767
This table has 62593 records and when it starts writing data into the file from the table it errors out after writing 30045 records with the error - ORA-01722: invalid number.
Can anyome please advise me is it because of the max_linesize => 32767. If not then what can be the possible reason.
Any help in this would be highly appreciated.
Regards,
Shruti891330 wrote:
Hi All,
I have written a package which fetches data from four different cursors and inserts into a temporary table.
Now this temporary table is used to write data in a file using the UTL_FILE feature.
fhandler :=
UTL_FILE.fopen (l_path,'Demand_Transactions_'
|| TO_CHAR (SYSDATE, 'YYYYMMDDHH24MI')
|| '.txt',
'w',
max_linesize => 32767
This table has 62593 records and when it starts writing data into the file from the table it errors out after writing 30045 records with the error - ORA-01722: invalid number.
Can anyome please advise me is it because of the max_linesize => 32767. If not then what can be the possible reason.Max linesize is the number of characters in a line before a newline has to be issued, not the number of rows written.
The error would indicate that you have a character to number conversion going on somewhere but the characters are not numeric so it's failing that conversion.
This doesn't sound like a UTL_FILE issue, but more to do with how you are building up your strings to output to the file.
You would need to show us your code that builds up the lines you are writing out, with details of the datatypes of any of the columns/variables included in that. -
Filename for flat file using J2EE FILE FTP Receiver adapter
Hi there,
I am struggling to do the following:
I have a J2EE File receiver that sends a file with a specific name to a FTP destination. I define the target filename in my graphical mapping using certain criteria and a incremental number. In my adapter I use variable substitution to select that value in the payload as the filename. Up to this point everything works fine.
The problem is that I convert the payload to a flat structure using xslt before writing it out and because of that the adapter cannot find my value as defined in the variable I use for the name.
Now, obviously if I move the xslt module after the CallAdapter module, the file won't be converted to a flat structure.
Can anyone give me advice on how I can do the flat conversion <u>and</u> the specific filename from the payload?
Thanks in advance,
JohanHi,
Instead of using variable substitution, use adapter specific identifiers to set the file name in mapping.
Ref:/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
Regards,
Jai Shankar -
Build daily Big flat file using SAP R/3 material master data
Hi all,
I must build an interface between SAP R/3 4.7 and an external application
Daily a flat file must be generated contaning Material data in full exchange mode
(volume 100 000 materials, <10 fields => ~ File of 30Mo)
No complex mapping, only format mapping (Ex : Price quantity...)
I don't know yet if I will use Idocs or BAPI to extract data. However, I'm sure I must use multiple inbound messages because of volume
After reading documentation, I consider the both following solutions to manage it :
1) A simple asynchronous interface with a file adapter in construction mode APPEND to build flat file progressively with arrival of SAP messages
=>
viable solution ?
Is there problem of concurrent access to file in such a solution ?
(idocs or bapi data will be processed ones following the others )
2) BPM Collecting and Bundling Messages - One Interface
(Unlimited Loop with Deadline trigger correspondint to time I must build flat file)
=>
Each SAP message is a small message but the outbound XML will represent a 30 Mo flat file => Is it a problem ??
Which solution do you advise ?
Is there another ?
Last question : (more general one)
In such scenario, I can't see XI-value added comparing a creation of flat file directly with R/3.
I will generate a big number of idocs, use a big part of XI memory ...
Can you give me your opinion about it ?
Thanks a lot
Best regards
Jean-Charles
Message was edited by:
Jean-Charles
Message was edited by:
Jean-CharlesHi Jean-Charles,
>>>volume 100 000 materials, <10 fields => ~ File of 30Mo
You have a performance task...
>>>Is there problem of concurrent access to file in such a solution ?
No, the adapter framework has its own queueing, the message would be stored and executed later. If sequence is important, you can use EOIO as well.
>>>BPM Collecting and Bundling Messages - One Interface
BPM is not required in your case, you should avoid becoz of performance task. You can append at file adapter, no problem. Bundling and splitting is even possible at Integration Server without BPM.
>>>Each SAP message is a small message but the outbound XML will represent a 30 Mo flat file => Is it a problem ??
Avoid using BAD words
>>>Each SAP message is a small message but the outbound XML will represent a 30 Mo flat file => Is it a problem ??
Use the <a href="https://websmp110.sap-ag.de/quicksizing">Quick Sizer</a> for sizing the hardware.
Regards,
Udo -
Urgent: Problem to load Flat file using DTP.
Hi Experts,
I try to load a flat file PSA->DSO->INFOCUBE using DTP.
I my flatfile in the application server in csv format.
in the My data source I opted Adapter as Load Text -Type file from Application Server.
Data Format : I test with both the potions : Fixed length & Separated with Separator( For example CSV) .
If I check the preview: I cant find any data and get the message: Inbound processing of data package 000001 finished
when I try to Load the data thorough PC the load was successfull but only 0 records are transfered and added to PSA:; DSO and Info Cube.
The test file contains around 20 records.
Any suggestions please.
Thanks & RegardsHi Sailekha..
in the My data source I opted Adapter as Load Text -Type file from Application Server.
Data Format : I test with both the potions : Fixed length & Separated with Separator( For example CSV) .
Note: As per ur info:
In the Flat file Data source :
1. You have to maintain the Adapter as:
Load Text -Type file from Application Server
Data Format : Separated with Separator
Then Use the "Proposal" Tab to generate the field proposals.
(Only in BI 7.0 this option is available).
After that check the Preview in "Preview" Tab.
Hope it works...
Cheers,...
Varma -
Reading data from flat file Using TEXT_IO
Dear Gurus
I already posted this question but this time i need some other changes .....Sorry for that ..
I am using 10G forms and using TEXT_IO for reading data from flat file ..
My data is like this :-
0|BP-V1|20100928|01|1|2430962.89|27|2430962.89|MUR|20100928120106
9|2430962.89|000111111111|
1|61304.88|000014104113|
1|41961.73|000022096086|
1|38475.65|000023640081|
1|49749.34|000032133154|
1|35572.46|000033093377|
1|246671.01|000042148111|
Here each column is separated by | . I want to read all the columns and want to do some validation .
How can i do ?
Initially my requirement was to read only 2 or 3 columns so i did like this ...
Procedure Pay_Simulator(lfile_type varchar2,lac_no varchar2,lcur varchar2,lno_item number,ltotal number,ldate date,lpay_purp varchar2,lfile_name varchar2)
IS
v_handle utl_file.file_type;
v_filebuffer varchar2(500);
line_0_date VARCHAR2 (10);
line_0_Purp VARCHAR2 (10);
line_0_count Number;
line_0_sum number(12,2);
line_0_ccy Varchar2(3);
line_9_sum Number(12,2);
line_9_Acc_no Varchar2(12);
Line_1_Sum Number(12,2);
Line_1_tot Number(15,2) := 0;
Line_1_flag Number := 0;
lval number;
lacno varchar2(16);
v_file varchar2(20);
v_path varchar2(50);
Begin
v_file := mcb_simulator_pkg.GET_FILENAME(lfile_name); -- For the file name
v_path :=rtrim(regexp_substr( lfile_name , '.*\\' ),'\'); For the Path
v_path := SUBSTR (lfile_name,0, INSTR (lfile_name, '\', -1));
v_handle := UTL_FILE.fopen (v_path, v_file, 'r');
LOOP
UTL_FILE.get_line (v_handle, v_filebuffer);
IF SUBSTR (v_filebuffer, 0, 1) = '0' THEN
SELECT line_0 INTO line_0_date
FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
FROM DUAL
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
WHERE rn = 3;
SELECT line_0 INTO line_0_Purp
FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
FROM DUAL
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
WHERE rn = 4;
SELECT line_0 INTO line_0_count
FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
FROM DUAL
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
WHERE rn = 7;
SELECT line_0 INTO line_0_sum
FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
FROM DUAL
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
WHERE rn = 8;
SELECT line_0 INTO line_0_ccy
FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_0, ROWNUM rn
FROM DUAL
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
WHERE rn = 9;
ELSIF SUBSTR (v_filebuffer, 0, 1) = '9' THEN
SELECT line_9 INTO line_9_Acc_no
FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_9, ROWNUM rn
FROM DUAL
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
WHERE rn = 3;
SELECT line_9 INTO line_9_sum
FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_9, ROWNUM rn
FROM DUAL
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
WHERE rn = 2;
ELSIF SUBSTR (v_filebuffer, 0, 1) = '1' THEN
line_1_flag := line_1_flag+1;
SELECT line_1 INTO line_1_sum
FROM (SELECT LTRIM (REGEXP_SUBSTR (v_filebuffer, '[^|]+{1}', 1, LEVEL)) line_1, ROWNUM rn
FROM DUAL
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (v_filebuffer, '[^|]*')) + 1)
WHERE rn = 3;
Line_1_tot := Line_1_tot + line_1_sum;
END IF;
END LOOP;
DBMS_OUTPUT.put_line (Line_1_tot);
DBMS_OUTPUT.PUT_LINE (Line_1_flag);
UTL_FILE.fclose (v_handle);
END;
But now how can i do ? Shall i use like this select Statement for all the columns ?Sorry for that ..
As per our requirement ...
I need to read the flat file and it looks like like this .
*0|BP-V1|20100928|01|1|2430962.89|9|2430962.89|MUR|20100928120106*
*9|2430962.89|000111111111|*
*1|61304.88|000014104113|*
*1|41961.73|000022096086|*
*1|38475.65|000023640081|*
*1|49749.34|000032133154|*
*1|35572.46|000033093377|*
*1|246671.01|000042148111|*
*1|120737.25|000053101979|*
*1|151898.79|000082139768|*
*1|84182.34|000082485593|*
I have to check the file :-
Validation are 1st line should start from 0 else it should raise an error and insert that error into one table .
The for 2nd line also same thing ..it should start from 9 else it should raise an error and insert that error into one table .
Then the 3rd line should start from 1 else it should raise an error and insert that error into one table .
After that i have to do a validation like i will read the 1st line 2nd column .. It should be like this BP-V1 else raise an error and insert that error to a table . Then i will check the 3rd column which is 20100928 , it should be YYYYMMDD format else same thing ERROR.
Then like this for all columns i have different validation .......
Then it will check for the 2nd line 3rd column . this is an account no .1st i will check it should be 12 char else ERROR .Then I will check that what user has imputed in the form.Like for example User putted 111111111 then i will check with this 000111111111 which is there in the 2nd line . I have to add 000 before that Account no which user imputed .
Then the lines which is starting from 1 , i have to take all the 2nd column for all the lines which is starting from 1 and i have to do a sum . After that i have to compare that sum with the value in the 1st lines ( Starting from 0) 6th column . It should be same else ERROR ...
Then same way i have to count all the lines which is starting from 1 . Then i have to compare with the 7th column of 1st line . It should be same . Here in this file it should be 9.
MY CODE IS :-
Procedure Pay_Simulator(lfile_type varchar2,lac_no varchar2,lcur varchar2,lno_item number,ltotal number,ldate date,lpay_purp varchar2,lfile_name varchar2)
IS
v_handle TEXT_IO.file_type;
v_filebuffer varchar2(500);
line_0_date VARCHAR2 (10);
line_0_Purp VARCHAR2 (10);
line_0_count Number;
line_0_sum number(12,2);
line_0_ccy Varchar2(3);
line_9_sum Number(12,2);
line_9_Acc_no Varchar2(12);
Line_1_Sum Number(12,2);
Line_1_tot Number(15,2) := 0;
Line_1_flag Number := 0;
lval number;
lacno varchar2(16);
v_file varchar2(20);
v_path varchar2(50);
LC$String VARCHAR2(50) ;--:= 'one|two|three|four|five|six|seven' ;
LC$Token VARCHAR2(100) ;
i PLS_INTEGER := 2 ;
lfirst_char number;
lvalue Varchar2(100) ;
Begin
v_file := mcb_simulator_pkg.GET_FILENAME(lfile_name); For the file name
v_path :=rtrim(regexp_substr( lfile_name , '.*\\' ),'\'); For the Path
--v_path := SUBSTR (lfile_name,0, INSTR (lfile_name, '\', -1));
Message(lfile_name);
v_handle := TEXT_IO.fopen(lfile_name, 'r');
BEGIN
LOOP
TEXT_IO.get_line (v_handle, v_filebuffer);
lfirst_char := Substr(v_filebuffer,0,1);
--Message('First Char '||lfirst_char);
IF lfirst_char = '0' Then
Loop
LC$Token := mcb_simulator_pkg.Split( v_filebuffer, i , '|') ;
Message('VAL - '||LC$Token);
lvalue := LC$Token;
EXIT WHEN LC$Token IS NULL ;
i := i + 1 ;
End Loop;
Else
Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (9999,'0002','First line should always start with 0');
Forms_DDL('Commit');
raise form_Trigger_failure;
End if ;
TEXT_IO.get_line (v_handle, v_filebuffer);
lfirst_char := Substr(v_filebuffer,0,1);
LC$Token := mcb_simulator_pkg.Split( v_filebuffer, i , '|') ;
--Message('Row '||LC$Token);
IF lfirst_char = '9' Then
Null;
Else
Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (8888,'0016','Second line should start with 9');
Forms_DDL('Commit');
raise form_Trigger_failure;
End IF;
LOOP
TEXT_IO.get_line (v_handle, v_filebuffer);
lfirst_char := Substr(v_filebuffer,0,1);
LC$Token := mcb_simulator_pkg.Split( v_filebuffer, i , '|') ;
--Message('Row '||LC$Token);
IF lfirst_char = '1' Then
Null;
Else
Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (7777,'0022','The third line onward should start with 1');
Forms_DDL('Commit');
raise form_Trigger_failure;
End if;
END LOOP;
--END IF;
END LOOP;
EXCEPTION
When No_Data_Found Then
TEXT_IO.fclose (v_handle);
END;
Exception
When Others Then
Message('Other error');
END;
I am calling the FUNCTION which you gave SPLIT as mcb_simulator_pkg.Split. -
How o place Flat file Using JMS Adapter.
Hi Frnds,
I have one scenario ,
Sender side i am having IDOC, i want convet the IDOC into Flat file. But my receiver side i have to use only JMS Adapter,
Flat file i have to place in FTP Server using JMS Adapter.
Can ne share your thoughts..
Regards,
rajRaj,
The below Link will help
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/50061bd9-e56e-2910-3495-c5faa652b710
Surya,
Welcome Back to SDN.
Regards
Agasthuri Doss
Maybe you are looking for
-
Help: How to create a query like this?
I am working on a report and I am facing on a question like this: TABLE TEST has two columns A and B A B 2 INFO21 2 INFO22 3 INFO31 3 INFO32 3 INFO33 I'd like to create a query which will return A INFO 2 INFO21, INFO22 3 INFO31, INFO32, INFO33 Please
-
1.4.2 breaking wrt socket bind?
I am trying to run jmechanic in eclipse. the problem is that it can connect between JVMs in 1.4.1_07 just fine. But if fails with socket in use on 1.4.2_03. I see nothing in 1.4.2 docs indicating a socket change. what gives??
-
I have conneted both a 19-inch monitor and 32 inch tv. I find when I siwtch the reolution of one, it affects that of the other. Turn the 19 inch monitor to a small resolution gives me more possibilities for the Aqous TV. Assume that the G5 drives up
-
Odd Bug Check Event ID 18 - BCCode 124; Can anyone help?
Hello, I understand that each bug check is different even if the codes are the same due to different real world problems but I'm stumped, granted I don't know too much. Hence I am here. I'm getting a BSOD every time I let my computer idle for 10 and
-
Transaction to maintain order currency of vendor (LFM1-WAERS)
Hi, what transaction do we maintain order currency of vendor (LFM1-WAERS)? Thanks a lot!