Uploading an excel file using webutil in AIX
Hi,
When i am uploading data in an excel file to my Forms(Windows) the screen works fine
But when i am uploading the same excel file to my forms in AIX(Where the application is running) the data is wrongly uploaded
The field is a number type and no format mask is set.
Eg:
Actual data:---------------------- In Form(Windows)---------- In Form (AIX)
31015134807500*30000* 31015134807500*30000* 31015134807500*29800*
I am using below code to copy the value
cell_value :=Client_OLE2.get_num_property(cell, 'Value');
COPY(cell_value,'data.field'||k);
Can anyone please help me understand why in AIX it reads a different value???
Your question is hard to respond too because we don't have access to your Excel file and don't know the structure of the data.
...In Form (AIX)...31015134807500*29800*>
Does the value "29800" exist in your Excel file? If so, where?
Perhaps your code is skipping a row for some reason? Are you opening the exact same Excel file on each computer?
What version of Oracle Forms are you using?
Craig...
Similar Messages
-
I would like to upload a excel file using jsp
Hi,
I would like to upload the excel file using jsp in my netbeans ide. Please help.
I don Know what is the error in this jsp file. It is not showing any thing and the file is also not getting uploaded.
Please gothru the code below.
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page import="java.io.*" errorPage="err.jsp"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<html:rewrite page="/design.css" />" rel="stylesheet" type="text/css">
<title>Upload Page</title>
</head>
<body onKeyDown="DisablingBackFunctionality()" onLoad="DisablingBackFunctionality()">
<html:form action="download" >
<div style="position:absolute; left:100;top:200;">Select an excel File :<input type="file" name="uploadfile"></div>
<div style="position:absolute; left:190;top:250;"><input type="submit" name="Submit" value="Read"></div>
<div style="position:absolute; left:336;top:250;"><input type="reset" name="Reset" value="Clear"></div>
mainmenu
</html:form>
</body>
</html>
<%
String contentType = request.getContentType();
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
String file = new String(dataBytes);
//out.println("<br> file :"+file);
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
//out.println("<br> savefile :"+saveFile);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
//out.println("<br> now file1 :"+saveFile);
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
//out.println("<br> now file2 :"+saveFile);
//out.print(dataBytes);
String ext = "";
if (saveFile.indexOf(".") != -1) {
ext = saveFile.substring(saveFile.lastIndexOf("."));
int lastIndex = contentType.lastIndexOf("=");
//out.println("<br>lst index of"+lastIndex);
String boundary = contentType.substring(lastIndex + 1, contentType.length());
//out.println("<br> boundary"+boundary);
//out.println("<br> file :"+file);
int pos;
pos = file.indexOf("filename=\"");
//out.println("<br> now 0 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 1 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 2 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 3"+pos);
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
FileOutputStream fileOut = new FileOutputStream("D:\\" + saveFile);
//FileOutputStream fileOut = new FileOutputStream(saveFile);
//fileOut.write(dataBytes);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
session.setAttribute("fil", saveFile);
//out.println("File saved as " +saveFile);
%>
<script type="text/javascript" >
function DisablingBackFunctionality()
var URL;
var i ;
var QryStrValue;
URL=window.location.href ;
i=URL.indexOf("?");
QryStrValue=URL.substring(i+1);
if (QryStrValue!='X')
window.location=URL + "?X";
</script>
Please let me know the result as soon as possible. Its my very urgent.
Thanking Yu,
Muthu Kumar.RNo.
Mylenium -
How to upload an excel file using ABAP.
Hi,
Can anyone please help me in understanding how to upload an excel file using ABAP.
Thanks!!http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/
check the link
TYPES: Begin of t_record,
name1 like itab-value,
name2 like itab-value,
age like itab-value,
End of t_record.
DATA: it_record type standard table of t_record initial size 0,
wa_record type t_record.
DATA: gd_currentrow type i.
*Selection Screen Declaration
PARAMETER p_infile like rlgrap-filename.
*START OF SELECTION
call function ALSM_EXCEL_TO_INTERNAL_TABLE
exporting
filename = p_infile
i_begin_col = 1′
i_begin_row = 2′ Do not require headings
i_end_col = 14′
i_end_row = 31′
tables
intern = itab
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. Problem uploading Excel Spreadsheet
endif.
Sort table by rows and colums
sort itab by row col.
Get first row retrieved
read table itab index 1.
Set first row retrieved to current row
gd_currentrow = itab-row.
loop at itab.
Reset values for next row
if itab-row ne gd_currentrow.
append wa_record to it_record.
clear wa_record.
gd_currentrow = itab-row.
endif.
case itab-col.
when 0001′. First name
wa_record-name1 = itab-value.
when 0002′. Surname
wa_record-name2 = itab-value.
when 0003′. Age
wa_record-age = itab-value.
endcase.
endloop.
append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop. -
Upload an excel file using servlet
want to upload an excel file read it and do some updates and then again build an excel sheet
step 1: display an Excel sheet inside the browser
step 2: edit the sheet
step 3: send the sheet data to a Servlet to read it.
i am using POI to read an excel file and use POIFS
when i upload an excel file and get servletinputstream it gives the header+data+tailor
stand alon i have done it but using servlet i failed
can anybody give me an simple example to upload an excel file and shoe it
plz help meSurprise! Look what the forum says...
BEFORE YOU POST A TOPIC HERE: Please be sure your topic is related to features or functionality of this site. This forum is not for general technology questions. Not sure which forum to use? Try searching for your topic in the "Search Forums" element on the left panel.Please post your question on http://forum.java.sun.com/forum.jspa?forumID=33
Do not reply here. -
How to upload a excel file using BDC
how should i upload a file using BDC
i have downloaded a excel file containing the values of table A006 a X server.
now i hav to upload it into new server Y server using BDC , how do i do it?
wat all things one shud consider ?Hi,
This is very simple, follow the below mention steps to do so:
1.Declare an internal table having same structure as db table, but take all the fields type as 'C' and length same as defined in the table.
TYPES:BEGIN OF it,
key(20) TYPE c,
indicator(20) TYPE c,
bldat(20) TYPE c,"bkpf-bldat
budat(20) TYPE c,"bkpf-budat
END OF it.
DATA: itab TYPE STANDARD TABLE OF it,
wa TYPE it.
2.Include TRUX as type pool and declare a variable of type trux_t_text_data to be passed in the FM that actually reads data from excel sheet into above declared intrenal table.
TYPE-POOLS: truxs.
DATA: it_raw TYPE truxs_t_text_data.
3. Call the FM 'TEXT_CONVERT_XLS_TO_SAP' and pass the file name and the internal table name into the parameter
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR = 'X'
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file "name of the excel file
TABLES
i_tab_converted_data = itab[] "internal table where data will be stored
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
4. loop at internal table and modify the ztable/dbtable where data to be upload .
Hope this solve your problem.
Pooja -
I'm doing a test on uploading an Excel file using JAVA. Right now I have my code set up to upload to an Access database. Everything works great except the last record in my Excel file is not being uploaded. I can make it load the last record by adding redundant code { stSQL.executeUpdate(strSQL); }
outside the loop as shown below. This doesn't really make sense to me since I am printing the last SQL statement twice, once inside the loop and once outside the loop so why the SQL statement isn't executed is beyond me. Any thoughts? Thanks,
import java.io.*;
import java.sql.*;
import java.util.regex.*;
public class UploadExcel{
public static void main(String[] args){
Connection connection = null;
String TableName = "GSABill";
String strBeginSQL = "INSERT INTO " + TableName + " VALUES( ";
try{
int iCount = 0;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:/test3.xls;DriverID=22;READONLY=false;" );
Connection Access = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)}; DBQ=c:/temp/test.mdb;Uid=Admin;Pwd=;");
Statement st = con.createStatement();
Statement stSQL = Access.createStatement();
ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int rows;
String strSQL;
strSQL = "";
while (rs.next()) {
strSQL = strBeginSQL;
iCount++;
strSQL = strBeginSQL + iCount + ", ";
for (int i = 1; i <= numberOfColumns; i++) {
String columnValue = rs.getString(i);
try{
if (!columnValue.equals("")){
strSQL = strSQL.substring(0, strSQL.length()-1) + "'" + columnValue + "', ";
} else {
strSQL = strSQL.substring(0, strSQL.length()-1) + "'', ";
} catch(Exception e) {
strSQL = strSQL.substring(0, strSQL.length()-1) + "'', ";
strSQL = strSQL.substring(0, strSQL.length() - 2) + ")";
System.out.println(strSQL);
stSQL.executeUpdate(strSQL);
System.out.println(strSQL);
stSQL.executeUpdate(strSQL);
stSQL.close();
st.close();
con.close();
} catch(Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());jsp file upload code (any type of file): (fileUpload.jsp)
<%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
<%@ page import="java.io.FileWriter,java.io.IOException" %>
<%
String savePath = "", filepath = "", filename = "";
String contentType = "", fileData = "", strLocalFileName = "";
int startPos = 0;
int endPos = 0;
%>
<%!
//copy specified number of bytes from main data buffer to temp data buffer
void copyByte(byte [] fromBytes, byte [] toBytes, int start, int len)
for(int i=start;i<(start+len);i++)
toBytes[i - start] = fromBytes;
%>
<%
int BOF = 0, EOF = 0;
contentType = request.getContentType();
out.println("<br>Content type is :: " +contentType);
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
DataInputStream in = new DataInputStream(request.getInputStream());
DataInputStream in1 = in;
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength)
byteRead = in1.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
out.println("<br>totalBytesRead : " + totalBytesRead + " : formDataLength = " + formDataLength);
//String file = new String(dataBytes);
//out.println("<br>File Contents:<br>////////////////////////////////////<br>" + file + "<br>////////////////////////////////<br>");
byte[] line = new byte[128];
if (totalBytesRead < 3)
return; //exit if file length is not sufficiently large
String boundary = "";
String s = "";
int count = 0;
int pos = 0;
//loop for extracting boundry of file
//could also be extracted from request.getContentType()
do
copyByte(dataBytes, line, count ,1); //read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf("Content-Disposition: form-data; name=\""); //set the file name
if(pos != -1)
endPos = pos;
}while(pos == -1);
boundary = fileData.substring(startPos, endPos);
//loop for extracting filename
startPos = endPos;
do
copyByte(dataBytes, line, count ,1); //read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf("filename=\"", startPos); //set the file name
if(pos != -1)
startPos = pos;
}while(pos == -1);
do
copyByte(dataBytes, line, count ,1); //read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf("Content-Type: ", startPos);
if(pos != -1)
endPos = pos;
}while(pos == -1);
filename = fileData.substring(startPos + 10, endPos - 3); //to eliminate " from start & end
strLocalFileName = filename;
int index = filename.lastIndexOf("\\");
if(index != -1)
filename = filename.substring(index + 1);
else
filename = filename;
//loop for extracting ContentType
boolean blnNewlnFlag = false;
startPos = endPos; //added length of "Content-Type: "
do
copyByte(dataBytes, line, count ,1); //read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf("\n", startPos);
if(pos != -1)
if(blnNewlnFlag == true)
endPos = pos;
else
blnNewlnFlag = true;
pos = -1;
}while(pos == -1);
contentType = fileData.substring(startPos + 14, endPos);
//loop for extracting actual file data (any type of file)
startPos = count + 1;
do
copyByte(dataBytes, line, count ,1); //read 1 byte at a time
count+=1;
s = new String(line, 0, 1);
fileData = fileData + s;
pos = fileData.indexOf(boundary, startPos); //check for end of file data i.e boundry value
}while(pos == -1);
endPos = count - boundary.length();
//file data extracted
out.println("<br><br>0. Local File Name = " + strLocalFileName);
out.println("<br><br>1. filename = " + filename);
out.println("<br>2. contentType = " + contentType);
out.println("<br>3. startPos = " + startPos);
out.println("<br>4. endPos = " + endPos);
out.println("<br>5. boundary = " + boundary);
//create destination path & save file there
String appPath = application.getRealPath("/");
out.println("<br>appPath : " + appPath);
String destFolder = appPath + "images/banner/";
filename= destFolder + filename;
FileOutputStream fileOut = new FileOutputStream(filename);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
out.println("<br>File saved as >> " + filename);
//file saved at destination
//out.println("<br>File data : <br><br>**************************<br>" + (new String(dataBytes,startPos, (endPos - startPos))) + "<br><br>**************************");
else
out.println("Error in uploading ");
%>
supporting html file:
<form method="post" action="fileUpload.jsp" name="upform" enctype="multipart/form-data">
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
<tr>
<td align="left"><b>Select a file to upload :</b></td>
</tr>
<tr>
<td align="left">
<input type="file" name="uploadfile" size="50">
</td>
</tr>
<tr>
<td align="left">
<input type="hidden" name="todo" value="upload">
<input type="submit" name="Submit" value="Upload">
<input type="reset" name="Reset" value="Cancel">
</td>
</tr>
</table>
</form>
</body>
</html> -
CRM ABAP How to upload an Excel file into an internal table?
How to upload an Excel file using GUI_UPLOAD?? what should be the values of the parameters? The function modules ALSM_EXCEL_TO_INTERNAL_TABLE and KCD_EXCEL_OLE_TO_INT are not present in CRM. Please suggest me a way out!
Hi saurabh,
you can try the folowing sample..
and make modifications according to your requirement..
TYPE-POOLS: truxs.
DATA: i_text_data TYPE truxs_t_text_data,
v_filename_string TYPE string.
DATA: BEGIN OF itab OCCURS 0,
Name(30),
Phone(15),
Fax(500).
DATA: END OF itab.
PARAMETERS: p_file LIKE rlgrap-filename.
START-OF-SELECTION.
v_filename_string = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_filename_string
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
dat_mode = ''
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = i_text_data
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
* I_LINE_HEADER =
i_tab_raw_data = i_text_data
i_filename = p_file
TABLES
i_tab_converted_data = itab
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
this is a sample code that uploads a excel file using GUI_UPLOAD, but uses another function module to convert that uploaded data into an internal table..
regards
satesh -
FRM-92101 when creating excel file through webutil
I am getting forms error FRM-92101 error when loading a large amount of records into an excel file using webutil
FRM-92101
A Network Error has occurred
The forms client has attempted to reconnect to the server 1 time(s) without success
I can successfully create the excel file without the the FRM-92101 when loading only 100 out of 2,000 records from the datablock.
But if I try to load 1,000 out of the 2,000 records then in the middle of the loading process I get the FRM-92101 error.
What is causing this error? A timeout issue with forms? How much the excel file can actually handle? Could it be an security issue on the network?
What can be done to remedy the problem? Just save data little bits at a time?
Thanks,
MichelleI was running the form from my DS and when I put the form on the application server there were no FRM-92101 errors.
I'm not sure why running the form from my DS caused this error and running the form from the application server didn't?
Thanks,
Michelle -
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 -
Problem in Uploading excel file using WebDynpro for Java
Hi All
I have followed for Uploading excel file using WebDynpro for Java added by Tulasi Palnati
I done all, but I'm getting 500 Exception please contact u r system admin meag at run time also Jxl/Workbook class not found msag but i downloaded Jxl.jar file and there is no error signals in coding part. How can I solve the Problem.
Thanks
PolakaPlease ask the people in the Web Dynpro Java forum for a solution.
-
Uploading excel file using Bapi f-02
Hi guys
I have a very short memory on how to use BAPIs.I have been requested to develop a program for uploading an excel template using t-code f-02.So far i did my recording using BDC i developed my program.and on executing the batch cannot continue after posting to 30 line items,in my template am supposed to post up to 60 line items and i understand SAP can take up to 999 line items.A sample screen shot might elaborate.
Attached is my code snippet and template as well.I tried to do several checks and tests and am seeing i cant succeed.I came across someone on the net who was advising me to use a BAPI.Now my challenge is how to use a BAPI to upload this template.A sample code snippet might help.
I have also noticed that 'BAPI_ACC_DOCUMENT_POST' is also used to post to F-02,but i dont know how to get my way out with this BAPI.
Please help.
Regards
RejoiceHi guys.I tried the following code and i am stuck.
Report ZTRIAL
no standard page heading line-size 255.
include zbdcrecx1.
TABLES: BSEG, BKPF.
TYPES: BEGIN OF it_lines, "Work table used for upload
line(1000) TYPE c,
END OF it_lines.
DATA: HEADER LIKE bapiache09,
accountgl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
CURRENCYAMOUNT LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
w_item_gl TYPE bapiacgl09,
t_item_gl TYPE STANDARD TABLE OF bapiacgl09.
TYPES:BEGIN OF it_posting, "Work table used for upload
company(4) TYPE N,
doc_date(10) TYPE N,
pstng_date(10) TYPE N,
doc_type(2) Type N,
fiscal_yr(10) TYPE N,
ref_doc_no(15) TYPE N,
pkey(2) type N,
gl_account(018) TYPE N,
busarea(4) TYPE N,
pcenter(010) TYPE N,
assignment(018) TYPE N,
text(050) TYPE N,
amount(016) TYPE N,
tax(004) TYPE N,
END OF it_posting.
Data: it_posting TYPE STANDARD TABLE OF it_posting,
w_postings type it_posting,
t_curr TYPE STANDARD TABLE OF t001 ,
w_curr type t001,
w_item_curr TYPE bapiaccr09,
t_item_curr TYPE STANDARD TABLE OF bapiaccr09.
DATA : g_credit_total like bseg-dmbtr,
g_debit_total like bseg-dmbtr.
CONSTANTS: g_error_flag VALUE 'X'. " Flag.
CONSTANTS : c_x VALUE 'X'. " Flag
data:
g_obj_type like bapiache02-obj_type,
g_obj_key like bapiache02-obj_key,
g_obj_sys like bapiache02-obj_sys.
DATA: it_lines TYPE it_lines OCCURS 0 WITH HEADER LINE.
DATA: p_file1 TYPE string.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
initialization.
user = sy-uname.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
START-OF-SELECTION.
p_file1 = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file1
filetype = 'ASC'
TABLES
data_tab = it_lines .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT it_lines.
SPLIT it_lines-line AT ',' INTO
w_postings-company
w_postings-doc_date
w_postings-pstng_date
w_postings-ref_doc_no
w_postings-pkey
w_postings-gl_account
w_postings-busarea
w_postings-pcenter
w_postings-assignment
w_postings-text
w_postings-amount
w_postings-tax
w_postings-amount .
APPEND w_postings TO it_posting.
*ENDIF.
ENDLOOP.
CLEAR:
w_postings.
LOOP AT it_posting into w_postings.
endloop.
FORM populate_bapi USING rlv_counter TYPE posnr_acc.
**Populate line item details
CONSTANTS : c_x VALUE 'X'. " Flag
data g_cross_flag.
IF w_postings-company NE Header-comp_code.
g_cross_flag = c_x.
ENDIF.
*Fill Credit line item data
IF w_postings-pkey = 25.
w_item_gl-itemno_acc = rlv_counter.
w_item_gl-comp_code = w_postings-company.
w_item_gl-gl_account = w_postings-gl_account.
w_item_gl-pstng_date = header-pstng_date.
w_item_gl-BUS_AREA = w_postings-busarea.
w_item_gl-profit_ctr = w_postings-pcenter.
*w_item_gl-tax_code = w_postings-tax_code.
w_item_gl-ALLOC_NMBR = w_postings-assignment.
w_item_gl-ITEM_TEXT = w_postings-text.
APPEND w_item_gl TO t_item_gl.
* To fetch company code currency
READ TABLE t_curr INTO w_curr
WITH KEY bukrs = w_postings-company
BINARY SEARCH.
w_item_curr-currency = w_curr-waers.
w_item_curr-amt_doccur = w_postings-amount * -1.
APPEND w_item_curr TO t_item_curr.
CLEAR w_item_curr.
g_credit_total = g_credit_total + w_postings-amount.
* Clear variables
CLEAR: w_postings,
w_item_curr,
w_curr,
w_item_gl.
*Fill Debit line item data
ELSEIF w_postings-pkey = 50.
w_item_gl-itemno_acc = rlv_counter.
w_item_gl-comp_code = w_postings-company.
w_item_gl-gl_account = w_postings-gl_account.
w_item_gl-pstng_date = header-pstng_date.
w_item_gl-BUS_AREA = w_postings-busarea.
w_item_gl-profit_ctr = w_postings-pcenter.
w_item_gl-tax_code = w_postings-tax.
w_item_gl-ALLOC_NMBR = w_postings-assignment.
w_item_gl-ITEM_TEXT = w_postings-text.
APPEND w_item_gl TO t_item_gl.
READ TABLE t_curr INTO w_curr
WITH KEY bukrs = w_postings-company
BINARY SEARCH.
w_item_curr-currency = w_curr-waers.
w_item_curr-amt_doccur = w_postings-amount * -1.
APPEND w_item_curr TO t_item_curr.
CLEAR w_item_curr.
g_credit_total = g_credit_total + w_postings-amount.
* Clear variables
CLEAR: w_postings,
w_item_curr,
w_curr,
w_item_gl.
endif.
endform.
FORM post_document.
TYPES:BEGIN OF type_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
gjahr TYPE bkpf-gjahr,
END OF type_bkpf.
*Local variable declarations
DATA: lv_belnr TYPE belnr_d,
lv_bukrs TYPE bukrs,
lv_gjahr TYPE gjahr,
*lw_message TYPE type_message,
lv_msg TYPE symsgv,
*lv_rdate TYPE sy-datum,
lt_return TYPE STANDARD TABLE OF bapiret2,
lw_return TYPE bapiret2, "#EC NEEDED
lt_bkpf TYPE STANDARD TABLE OF type_bkpf,
lw_bkpf TYPE type_bkpf.
*lv_bvorg TYPE bvor-bvorg.
*Clear local work area and variables
*lw_message,
CLEAR:
lv_msg,
lw_return,
lw_bkpf.
CLEAR: header-obj_type,
header-obj_key,
header-obj_sys.
IF g_error_flag NE c_x.
IF g_credit_total <> 0 AND g_debit_total <> 0.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
documentheader = header
TABLES
accountgl = t_item_gl
currencyamount = t_item_curr
return = t_return.
If t_return is not initial.
* Posting journal entries
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = header
IMPORTING
obj_type = g_obj_type
obj_key = g_obj_key
obj_sys = g_obj_sys
TABLES
accountgl = t_item_gl
currencyamount = t_item_curr
return = t_return.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
ENDIF.
Endif.
Endif.
ENDIF.
ENDFORM." POPULATE_BAPI -
Uploading Excel file using GUI_UPLOAD
Hi Friends,
I want to upload a excel file to internal table,iam facing a issue with GUI_UPLOAD? can you please tell me how to upload it?
any sample code will be greatly helpful.
Regards
Babuhi,
these are basic things which are already present in SDN do search before posting
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'c:\itab_mat.xls'
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
thanks
shivraj
Edited by: ShivrajSinha on Feb 9, 2010 1:56 PM -
Hi,
I am getting an error while trying to upload a excel file. I am using the function HR_KR_XSTRING_TO_STRING for conversion. The error message is "Unable to interpret as a number"First of all, are you sure you know what you are working with here. If this is standard Excel file in the Microsoft binary/propriatery format there is not function module or class in ABAP that can magically just transform this to a character string. You should search the forums as this has been discussed extensively. On that topic, please also do not post duplicate threads. I have already locked your other thread with the same basic question.
Instead of the binary/propriatery format of Excel, the file should be saved on the client as a text based format - like XML or Text Tab Delimited. You can then use several different options on the server to convert the XSTRING to STRING and process the content (becuase it was text based to begin with). You could use CL_BCS_CONVERT, the function modules in the function group SCMS_CONV, or the class CL_ABAP_CONV_IN_CE. -
Read an excel file using JSP in MII 12.1
Hi,
I want to read an excel file using jsp page. I dont want to use the UDS or ODBC for connecting to excel.
I am trying to use org.apache.poi to read the excel file in jsp page.
While running, its showing a compilation error "package org.apache.poi.hssf.usermodel does not exist"
I have the jar files for it, where do we need to upload it so that jsp page works.
Thanks a lot
Regards,
Neha MaheshwariThe user doesn't want to save the excel file in server.
I want to upload file and save its contents in database.
I have the code to read and save excel data in database but not able to get the location to deploy the jar file.
In general, if we are creating a jsp page in MII workbench which is using some jar file.
Whats the location to upload this jar file so that the jsp page works correctly? -
To upload a excel file to dB table through webdynpro ABAP
HI,
I am unable to upload a excel file directly by using func module "HR_KR_XSTRING_TO_STRING".
If file is in tab delimited then only, I am able to upload.
Suggest me if there are any other options to upload a excel file.Hi,
The below link gives you an explanation of how you can upload an excel file to web dynpro.
http://www.****************/Tutorials/WebDynproABAP/Upload/Page1.htm
Kindly read go through the below link, as this issue have been brought up before
http://forums.sdn.sap.com/thread.jspa?threadID=1831838
Thanks and regards.
Edited by: Suraj Ravindran Nair on Feb 24, 2012 6:24 AM
Maybe you are looking for
-
Keynote and Numbers apps.
I mistakenly deleted the Keynote and Numbers apps. How do I get the apps back without having to pay?
-
Multiple Adobe ID accounts linked to one Behance account?
I am a creative cloud team member and need to access my company's already set up Behance account to update work. Since Behance login was changed to Adobe ID's I am unable to sign in without knowing the owners sign in credentials. Is there a way to si
-
I have downloaded and tried a few group message apps to send sms text to over 150 group contacts. i created a group and have tried a few apps, but for some unknown reason the texts aren't received by all recipients. any idea how to deal with this?
-
I would like to remove a rather large stye from the eye area of a child in a photo...can someone point me in the right direction please Cheers
-
Uploading my folio..
Uploading local folios to the producer site becomes a nightmare.. and it only happens whe the folio contain a web element ( html files) doesn't matter what the file size was.. Even a hyperlink. but when i use a html file the has been generated by the