Help needed in Loading excel data to staging table from OAF Page
Hi All,
We have a requirement from the client on loading of a excel sheet data into staging table using OAF page.
We were able to load a CSV file into staging table via OAF. The approach we used is we created a item of style 'messageFileUpload', which would pick the CSV file from desktop and we wrote the logic on the controller to place the file into server and then sumit a concurrent program to load the data into the staging table.
But client wants data from the excel file to be loaded into staging table. Is there any way(approach) by which we can convert the excel file data into .CSV file using OAF?
Any help or pointers on this will be highly apperciated.
Thanks,
Chethana
Hi,
Read through this :
Need to upload a CSV/Excel to a table in OAF page
Thanks,
Gaurav
Similar Messages
-
Want to load excel data into oracle table with out changing it to CSV
Hello all,
I have a requirement in dumping excel data into oracle database table without changing it to CSV file and this has to be used in normal sql/plsql environment i.e., pkg/procedure cant be used in the forms also...
so, can u guys can help me out in this
thanks.............The link Pavan provided discusses Oracle Heterogeneous Services. This allows you (using ODBC) to create a database link from Oracle to a non-Oracle data source like Excel. This would allow you to query the Excel data source from SQL*Plus or any other client tool. But that is probably going to require that your Oracle database is running on Windows since I'm not aware of any Excel ODBC drivers for Unix.
Another potential option would be to write a Java stored procedure that parsed the file. There are a few different Java libraries that can read and write Excel data files. You could load one of those libraries into the database's JVM and then write Java code that parsed the file. You would then be able to call your Java stored procedure from PL/SQL.
Justin -
How to load excel data into oracle table
How do i load data from an excel file with several worksheets into an oracle table?
using Oracle 10g
Excel
sample data of excel
Name eric Name mary
AccountNo 123 AccountNo 321
amount1 5.0 Amount1 1.0
amount2 5.5 Amount2 2.0
amount3 6.0 Amount3 3.0
Total 16.5 Total 6.0
Name larry Name beth
AccountNo 123 AccountNo 321
amount1 5.0 Amount1 1.0
amount2 5.5 Amount2 2.0
amount3 6.0 Amount3 3.0
Total 16.5 Total 6.0
Note: Assume data are aligned into columns like a real excel workbookI have some used something like this.
don't ask any details as I am not a xl person, but i think its pretty straight forword.
hope its helpful for you or someone else
Dim i As Integer
Dim conn As New ADODB.Connection
Dim strInsert As String
Dim strExecInsert As String
conn.ConnectionString = "Provider=MSDAORA.1;User ID=scott;password=tiger;Data Source=orcl.world;Persist Security Info=False"
conn.Open
strInsert = "insert into xlsc ( emp, dept, doj," & _
"dol, dob, Ce ,ED, v_date ) values("
'this is to insert first 2347 rows from xl to orcl
While i < 2348
strExecInsert = strInsert & "'" & _
Trim(Cells(i, 1).Value) & "','" & _
Trim(Cells(i, 2).Value) & "','" & _
Trim(Cells(i, 3).Value) & "','" & _
Trim(Cells(i, 4).Value) & "','" & _
Trim(Cells(i, 5).Value) & "','" & _
Trim(Cells(i, 6).Value) & "','" & _
Trim(Cells(i, 7).Value) & "','" & _
Trim(Cells(i, 8).Value) & "' )"
'MsgBox strExecInsert
If Cells(i, 1).Value <> "" Then
conn.Execute (strExecInsert)
End If
i = i + 1
Wend
'conn.Execute ("commit")
conn.Close
End Sub -
Need to load the data through excel for plan data through IP?
Hi all,
The user needs to load the data through the excel and click on the save button so that the data is saved in the cube through integrated planning.
The objects used are
customer, material, plant, calendarmonth sales qty, gross billing!!
Can anyone pls let me know how to do this?
ThanksHi,
You can use the following How to guide to load data from file into transactional cube.
If using IP :
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/90cef248-29e0-2910-11bb-df8dece7e22c?quicklink=index&overridelayout=true
Can also Refer to Marc's Blog:
/people/marc.bernard/blog/2007/11/25/how-to-load-a-file-into-sap-netweaver-bi-integrated-planning-part-1
If you are using bPS you can get the details in Wiki also for the same.
You can then create the hyperlink in Excel ,which user can use to upload data which can then be saved to cube using save button. -
Step- by- Step on How to Load Excel data into Crystal Reports?
Hi Friends,
Can anyone send me a Step- by- Step on How to Load Excel data into Crystal Reports? Pls help me. Thanks in Advance.
VijayIt's also important to 'prep' the excel file prior to connecting to it.
Give the data tab a meaningful name
Make sure the column headers are unique and that every column has a header
Delete any blank tabs
If you have trouble with Excel changing the data type of a field (say, a social security number you want to be a string value rather than a number so you don't lose leading zero) an alternative would be to save the spreadsheet file as a CSV, create a schema.ini to specify the data types for each column (example below) and use the same steps to connect except instead of choosing Excel 8.0, scroll to the bottom and choose Text. You have to make sure the CSV file is in the same folder as the schema.ini file that defines the columns.
Schema.ini example:
200912PUSD.csv
ColNameHeader=True
Format=CSVDelimited
MaxScanRows=25
CharacterSet=OEM
Col1=SSN Char Width 9
Col2=LAST_NM Char Width 25
Col3=FIRST_NM Char Width 25
Col4=DOB Date
Col5=STDNT_ID Char Width 10
Col6=SORTKEY Char Width 10
Col7=SCHOOL_NM Char Width 30
Col8=OTHER_ID Integer
Col9=GRADE Char Width 2
The filename in the first line needs to have the [] brackets around it, but I couldn't get it to display in this forum correctly.
Edited by: Eric Petersen on Jan 27, 2010 9:40 AM -
SSIS Load Excel Data with out MS Office
Hello All,
Requirement : Load Excel Data to SQL Server Table using SSIS 2012 with out using OPENROWSET(Ad Hoc Distributed Queries)
SET UP : SQL SERVER 2012-64 Bit and Access DataBase Engine 2010 -64 Bit
Problem :: No MS Office Install
Help on this as how can this be achieved
When I use Excel as Source , I get error "MS Ace OLEDB 12.0" provider is not install on local Machine but if I take OLEDB Source and use OPENROWSET , I can see and Load data in SQL Table ..Hi Mushtaq308,
According to your description, you want to read write Excel using SSIS without installing MS office on the target environment. In that case, missing of data access component on the machine stops working of SSIS package.
Then following any one installation on the machine can solve this issue:
2007 Office System Driver: Data Connectivity Components
Microsoft Access Database Engine 2010 Redistributable
Besides, for the error message that “the 'microsoft.ace.oledb.12.0' provider is not registered on the local machine”, please refer to the following thread:
https://social.msdn.microsoft.com/Forums/en-US/1d5c04c7-157f-4955-a14b-41d912d50a64/how-to-fix-error-the-microsoftaceoledb120-provider-is-not-registered-on-the-local-machine?forum=vstsdb
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Help with Importing Excel Data into Formatted Tables
This is my first post, here, so please be gentle!
I am a relatively new user of InDesign CS4, and I am creating a 70-pg manufacturer's price book. A very large portion of each page is going to be size and price information imported from a large Excel spreadsheet.
I have created the table format that I'd like to use for each page, but the trouble comes when I import the Excel data into that table. For some reason, when I import, it all dumps into one cell. Would it be best to import as an unformatted table, and then format the table each time, or is there a way to simply import the data into my pre-formatted table? I've seen how the former is done, but the latter seems much easier (...although that could be my inexperience talking).
Any advice would be greatly appreciated!
Thanks so much,
Laura (V1500)Thank you both so much for your time! This is exactly what I needed.
Cheers
Laura -
Importing excel data into oracle tables
Hello gurus,
Importing excel data into oracle tables..
I know this is the most common question on the thread ...First, i searched the forum, i found bunch of threads with loading data using sqlloader, converting excel into .Txt, tab delimited file, .csv file etc....
Finally i was totally confused in terms how to get this done....
Here is wat i have
- Excel file on local computer.
- i have laod data into dev environment tables(So no risk involved, but want to try something simple)
- Oracle version 11.1.0.7
- Sqlplus and toad (editors)
Here is wat i like to do ....i dont know if its possible
- Without going to unix server can i do everthing on local system by making use of oracle db and sqlplus or toad
SQLLOADER might be one option...but i dont want to go the unix server for placing files and logs and stuff.
Wat will be best and simplest option to do?? and wat format will best to convert from excel into csv, or txt or tab delimited etc.....
If you suggest sqlloader, any code example will be greatly appriciated.
Thank you so much!!!Hi,
user642297 wrote:
Imran,
This is increadible option in toad!!! It works absolutely sweet!! I have toad 9.7 version. IT works great. Thank you so much!!You are welcome :)
Well i have further discussion on this ....this option is great if you doing in staging or development area. What if your doing in prod?? If you automating the sqlloader then how do u do it?? I think we still need to stick with traditional approach of laoding data by making use of SQLLoader right ?? If m wrong please correct me.well, in our case, we do have access to a custom schema in prod where we create the staging table and load the data from datafiles.
try this:
load data
infile 'C:\dest.csv'
into table dest_table
fields terminated by "~" optionally enclosed by '"'
TRAILING NULLCOLS
(name,
owner_nm,
description_column,
UPDT_DT DATE 'MM/DD/YYYY')
{code}
you can get more info about sql loader and your error here:
http://download.oracle.com/docs/cd/B10501_01/server.920/a96652/ch05.htm
http://www.allinterview.com/showanswers/53766.html
And one more quick question ...i found an example of control file , in that i see .dat format file. Is it a data file ?? can i try that option ?? But in excel i didnt see to convert the .dat format file.
Any thoughts ???
It is same as a delimiter text file.
steps to create a .dat file (from a excel file):
1. Insert a column between two columns and populate it with the delimiter (in our case, it is ~)
2. Save the file as unicode text.
3. Open the file in text editor and remove all the tabs (find an replace with blank)
4. Save the file as "DEST.dat". Select encoding as UTF-8 while saving.
5. Your .dat file is ready.
Regards
Imran
Edited by: Imran Soudagar on Apr 22, 2010 10:22 PM -
How can we export the data from OAF Page to Excel instead of .csv or .txt
Hello,
How can we export the data from OAF Page to Excel instead of .csv or .txt
When i click on the export button it is exporting to txt file, But i need to export the data into Excel by default
Please help me
Thanks in advance
Thanks,
Raju
We have changed the below profile option to get the data in excel by default
Profile Name Export MIME type
Profile Code FND_EXPORT_MIME_TYPE+
Existing Value: text/tab-separated-values+
Change as: Excel
Thank you,
Raju
Edited by: 1006649 on May 21, 2013 10:55 AMWe have changed the below profile option to get the data in excel by default
Profile Name Export MIME type
Profile Code FND_EXPORT_MIME_TYPE+
Existing Value: text/tab-separated-values+
Change as: Excel
Thank you,
Raju -
Hi,
Iam new to the xml,
can u please anyone help me how to write procedure to load the data into a table using xml as input parameter to a procedure and xml file is as shown below which is input to me.
<?xml version="1.0"?>
<DiseaseCodes>
<Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
</DiseaseCodes>.
Regards,
vikram.here is the your XML parse in 11g :
select *
from xmltable('//Entity' passing xmltype
'<?xml version="1.0"?>
<DiseaseCodes>
<Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
</DiseaseCodes>
') columns
"dcode" varchar2(4000) path '/Entity/dcode',
"ddesc" varchar2(4000) path '/Entity/ddesc',
"reauthflag" varchar2(4000) path '/Entity/reauthflag'
dcode ddesc reauthflag
0 (I87)Other disorders of veins - postphlebitic syndrome 0
0 (J04)Acute laryngitis and tracheitis 0
0 (J17*)Pneumonia in other diseases - whooping cough 0
SQL>
Using this parser you can create procedure as
SQL> create or replace procedure myXMLParse(x clob) as
2 begin
3 insert into MyXmlTable
4 select *
5 from xmltable('//Entity' passing xmltype(x) columns "dcode"
6 varchar2(4000) path '/Entity/dcode',
7 "ddesc" varchar2(4000) path '/Entity/ddesc',
8 "reauthflag" varchar2(4000) path '/Entity/reauthflag');
9 commit;
10 end;
11
12 /
Procedure created
SQL>
SQL>
SQL> exec myXMLParse('<?xml version="1.0"?><DiseaseCodes><Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity></DiseaseCodes>');
PL/SQL procedure successfully completed
SQL> select * from MYXMLTABLE;
dcode ddesc reauthflag
0 (I87)Other disorders of veins - postphlebitic syndrome 0
0 (J04)Acute laryngitis and tracheitis 0
0 (J17*)Pneumonia in other diseases - whooping cough 0
SQL>
SQL>
Ramin Hashimzade -
Help with uploading an excel file to a table using an application
Hello,
Can anyone please help me out with this issue. I have apex application where in the end users upload an excel file to a table. For this I have followed the solution provided in this link
http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
Using the above solution, I was able to upload the excel data to a table "sample_tbl1" successfully with fields Id,acct_no,owner_name,process_dt. But the thing is I want accomdate a particular condition while uploading the file data, to check see if the acct_no already exists in another table say "sample_tbl2" or not. If acct_nos already exists in sample_tbl2 then give out an error displaying the list of account numbers that already exists in the database. Below is the code which I am using to upload file data to a table.
DECLARE
v_blob_data BLOB;
v_blob_len NUMBER;
v_position NUMBER;
v_raw_chunk RAW(10000);
v_char CHAR(1);
c_chunk_len number := 1;
v_line VARCHAR2 (32767) := NULL;
v_data_array wwv_flow_global.vc_arr2;
v_rows number;
v_sr_no number := 1;
l_cnt BINARY_INTEGER := 0;
l_stepid NUMBER := 10;
BEGIN
--Read data from wwv_flow_files</span>
select blob_content into v_blob_data
from wwv_flow_files
where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER)
and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER);
v_blob_len := dbms_lob.getlength(v_blob_data);
v_position := 1;
/* Evaluate and skip first line of data
WHILE (v_position <= v_blob_len ) LOOP
v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position);
v_char := chr(hex_to_decimal(rawtohex(v_raw_chunk)));
v_line := v_line || v_char;
v_position := v_position + c_chunk_len;
-- When a whole line is retrieved
IF v_char = CHR(10) THEN
-- Clear out
v_line := NULL;
EXIT;
END IF;
END LOOP;
-- Read and convert binary to char</span>
WHILE ( v_position <= v_blob_len ) LOOP
v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position);
v_char := chr(hex_to_decimal(rawtohex(v_raw_chunk)));
v_line := v_line || v_char;
v_position := v_position + c_chunk_len;
-- When a whole line is retrieved </span>
IF v_char = CHR(10) THEN
-- Convert comma to : to use wwv_flow_utilities </span>
v_line := REPLACE (v_line, ',', ':');
-- Convert each column separated by : into array of data </span>
v_data_array := wwv_flow_utilities.string_to_table (v_line);
-- Insert data into target table
EXECUTE IMMEDIATE 'insert into sample_tbl1(ID,ACCT_NO,OWNER_NAME,PROCESS_DT)
values (:1,:2,:3,:4)'
USING
v_sr_no,
v_data_array(1),
v_data_array(2),
to_date(v_data_array(3),'MM/DD/YYYY');
-- Clear out
v_line := NULL;
v_sr_no := v_sr_no + 1;
l_cnt := l_cnt + SQL%ROWCOUNT;
END IF;
END LOOP;
delete from wwv_flow_files
where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER)
and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER);
l_stepid := 20;
IF l_cnt = 0 THEN
apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold">Please select a file to upload.</span></p>' ;
ELSE
apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold;color:green">File uploaded and processed ' || l_cnt || ' record(s) successfully.</span></p>';
END IF;
l_stepid := 30;
EXCEPTION WHEN OTHERS THEN
ROLLBACK;
apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold;color:red">Failed to upload the file. '||REGEXP_REPLACE(SQLERRM,'[('')(<)(>)(,)(;)(:)(")('')]{1,}', '') ||'</span></p>';
END;
{code}
Can anyone please help me, how do i accomdate the condition within my existing code.
thanks,
OrtonOrton,
From your code it appears that the account No comes in the second column of the file = > v_data_array(1)
So You can put a conditional block around the execute immediate code that inserts the records
For instance
SELECT count(1) INTO ln_account_no_exists from <"sample_tbl2> where account_no = v_data_array(1);
IF ( ln_account_no_exists > 0 ) THEN
--Account No: already exists
<Do what you want to do here >
ELSE
EXECUTE IMMEDIATE ...
END IF:
{code}
Inorder to handle the account no records which exists you can
<li>Raise an exception
<li> Write record to table or insert into collection and then use a report region in the page based on this table/collection to show error records
<li> Append errored account No:s to the Success Message Variable programmatically(this variable is used by PLSQL process success/error message )
{code}
IF ( record exists)
apex_application.g_print_success_message := apex_application.g_print_success_message||','|| v_data_array(1) ; -- Comma separated list of errored account no:s
ELSE ...
{code}
Hope it helps -
I am new to AQ and XML,
We have a situation at our project, the last DBA left us without any previous notice and no one here know AQ and XML. So now it is my duty to learn and work on this project.
We are getting Queue with XML information (i mean data) we have to dequeue and then store that data in oracle tables.
I tried to each and every site to get a grip of what's the basic here, but I get lost. It's more easy for me to understand a concept by going through examples rather study chapters.
This is what I did today from this site. (http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/HowToLoadLargeXML.html#PLSQLCode)
created the potable, then loaded data in potable as per example. Now I want to load this data in a table which I created in Oracle (10.2....) table.
CREATE OR REPLACE PROCEDURE loadpurchaseorder
IS
-- Declare a CLOB variable
poxml CLOB;
BEGIN
-- Store the Purchase Order XML in the CLOB variable
poxml :=
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PurchaseOrder>
<PONum>1001</PONum>
<Company>Oracle Corp</Company>
<PONum>1002</PONum>
<Company>NPC Corp</Company>
<PONum>1003</PONum>
<Company>FDCA Corp</Company>
<PONum>1004</PONum>
<Company>Mahesh Corp</Company>
<PONum>1005</PONum>
<Company>Habeeb Corp</Company>
</PurchaseOrder>';
-- Insert the Purchase Order XML into an XMLType column
INSERT INTO potable
(purchaseorder
VALUES (XMLTYPE (poxml)
--Handle the exceptions
EXCEPTION
WHEN OTHERS
THEN
raise_application_error
(-20101
, 'Exception occurred in loadPurchaseOrder procedure :'
|| Sqlerrm
END loadpurchaseorder;
execute loadpurchaseorder;PL/SQL procedure successfully completed.
Elapsed: 00:00:00.04
select count(*) from potable;COUNT(*)
1
Elapsed: 00:00:00.00
select * from potable;PURCHASEORDER
<?xml version="1.0" encoding="ISO-8859-1" standalone='yes'?>
<PurchaseOrder>
<PONum>1001</PONum>
<Company>Oracle Corp</Company>
<PONum>1002</PONum>
<Company>NPC Corp</Company>
<PONum>1003</PONum>
<Company>FDCA Corp</Company>
<PONum>1004</PONum>
<Company>Mahesh Corp</Company>
<PONum>1005</PONum>
<Company>Habeeb Corp</Company>
</PurchaseOrder>
Elapsed: 00:00:00.03
create table xml_ora_data(corp_id number, corp_name varchar2(30));Table created.
Now I want data from potable to be loaded in xml_ora_data.
any help is appriciated...
Thanks
HabeebThanks for the quick response...
XML_ORA_DATA is the table I created as below..
create table xml_ora_data(corp_id number, corp_name varchar2(30)); -
How to load text data into internal table
I have a text file to load txt data into internal table. So how to read text data with validation and to load all text data into the internal table?
Say this is the text file:
IO_NAME, IO_TYPE, IO_SHTXT, IO_LONGTEXT, DATATYPE, DATA LENGTH
ZIO_TEST1, CHA, IO TEST1, IO TEST 1, CHAR, 20
ZIO_TEST2, CHA, IO TEST2, IO TEST 2, CHAR, 20
Regards,
MauHi,
U can use GUI_UPLOAD for this...
Declare an internal table like
data: begin of itab occurs 0,
string(1200),
end of itab.
check the sample code:
cange as you need
DATA: DATEI_PC TYPE STRING VALUE 'C:\MATNR.TXT'.
DATA: BEGIN OF ITAB occurs 0,
TXT(1024),
END OF ITAB.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = DATEI_PC
FILETYPE = 'ASC'
CHANGING
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
NOT_SUPPORTED_BY_GUI = 17
ERROR_NO_GUI = 18
OTHERS = 19.
IF SY-SUBRC NE 0. WRITE: / 'Error in Uploading'. STOP. ENDIF.
WRITE: / 'UPLOAD:'.
LOOP AT ITAB. WRITE: / ITAB-TXT. ENDLOOP. -
Need to save the data in mutiple tables
Dear Experts,
I need to insert the data ,which is accepted from the user at runtime using table control and also generate automatic number when clicked on the save button the data should be in the database as well.
I am new to module pool, your help is reqd. The user will be awarded ample points if answered correctly.
regards,
RachelHi Rachel,
For automatic number generation you need to create number range object using tcode SNRO and then use the foolowing logic.
*& Form GET_NEXT_NUMBER
text
--> p1 text
<-- p2 text
FORM get_next_number .
DATA: w_quant LIKE inri-quantity, "dummy
w_code LIKE inri-returncode. "returncode
To lock the number range object
CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
EXPORTING
object = 'ZNUM'
EXCEPTIONS
foreign_lock = 1
object_not_found = 2
system_failure = 3
OTHERS = 4.
To raise the exception to the corresponding exception of
'NUMBER_RANGE_ENQUEUE'
IF sy-subrc NE 0.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc NE 0
To get the next number from the object
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = 'Z2'
object = 'ZNUM'
toyear = '2008'
IMPORTING
number = l_lbc_next
quantity = w_quant
returncode = w_code
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
CLEAR ok_code.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc <> 0
To unlock the number range object
CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
EXPORTING
object = 'ZNUM'
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
CLEAR ok_code.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc NE 0
ENDFORM. " GET_NEXT_NUMBER
And for table control logic
see the below link.
Table control of Module Pool Program
Regards,
Raju -
Loading Text data into internal table
I have a text file to load txt data into internal table. So how to read text data with validation and to load all text data into the internal table?
Say this is the text file:
IO_NAME, IO_TYPE, IO_SHTXT, IO_LONGTEXT, DATATYPE, DATA LENGTH
ZIO_TEST1, CHA, IO TEST1, IO TEST 1, CHAR, 20
ZIO_TEST2, CHA, IO TEST2, IO TEST 2, CHAR, 20
Regards,
Mauhi Mau,
look this code, maybe it's help u.
<b>REPORT ZTXTTOTABLE.</b>
DATA: p_file TYPE string value 'C:\teste.txt',
BEGIN OF TI_table OCCURS 0,
COD(5) TYPE C,
NAME(40),
END OF TI_table,
a(2).
PARAMETERS: sel_file(128) TYPE c
default 'C:\teste.txt' OBLIGATORY LOWER CASE.
p_file = sel_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
TABLES
data_tab = ti_table[].
format color COL_TOTAL INTENSIFIED ON.
loop at ti_table.
write: / sy-vline, ti_table-cod, at 10 sy-vline, ti_table-name,
at 60 sy-vline.
endloop.
write: / sy-uline(60).
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = ''
def_path = 'C:\'
mask = ',Documentos de texto (*.txt), *.txt.'
mode = ''
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
find '.txt' IN p_file.
if sy-subrc <> 0.
concatenate p_file '.txt' into sel_file.
else.
sel_file = p_file.
endif.
top-of-page.
format color COL_HEADING INTENSIFIED ON.
uline (60).
write: / sy-vline, 'COD', at 10 sy-vline, 'NAME', at 60 sy-vline.
write: / sy-uline(60).
good luck!
Regards
Allan Cristian
Maybe you are looking for
-
How can I send a jpg of a photograph to someone so that they can download the file and use it to put into an article? I can send it in an Email, but there doesn't seem to be a way for the recipient to extract the jpg from the Email
-
I updated my 4s to iOS 6, and my photos were fine. A week later, and my photos have disappeared, though the album names are there. (I don't have access to a PC, so I can't use the iExplorer trick to find the photo files.) All of my photos exist on
-
Portal 3.0 installation error
He's my software configuration : Oracle9iAS 1.0.2.2.2a on NT server SP5, Oracle 8.1.7 Standard Edition on other machine NT SP5. With the Oracle9iAS Portal Configuration Assistant, I installed repository and users; but at the end of the installation I
-
How to restrict database user.
I need to create a database user who have only read only access to the 10g database. Is there any note which will help on this. Thanks in advance. regards, manish
-
Runtime Error While in Tcode KES1
Hello Team, We are using ECC6 EhP6. I am getting a Runtime error while working with Tcode KES1: Short text Syntax error in program "SAPL0KEA ". What happened? Error in the ABAP Application Program The current ABAP p