Upload of excel file in to purchase order
hi guys,
i want to upload a excel file to the internal table and then to create the purchase order.
i know the name of function module and bapi.
but how to make use of them in implementation!!!
fun module : ALSM_EXCEL_TO_INTERNAL_TABLE
bapi : BAPI_PO_CREATE1.
arun and vishnu from
infotech solutions
*CREATION OF A TEMPORARY STRUCTURE FOR INSERTING FIELDS OF EXCEL TO INTERNAL TABLE.
TYPES : BEGIN OF STR_FINAL,
COMP_CODE TYPE BAPIMEPOHEADER-COMP_CODE, " STRUCTURE : BAPIMEPOHEADER
ITEM_INTVL TYPE BAPIMEPOHEADER-ITEM_INTVL,
VENDOR TYPE BAPIMEPOHEADER-VENDOR,
PMNTTRMS TYPE BAPIMEPOHEADER-PMNTTRMS,
PURCH_ORG TYPE BAPIMEPOHEADER-PURCH_ORG,
PUR_GROUP TYPE BAPIMEPOHEADER-PUR_GROUP,
CURRENCY TYPE BAPIMEPOHEADER-CURRENCY,
PO_ITEM TYPE BAPIMEPOITEM-PO_ITEM, " STRUCTURE : BAPIMEPOITEM
MATERIAL TYPE BAPIMEPOITEM-MATERIAL,
PLANT TYPE BAPIMEPOITEM-PLANT,
STGE_LOC TYPE BAPIMEPOITEM-STGE_LOC,
QUANTITY TYPE BAPIMEPOITEM-QUANTITY,
TAX_CODE TYPE BAPIMEPOITEM-TAX_CODE,
ITEM_CAT TYPE BAPIMEPOITEM-ITEM_CAT,
ACCTASSCAT TYPE BAPIMEPOITEM-ACCTASSCAT,
SCHED_LINE TYPE BAPIMEPOSCHEDULE-SCHED_LINE, " STRUCTURE : BAPIMEPOSCHEDULE
DELIVERY_DATE TYPE BAPIMEPOSCHEDULE-DELIVERY_DATE,
SERIAL_NO TYPE BAPIMEPOACCOUNT-SERIAL_NO, " STRUCTURE : BAPIMEPOACCOUNT
GL_ACCOUNT TYPE BAPIMEPOACCOUNT-GL_ACCOUNT,
COSTCENTER TYPE BAPIMEPOACCOUNT-COSTCENTER,
CO_AREA TYPE BAPIMEPOACCOUNT-CO_AREA,
END OF STR_FINAL.
DATA : IT_FINAL TYPE TABLE OF STR_FINAL,
WA_FINAL TYPE STR_FINAL.
DATA: ST_BAPIMEPOHEADER TYPE BAPIMEPOHEADER,
ST_BAPIMEPOHEADERX TYPE BAPIMEPOHEADERX.
*it is for item data
DATA: WA_POITEM TYPE BAPIMEPOITEM,
IT_POITEM TYPE TABLE OF BAPIMEPOITEM,
WA_POITEMX TYPE BAPIMEPOITEMX,
IT_POITEMX TYPE TABLE OF BAPIMEPOITEMX,
WA_POSCHEDULE TYPE BAPIMEPOSCHEDULE,
IT_POSCHEDULE TYPE TABLE OF BAPIMEPOSCHEDULE,
WA_POSCHEDULEX TYPE BAPIMEPOSCHEDULX,
IT_POSCHEDULEX TYPE TABLE OF BAPIMEPOSCHEDULX,
WA_POACCOUNT TYPE BAPIMEPOACCOUNT,
IT_POACCOUNT TYPE TABLE OF BAPIMEPOACCOUNT,
WA_POACCOUNTX TYPE BAPIMEPOACCOUNTX,
IT_POACCOUNTX TYPE TABLE OF BAPIMEPOACCOUNTX,
WA_RETURN TYPE BAPIRET2,
IT_RETURN TYPE TABLE OF BAPIRET2.
selection-screen skip 1.
parameters: p_file type localfile default 'D:\VISHNU\DEMO.XLS'.
*selection-screen skip 1.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
clear IT_FINAL.
refresh IT_FINAL.
perform upload_data.
loop at IT_FINAL INTO WA_FINAL.
write:/ WA_FINAL-COMP_CODE,
/ WA_FINAL-ITEM_INTVL,
/ WA_FINAL-VENDOR,
/ WA_FINAL-PMNTTRMS,
/ WA_FINAL-PURCH_ORG,
/ WA_FINAL-PUR_GROUP,
/ WA_FINAL-CURRENCY,
/ WA_FINAL-PO_ITEM,
/ WA_FINAL-MATERIAL,
/ WA_FINAL-PLANT,
/ WA_FINAL-STGE_LOC,
/ WA_FINAL-QUANTITY,
/ WA_FINAL-TAX_CODE,
/ WA_FINAL-ITEM_CAT,
/ WA_FINAL-ACCTASSCAT,
/ WA_FINAL-SCHED_LINE,
/ WA_FINAL-DELIVERY_DATE,
/ WA_FINAL-SERIAL_NO,
/ WA_FINAL-GL_ACCOUNT,
/ WA_FINAL-COSTCENTER,
/ WA_FINAL-CO_AREA.
endloop.
LOOP AT IT_FINAL INTO WA_FINAL.
ST_BAPIMEPOHEADER-COMP_CODE = WA_FINAL-COMP_CODE.
ST_BAPIMEPOHEADER-DOC_TYPE = 'NB'.
ST_BAPIMEPOHEADER-ITEM_INTVL = WA_FINAL-ITEM_INTVL.
ST_BAPIMEPOHEADER-VENDOR = WA_FINAL-VENDOR.
ST_BAPIMEPOHEADER-LANGU = SY-LANGU.
ST_BAPIMEPOHEADER-PMNTTRMS = WA_FINAL-PMNTTRMS.
ST_BAPIMEPOHEADER-PURCH_ORG = WA_FINAL-PURCH_ORG.
ST_BAPIMEPOHEADER-PUR_GROUP = WA_FINAL-PUR_GROUP.
ST_BAPIMEPOHEADER-CURRENCY = WA_FINAL-CURRENCY.
*insert ST_BAPIMEPOHEADERX values
ST_BAPIMEPOHEADERX-COMP_CODE = 'X'.
ST_BAPIMEPOHEADERX-DOC_TYPE = 'X'.
ST_BAPIMEPOHEADERX-ITEM_INTVL = 'X'.
ST_BAPIMEPOHEADERX-VENDOR = 'X'.
ST_BAPIMEPOHEADERX-LANGU = 'X'.
ST_BAPIMEPOHEADERX-PMNTTRMS = 'X'.
ST_BAPIMEPOHEADERX-PURCH_ORG = 'X'.
ST_BAPIMEPOHEADERX-PUR_GROUP = 'X'.
ST_BAPIMEPOHEADERX-CURRENCY = 'X'.
*insert IT_POITEM values
WA_POITEM-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POITEM-MATERIAL = WA_FINAL-MATERIAL.
WA_POITEM-PLANT = WA_FINAL-PLANT.
WA_POITEM-STGE_LOC = WA_FINAL-STGE_LOC.
WA_POITEM-QUANTITY = WA_FINAL-QUANTITY.
WA_POITEM-TAX_CODE = WA_FINAL-TAX_CODE.
WA_POITEM-ITEM_CAT = WA_FINAL-ITEM_CAT.
WA_POITEM-ACCTASSCAT = WA_FINAL-ACCTASSCAT.
APPEND WA_POITEM TO IT_POITEM.
CLEAR WA_POITEM.
*insert IT_POITEMX values
WA_POITEMX-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POITEMX-PO_ITEMX = 'X'.
WA_POITEMX-MATERIAL = 'X'.
WA_POITEMX-PLANT = 'X'.
WA_POITEMX-STGE_LOC = 'X'.
WA_POITEMX-QUANTITY = 'X'.
WA_POITEMX-TAX_CODE = 'X'.
WA_POITEMX-ITEM_CAT = 'X'.
WA_POITEMX-ACCTASSCAT = 'X'.
APPEND WA_POITEMX TO IT_POITEMX.
CLEAR WA_POITEMX.
*insert IT_POSCHEDULE values
WA_POSCHEDULE-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POSCHEDULE-SCHED_LINE = WA_FINAL-SCHED_LINE.
WA_POSCHEDULE-DELIVERY_DATE = WA_FINAL-DELIVERY_DATE .
WA_POSCHEDULE-QUANTITY = WA_FINAL-QUANTITY.
APPEND WA_POSCHEDULE TO IT_POSCHEDULE.
CLEAR WA_POSCHEDULE.
*insert IT_POSCHEDULEX values
WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
WA_POSCHEDULEX-PO_ITEMX = 'X' .
WA_POSCHEDULEX-SCHED_LINEX = 'X' .
WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
WA_POSCHEDULEX-QUANTITY = 'X' .
WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM .
WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
WA_POSCHEDULEX-PO_ITEMX = 'X'.
WA_POSCHEDULEX-SCHED_LINEX = 'X' .
WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
WA_POSCHEDULEX-QUANTITY = 'X'.
WA_POSCHEDULEX-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POSCHEDULEX-SCHED_LINE = WA_FINAL-SCHED_LINE.
WA_POSCHEDULEX-PO_ITEMX = 'X'.
WA_POSCHEDULEX-SCHED_LINEX = 'X'.
WA_POSCHEDULEX-DELIVERY_DATE = 'X' .
WA_POSCHEDULEX-QUANTITY = 'X'.
APPEND WA_POSCHEDULEX TO IT_POSCHEDULEX.
CLEAR WA_POSCHEDULEX.
*insert IT_POACCOUNT values
WA_POACCOUNT-PO_ITEM = WA_FINAL-PO_ITEM.
WA_POACCOUNT-SERIAL_NO = WA_FINAL-SERIAL_NO.
WA_POACCOUNT-QUANTITY = WA_FINAL-QUANTITY .
WA_POACCOUNT-GL_ACCOUNT = WA_FINAL-GL_ACCOUNT.
WA_POACCOUNT-COSTCENTER = WA_FINAL-COSTCENTER.
WA_POACCOUNT-CO_AREA = WA_FINAL-CO_AREA.
APPEND WA_POACCOUNT TO IT_POACCOUNT.
CLEAR WA_POACCOUNT.
*insert IT_POACCOUNTX values
WA_POACCOUNTX-PO_ITEM = 00001.
WA_POACCOUNTX-SERIAL_NO = 01.
WA_POACCOUNTX-QUANTITY = 'X'.
WA_POACCOUNTX-GL_ACCOUNT = 'X'.
WA_POACCOUNTX-COSTCENTER = 'X' .
WA_POACCOUNTX-CO_AREA = 'X'.
APPEND WA_POACCOUNTX TO IT_POACCOUNTX.
CLEAR WA_POACCOUNTX.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = ST_BAPIMEPOHEADER
POHEADERX = ST_BAPIMEPOHEADERX
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = IT_RETURN
POITEM = IT_POITEM
POITEMX = IT_POITEMX
POADDRDELIVERY =
POSCHEDULE = IT_POSCHEDULE
POSCHEDULEX = IT_POSCHEDULEX
POACCOUNT = IT_POACCOUNT
POACCOUNTPROFITSEGMENT =
POACCOUNTX = IT_POACCOUNTX
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
*this is for save the porder number
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*dispaly the results
LOOP AT IT_RETURN INTO WA_RETURN.
WRITE:/ WA_RETURN-MESSAGE,
ST_BAPIMEPOHEADER-PO_NUMBER.
ENDLOOP.
form upload_data.
data: file type rlgrap-filename.
data: IT_XCEL type table of alsmex_tabline,
WA_XCEL TYPE ALSMEX_TABLINE.
file = p_file.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '21'
i_end_row = '1'
tables
intern = IT_xcel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
loop at IT_xcel INTO WA_XCEL.
case
WA_XCEL-COL.
when '0001'.
WA_FINAL-COMP_CODE = WA_xcel-value.
WHEN '0002'.
WA_FINAL-ITEM_INTVL = WA_XCEL-VALUE.
WHEN '0003'.
WA_FINAL-VENDOR = WA_XCEL-VALUE.
WHEN '0004'.
WA_FINAL-PMNTTRMS = WA_XCEL-VALUE.
WHEN '0005'.
WA_FINAL-PURCH_ORG = WA_XCEL-VALUE.
WHEN '0006'.
WA_FINAL-PUR_GROUP = WA_XCEL-VALUE.
WHEN '0007'.
WA_FINAL-CURRENCY = WA_XCEL-VALUE.
WHEN '0008'.
WA_FINAL-PO_ITEM = WA_XCEL-VALUE.
WHEN '0009'.
WA_FINAL-MATERIAL = WA_XCEL-VALUE.
WHEN '00010'.
WA_FINAL-PLANT = WA_XCEL-VALUE.
WHEN '00011'.
WA_FINAL-STGE_LOC = WA_XCEL-VALUE.
WHEN '00012'.
WA_FINAL-QUANTITY = WA_XCEL-VALUE.
WHEN '00013'.
WA_FINAL-TAX_CODE = WA_XCEL-VALUE.
WHEN '00014'.
WA_FINAL-ITEM_CAT = WA_XCEL-VALUE.
WHEN '00015'.
WA_FINAL-ACCTASSCAT = WA_XCEL-VALUE.
WHEN '00016'.
WA_FINAL-SCHED_LINE = WA_XCEL-VALUE.
WHEN '00017'.
WA_FINAL-DELIVERY_DATE = WA_XCEL-VALUE.
WHEN '00018'.
WA_FINAL-SERIAL_NO = WA_XCEL-VALUE.
WHEN '00019'.
WA_FINAL-GL_ACCOUNT = WA_XCEL-VALUE.
WHEN '00020'.
WA_FINAL-COSTCENTER = WA_XCEL-VALUE.
WHEN '00021'.
WA_FINAL-CO_AREA = WA_XCEL-VALUE.
ENDCASE.
at end of row.
append WA_FINAL TO IT_FINAL.
clear WA_FINAL.
endat.
ENDLOOP.
ENDFORM.
Similar Messages
-
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. -
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 -
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 -
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> -
Problem in uploading an excel file in wd abap
I am trying to upload an excel file in wd abap but on uploading it shows me the data in the form of some codes but when i try to do the same thing using text file it works well.Plese refer the code .
METHOD onactionon_upload .
TYPES : BEGIN OF itab_str1,
name(10) TYPE c,
age(10) TYPE c,
END OF itab_str1.
DATA : t_table1 TYPE STANDARD TABLE OF itab_str1,
i_data TYPE STANDARD TABLE OF string,
lo_nd_sflight TYPE REF TO if_wd_context_node,
lo_el_sflight TYPE REF TO if_wd_context_element,
l_string TYPE string,
fs_table TYPE itab_str1,
l_xstring TYPE xstring,
fields TYPE string_table,
lv_field TYPE string.
DATA : t_table TYPE if_main=>elements_data_tab,
data_table TYPE if_main=>elements_data_tab.
wd_context->get_attribute(
EXPORTING
name = 'DATASOURCE'
IMPORTING
value = l_xstring
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = l_xstring
IMPORTING
out_string = l_string.
SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.
LOOP AT i_data INTO l_string.
SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
READ TABLE fields INTO lv_field index 1.
fs_table-name = lv_field.
READ TABLE fields INTO lv_field index 2.
fs_table-age = lv_field.
APPEND fs_table TO t_table1.
ENDLOOP.
lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB').
lo_nd_sflight->bind_table( t_table1 ).
ENDMETHOD.Problem is not with the file format nor Upload element.
problem is with conversion function module, still now for conversion of xcel data to string format we dont have perfect function module.
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = l_xstring
IMPORTING
out_string = l_string.
That's a bug with xcel conversion As of now I dont find any fm which converts xcel data to string without any problem.
Regards
Srinvivas
Edited by: sanasrinivas on Dec 23, 2011 7:02 AM -
Uploading an excel file in an internal table.
hi experts,
I m trying to upload a excel file comprising of 16,000 records using the function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' as follws
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_input
i_begin_col = 1
i_begin_row = 1
i_end_col = 30
i_end_row = 65000
TABLES
intern = g_t_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
My problem is I am unable to upload record number 10001 else all the records are uploaded successfully
can anyone help me in solving this problemFORM upload_itab .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = p_file
FILETYPE = 'ASC'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = itab
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Need help in uploading an excel file into SAP
Hi All,
I got a requirement to upload an excel file to SAP.
But When i tried with the FM "ALSM_EXCEL_TO_INTERNAL_TABLE" , file not getting uploaded to internal table.
Getting expection 2, UPLOAD_OLE...
I think the problem is with the file... the following the sample text of the file...
Technical IdentNo. Line No. Text Location
BS-PZ-180 1 035-05 EXZENTER-SCHNECKENPUMPE 0026
BS-PZ-180 2 LIEFERANT : SOCSIL-INTER SA ECUBLENS 0026
BS-PZ-180 3 HERSTELLER : MONO PUMPS LIMITED MANCH 0026
BS-PZ-180 4 MODELL/TYP : SH 60 0026
But when I tried with only one Column..its getting successfully uploaded...
Pls suggest me how to upload the file? ( May be with sample code)
Also pls let me know hw to handle the file..which contains 5 differnt sheets of texts.. ( May be with sample code)
Your suggestion will be highly appreciated...
Thanks,
PriyaHi,
Use the FM: TEXT_CONVERT_XLS_TO_SAP. It will work perfectly. I used this function module and uploaded data from xls to sap. check the following code:
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
PROP_NAME like SDOKPROP-PROP_NAME,
PROP_CHECK like SDOKPROP-PROP_CHECK,
TABNAME like SDOKPROP-TABNAME,
FIELDNAME like SDOKPROP-FIELDNAME,
DESCRIPT(30) type c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
itab TYPE STANDARD TABLE OF t_datatab,
wa_itab TYPE t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
*START-OF-SELECTION.
START-OF-SELECTION.
SELECT * FROM sdokprop INTO CORRESPONDING FIELDS OF TABLE itab
WHERE PROP_NAME LIKE 'DMS%'.
WRITE / 'Before Modification'.
LOOP AT itab INTO wa_itab.
WRITE:/1 wa_itab-PROP_NAME, 27 wa_itab-PROP_CHECK, 31 wa_itab-TABNAME, 65 wa_itab-FIELDNAME, 96 wa_itab-DESCRIPT.
CLEAR wa_itab.
ENDLOOP.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
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.
END-OF-SELECTION.
END-OF-SELECTION.
WRITE / 'After Modification'.
MODIFY sdokprop FROM TABLE it_datatab.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/1 wa_datatab-PROP_NAME, 27 wa_datatab-PROP_CHECK, 31 wa_datatab-TABNAME, 65 wa_datatab-FIELDNAME, 96 wa_datatab-DESCRIPT.
CLEAR wa_datatab.
ENDLOOP.
IF sy-subrc = 0.
MESSAGE 'successfull' TYPE 'S'.
ELSE.
MESSAGE 'failed' TYPE 'E'.
ENDIF.
Regards,
Bhaskar -
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 -
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 in the server with a background job
I am trying to upload an excel file in the server, but i only can upload flat files, i can upload files in local with the function ALSM_EXCEL_TO_INTERNAL_TABLE, can i use this function reading an excel file in the server, or is there another possibility of uploadinging an excel file in the server with a background job ?
thanks in advanceHi
First read the file from the server to some temporary place at presentation layer and then open it. And if required, save it to the server afterwards. To read/write files to application server you can use:
1. Statements "OPEN DATASET/CLOSE DATASET".
2. There are some FMs for server file operations, like "C13Z_FILE_UPLOAD_BINARY" and "C13Z_FILE_DOWNLOAD_BINARY".
*--Serdar -
How to upload a excel file in webdynpro? Please help!
Hi Experts,
I have a requirement where I need to upload a excel file in my webdynpro for ABAP report.
I have used the fileupload UI element in my view and a upload button.
However when I test the application I found that it is getting file data as some junk value like below:
###ࡱ#################>########################################################################################################################################################################################################################################
Why is that so?
Is there any limitation with fileuplaod reading excel file?
Do i have to use any encoding option?
What is the alternative option to read excel file in ABAP webdynpro?
Thanks
GopalHi,
Check this.. Write this code in Upload button 's method
********** Reading data from flat file ****************
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_datasource type xstring.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `DATASOURCE`
IMPORTING
value = lv_datasource ).
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
* FROM_CODEPAGE = '8500'
IN_XSTRING = LV_DATASOURCE
* OUT_LEN = '1'
IMPORTING
OUT_STRING = LV_STRING.
SPLIT LV_STRING AT CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO TABLE IT_STR.
LOOP AT IT_STR INTO LV_STRING.
SPLIT LV_STRING AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO TABLE FIELDS.
READ TABLE FIELDS INTO LV_FIELD INDEX 1. " Reading 1st field
ls_header-STATU = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 2. " Reading 2st field
ls_header-LIFNR = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 3.
ls_header-BSART = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 4.
ls_header-EKORG = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 5.
ls_header-EKGRP = LV_FIELD.
clear LV_FIELD.
READ TABLE FIELDS INTO LV_FIELD INDEX 6.
ls_header-BUKRS = LV_FIELD.
clear LV_FIELD.
APPEND wa to it.
append ls_header to lt_header.
clear: ls_header,wa.
endloop.
lo_nd_header->BIND_TABLE( lt_header ).
Thanks,
Ramesh
Edited by: Rameshkumar Raamasamy on Dec 20, 2010 11:16 AM -
How can I add the attachment list pdf file context to purchase order ?
Dear all,
I have use services for object in ME22N to attach PDF file to purchase order,I want to know how can I add the pdf file context to purchase order when I send the purchase order to vendor.
Thanks in advance
Best regards,
Merryhi,
attach document through Service for Object button. Service for Object button available down side of Command screen ( in your PO screen ME22N ) .
Click your Service Object button -> Create -> Create attachment
then select your window directory ( which file you need to attach) select your file Now your system shows message Service "Create attachment" is started.
Save again your PO. You can see (open) your attachment in same field ( Service for Object ) select and Create and check attachment list. You can attach as many document in your PO. -
Upload the excel file in oracle db through oracle forms
Hi all,
I want to upload the excel file in oracle db through oracle forms...I am new to oracle forms .
I have searched a lot but not getting exact solution
Is there anyone who will help me out with this .....
Any help will be appriciatedI'm trying to move data from excel into an Oracle forms field. This involves coping 2 columns of data cells in excel and pasting it into an Oracle forms field. I can get the date pasted into the Oracle forms field but there is a invisible character that separates the 2 columns of data coming from Excel. I do not know what this character is but it is causing the error 'Line 1 is invalid. Check forms'.
Any ideas how to get pass this?
Thank you -
Urgent : Uploading an excel file to an internal table
Hi All
M problem is simple ..i have to upload an excel file from my PC which is containing 2 cols to an internal table which is having two fields .. I am using GUI_UPLOAD function module for this and using FILELD_SEPARATOR as 'X" .. But i am not able to upload anything .it gives some junk content to my internal tble .
please help me out
Regards
rohanHi Rohan,
Use the following code.
DATA: IT_MAIN LIKE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = 'c:\test.xls'
i_begin_col = 1
i_begin_row = 1
i_end_col = 4
i_end_row = 4
tables
intern = IT_MAIN
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
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_MAIN.
WRITE:/ IT_MAIN-ROW, ' ',
IT_MAIN-COL, ' ',
IT_MAIN-VALUE, ' '.
ENDLOOP.
The field VALUE of internal table IT_MAIN will contain the data. The first row will contain data from the first column, second for the second column and so on... In your case, the third row will contain 2nd row data from the first column of your excel sheet and so on.
Hopw this helps,
Cheers,
Madhur
Maybe you are looking for
-
Configuration Error in PI 7.1 Receiver Agreement
Hi, I am facing a problem while testing my interface throught RWB, I am getting below error. Error while sending message: com.sap.engine.interfaces.messaging.api.exception.ConfigException: ConfigException in XI protocol handler. Failed to determine a
-
Laptop won't let me play any video or change the brightness of the screen at all.
I got this new Laptop a few months ago and it has just recently started to play up slightly and not let me change my brightness settings at all and now it won't let me play any videos.
-
When I copy text from a .pdf to a Word document, all words containing the combination 'tt' or 'ti' come up as blank boxes,or question marks. How can I correct this?
-
Hi All, The scenario is like this.... I have two list item Country and State.....Now when I select a specfic country from the list item.....corresponding state will come in the State list item.... Plz Help me to solve the issue.... Thanks in Advance.
-
Some failed BPEL processes are not tracked in BPEL Console (not hydrated)
Hi all. I'm experiencing a problem at a customer which has a standalone BPEL install (they use BPEL 10.1.3.1 only) The customer is complaing that, due to some process errors, the BPEL process fails but, the process final state is not hydrated to data