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
Rejoice
Hi 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
Similar Messages
-
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 'ALSM_EXCEL_TO_INTERNAL_TABLE'
Hi,
I am uploading excel file into an internal table using 'ALSM_EXCEL_TO_INTERNAL_TABLE' FM.
but I'm getting a popup with the message
'There is a large amount of the information on the clipboard. Do you want to be able to paste this information into another programme later.' and there are three buttons in the popup 'YES', 'CANCEL' and 'NO'. but for any choice there is no data in the internal table.
the progrsm is working in other systems but giving problem in customer laptop, can you please tell me is there any settings need to set for EXCEL or SAP.
system details are as below
OS: windows 7
MS-Office - 2007
SAP : ECC06Looks like there was an intention to clear the clipboard in the code, but this does not seem to work.
I copied the function module to my own version and added the following code, which seems to work :
* clear clipboard
refresh excel_tab.
call method cl_gui_frontend_services=>clipboard_export
importing
data = excel_tab
changing
rc = ld_rc
exceptions
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
others = 4
* Copy only one cell to prevent the clipboard data message.
call method of worksheet 'Cells' = h_cell
exporting #1 = 1 #2 = 1.
m_message.
call method of worksheet 'Cells' = h_cell1
exporting #1 = 1 #2 = 1.
m_message.
call method of worksheet 'RANGE' = range
exporting #1 = h_cell #2 = h_cell1.
m_message.
call method of range 'SELECT'.
m_message.
* copy marked area (whole spread sheet) into Clippboard
call method of range 'COPY'.
m_message.
* quit Excel and free ABAP Object - unfortunately, this does not kill
* the Excel process
call method of application 'QUIT'.
m_message. -
Error in uploading excel file using Java pages
Hello,
We are using oracle ERP (R12.1.1) and we have developed one JSP page to upload an excel.
After selecting the excel and browse button is clicked we are gettign the OLE stream error when the excel file is .csv or .xlsx. There is no issue with .xls excel files. For loading the excel data to custom table we are using the "jxl-2.6.jar".
Can we get higher version of "jxl-2.6.jar to support CSV upload?
Thanks.Are you Registered this jsp upload page to EBS before test?
You have to register the page to EBS first.
Regards,
Dilip -
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 -
Upload Excel file using GUI_UPLOAD
I'm trying to upload a regular excel (*.xls) using the fm <b>GUI_UPLOAD</b>, though sy-subrc is set to 0 after the function call, the data that is uploaded into the internal table shows junk. Any thoughts are welcome.
Hi Ratan,
There is no confusion in this,
you can do this with GUI_UPLOAD but you will not get the uploaded internal table data in
a right and organised way.
but in case of ALSM_EXCEL_TO_INTERNAL_TABLE you will get those uploaded internal table data as below.
ROW COL VALUE
1 1 10
1 2 20 -
Uploading Excel File and Reading Data from that File
<b>Hi
Can anyone Please tell me how to upload an Excel File in to the Web Dynpro Application and After that i want to read the data from that uploaded excel file in the Web Dynpro Application to the Web Dynpro table.
Plz help me to solve this.......
Regards
Chandran</b>Hi,
Upload Excel file using File Upload UI
1)Add jxl jar folder in the lib folder of ur project.
2)Go to properties of ur project and add jar to ur project.
3)Using the File upload ui ,browse and upload the file.
4)Write the read file in to ur server location using fileoutput stream.
5)then using code u can read the excelfile from the server location itself.
Here is the code:
IWDAttributeInfo attInfo =wdContext.getNodeInfo().getAttribute("upload");
/** get the name of excel file and storing it in the server with the same name and extention****/
binaryType=IWDModifiableBinaryTypeattInfo.getModifiableSimpleType();
fileuploaded = binaryType.getFileName();
byte b[] = wdContext.currentContextElement().getUpload();
File filename =new File("
<Server name>
<folde name>
" + fileuploaded);
try {
FileOutputStream out = new FileOutputStream(filename);
out.write(b);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
/**Readind from the server**/
int iRows = 0;
try { Workbook wb = null;
Sheet sheet = null;
wb = Workbook.getWorkbook(filename);
sheet = wb.getSheet(0);
int iColumns = sheet.getColumns();
iRows = sheet.getRows();
int i = 0;
//get Cell contents by (COLUMN, ROW);
for (int r = 0; r < iRows; r++) {
for (int c = 0; c < iColumns; c++) {
Cell cell = sheet.getCell(c, r);
characterarray<i> = cell.getContents();
//wdComponentAPI.getMessageManager().reportSuccess("Row"r characterarray<i>);
i++;
wb.close();
Declare Globally
//@@begin others
String fileuploaded;
IWDModifiableBinaryType binaryType;
String characterarray[] = new String[1000];
//@@end
Also look at this blog too /people/perumal.kanthan/blog/2005/03/21/reading-excel-data-from-java-using-hssf-api
Thanks and Regards,
Arun -
How to upload Excel file in BI using function module in abap program
How to upload Excel file in BI using function module in abap program?
Hi Anuj,
To upload the file , you can try a standard program "RSEPSFTP" .
while you execute the program , a selection screen appears in which the inputs should be give as
RFC destination - The target server name
FTP command- PUT
local file - your file name
local directory - path of your local file
remote file - your target file name
remote directory - where it has to be stored
Hope this is useful for you
Thanks & regards
Anju -
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 excel file in Webdynpro application using ABAP
Hi Experts,
Am developing a webdynpro application in which it will take an excel file as input and display the contents in the form of a table in output. I am able to upload tab delimited text file and populate the table using the below code but not able to do the same with .xls file. Pls let me know if I need to use a different function module for upload excel file.
get single attribute
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.
Bind With table Element.
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_data = wd_context->get_child_node( 'DATA_TAB' ).
lo_nd_data->bind_table( T_TABLE1 ).
Thanks,
SubathraDear Exports
Can anyone guide me how to uplode the .xlsx or ..xls formatted excel file using abap webdynpro without converting it to .txt file. Because my client requirement is only to upload the excel file. because to convert the .xlsx flie to .txt file it will be time taking and cost expanssive. Another requirement is suppose today i have create a application for uploading a file which has 8 columns and 10 rows. suppose tomorrow the client will make some changes in that flat file means the client will add 2 extra columns and 10 more columns in that fil. and will upload that file. Then the new file will be display on the browser or old file. but my requirement is to display the new file in browser.
Can anyone kindly help to solve my problem. I am completely fresher in this field and I need to do it as soon as possible. Please help to solve the problem.
Regards
Rashmita -
Reading XML file using BAPI and then uploading that xml file data into SAP
I am getting a xml file from Java server. I need to take
data from this file using BAPI and need to upload into SAP using SAP.
Please tell me how to read XML files using BAPI's.<b>SDIXML_DATA_TO_DOM</b> Convert SAP data (elementary/structured/table types) into DOM (XML
<b>SDIXML_DOM_TO_XML</b> Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
<b>SDIXML_DOM_TO_SCREEN</b> Display DOM (XML)
<b>SDIXML_DOM_TO_DATA</b>
data: it_table like t001 occurs 0.
data: l_dom TYPE REF TO IF_IXML_ELEMENT,
m_document TYPE REF TO IF_IXML_DOCUMENT,
g_ixml TYPE REF TO IF_IXML,
w_string TYPE XSTRING,
w_size TYPE I,
w_result TYPE I,
w_line TYPE STRING,
it_xml TYPE DCXMLLINES,
s_xml like line of it_xml,
w_rc like sy-subrc.
start-of-selection.
select * from t001 into table it_table.
end-of-selection.
initialize iXML-Framework ****
write: / 'initialiazing iXML:'.
class cl_ixml definition load.
g_ixml = cl_ixml=>create( ).
check not g_ixml is initial.
write: 'ok'.
create DOM from SAP data ****
write: / 'creating iXML doc:'.
m_document = g_ixml->create_document( ).
check not m_document is initial.
write: 'ok'.
write: / 'converting DATA TO DOM 1:'.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'IT_TABLE'
DATAOBJECT = it_table[]
IMPORTING
DATA_AS_DOM = l_dom
CHANGING
DOCUMENT = m_document
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
check not l_dom is initial.
write: / 'appending DOM to iXML doc:'.
w_rc = m_document->append_child( new_child = l_dom ).
if w_rc is initial. write 'ok'.
else. write: 'Err =', w_rc.
endif.
visualize iXML (DOM) ****
write: / 'displaying DOM:'.
CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
EXPORTING
DOCUMENT = m_document
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
convert DOM to XML doc (table) ****
write: / 'converting DOM TO XML:'.
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = m_document
PRETTY_PRINT = ' '
IMPORTING
XML_AS_STRING = w_string
SIZE = w_size
TABLES
XML_AS_TABLE = it_xml
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
write: / 'XML as string of size:', w_size, / w_string.
describe table it_xml lines w_result.
write: / 'XML as table of', w_result, 'lines:'..
loop at it_xml into s_xml.
write s_xml.
endloop.
write: / 'end of processing'.
end of code
Hope this will be useful.
regards
vinod -
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. -
Can 'GUI_UPLOAD' to be used to upload excel file lonely?
Hi experts,
I wonder that can 'GUI_UPLOAD' to be used to upload excel file lonely. I tried and use 'asc' as the L_FILETYPE, but the data uploaded contain many '###yyy'. But if I save the excel file as a txt file,
the data can be uploaded by 'GUI_UPLOAD' correctly. So what is the problem?Excel files be can't uploaded using "GUI_UPLOAD".
Use the FM "ALSM_EXCEL_TO_INTERNAL_TABLE"
Try this code:
* Upload data direct from excel.xls file to SAP
REPORT ZEXCELUPLOAD.
PARAMETERS: filename LIKE rlgrap-filename MEMORY ID M01,
begcol TYPE i DEFAULT 1 NO-DISPLAY,
begrow TYPE i DEFAULT 1 NO-DISPLAY,
endcol TYPE i DEFAULT 100 NO-DISPLAY,
endrow TYPE i DEFAULT 32000 NO-DISPLAY.
* Tick don't append header
PARAMETERS: kzheader AS CHECKBOX.
DATA: BEGIN OF intern OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF intern.
DATA: BEGIN OF intern1 OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF intern1.
DATA: BEGIN OF t_col OCCURS 0,
col LIKE alsmex_tabline-col,
size TYPE i.
DATA: END OF t_col.
DATA: zwlen TYPE i,
zwlines TYPE i.
DATA: BEGIN OF fieldnames OCCURS 3,
title(60),
table(6),
field(10),
kz(1),
END OF fieldnames.
* No of columns
DATA: BEGIN OF data_tab OCCURS 0,
value_0001(50),
value_0002(50),
value_0003(50),
value_0004(50),
value_0005(50),
value_0006(50),
value_0007(50),
value_0008(50),
value_0009(50),
value_0010(50),
value_0011(50),
value_0012(50),
value_0013(50),
value_0014(50),
value_0015(50),
value_0016(50),
value_0017(50),
value_0018(50),
value_0019(50),
value_0020(50),
value_0021(50),
value_0022(50),
value_0023(50),
value_0024(50),
value_0025(50),
value_0026(50),
value_0027(50),
value_0028(50),
value_0029(50),
value_0030(50),
value_0031(50),
value_0032(50),
value_0033(50),
value_0034(50),
value_0035(50),
value_0036(50),
value_0037(50),
value_0038(50),
value_0039(50),
value_0040(50),
value_0041(50),
value_0042(50),
value_0043(50),
value_0044(50),
value_0045(50),
value_0046(50),
value_0047(50),
value_0048(50),
value_0049(50),
value_0050(50),
value_0051(50),
value_0052(50),
value_0053(50),
value_0054(50),
value_0055(50),
value_0056(50),
value_0057(50),
value_0058(50),
value_0059(50),
value_0060(50),
value_0061(50),
value_0062(50),
value_0063(50),
value_0064(50),
value_0065(50),
value_0066(50),
value_0067(50),
value_0068(50),
value_0069(50),
value_0070(50),
value_0071(50),
value_0072(50),
value_0073(50),
value_0074(50),
value_0075(50),
value_0076(50),
value_0077(50),
value_0078(50),
value_0079(50),
value_0080(50),
value_0081(50),
value_0082(50),
value_0083(50),
value_0084(50),
value_0085(50),
value_0086(50),
value_0087(50),
value_0088(50),
value_0089(50),
value_0090(50),
value_0091(50),
value_0092(50),
value_0093(50),
value_0094(50),
value_0095(50),
value_0096(50),
value_0097(50),
value_0098(50),
value_0099(50),
value_0100(50).
DATA: END OF data_tab.
DATA: tind(4) TYPE n.
DATA: zwfeld(19).
FIELD-SYMBOLS: <fs1>.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
mask = '*.xls'
static = 'X'
CHANGING
file_name = filename.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = filename
i_begin_col = begcol
i_begin_row = begrow
i_end_col = endcol
i_end_row = endrow
TABLES
intern = intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
WRITE:/ 'Upload Error ', SY-SUBRC.
ENDIF.
END-OF-SELECTION.
LOOP AT intern.
intern1 = intern.
CLEAR intern1-row.
APPEND intern1.
ENDLOOP.
SORT intern1 BY col.
LOOP AT intern1.
AT NEW col.
t_col-col = intern1-col.
APPEND t_col.
ENDAT.
zwlen = strlen( intern1-value ).
READ TABLE t_col WITH KEY col = intern1-col.
IF sy-subrc EQ 0.
IF zwlen > t_col-size.
t_col-size = zwlen.
* Internal Table, Current Row Index
MODIFY t_col INDEX sy-tabix.
ENDIF.
ENDIF.
ENDLOOP.
DESCRIBE TABLE t_col LINES zwlines.
SORT intern BY row col.
IF kzheader = 'X'.
LOOP AT intern.
fieldnames-title = intern-value.
APPEND fieldnames.
AT END OF row.
EXIT.
ENDAT.
ENDLOOP.
ELSE.
DO zwlines TIMES.
WRITE sy-index TO fieldnames-title.
APPEND fieldnames.
ENDDO.
ENDIF.
SORT intern BY row col.
LOOP AT intern.
IF kzheader = 'X'
AND intern-row = 1.
CONTINUE.
ENDIF.
tind = intern-col.
CONCATENATE 'DATA_TAB-VALUE_' tind INTO zwfeld.
ASSIGN (zwfeld) TO <fs1>.
<fs1> = intern-value.
AT END OF row.
APPEND data_tab.
CLEAR data_tab.
ENDAT.
ENDLOOP.
CALL FUNCTION 'DISPLAY_BASIC_LIST'
EXPORTING
file_name = filename
TABLES
data_tab = data_tab
fieldname_tab = fieldnames.
*-- End of Program -
Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure
Please Help , Urgent Help Needed.
Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
Case's are :
1. Excel File is On Users/ Client PC.
2. Application is on Remote Server(Oracle Forms D2k).
3. User Is Using Application Using Terminal Server LogIn.
4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
6. we are Using Oracle 8.7
So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
Jus help to Sort This Issue ........
you can also write me on :
[email protected], [email protected]TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
Justin -
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
Maybe you are looking for
-
I have been sharing for a while. I regularly listen to my library on two other computers over my wireless network. I recently updated the computer I am sharing from to 10.1.0.56. I also upgraded to the iPhone 4 and did all the necessary for things fo
-
Exchange 2013 will not send out email using MX records, but will via smart host.
When I use a smart host my email goes out fine, but when I use MX look-up it does not. Inbound mail works when I use Telnet to test it. Could this be because I'm testing the server from our office that the FQDN on the Exchange Server will not reso
-
Lack of sharpness in previews - Lightroom 2
I'm hoping the collective wisdom of this forum can help me sort through this issue that is causing me a lot of problems. I am shooting NEFs. When I view my images in Lightroom 2 after import, there is a noticeable lack of sharpness to the images. Eve
-
Ipod from old mac to new?
Sorry to post this, but I couldn't find an answer anywhere... How do you transfer the music from an Ipod that has a connection to an old computer and put the music on the new computer? Thanks, scott
-
Facebook Greetings for All Toshiba Users
Hey everyone, I just wanted to advertise for all Toshiba users, fanpage on fb which is created by one of the authorized service. We will try to answer on all of your question, fix a parts for you if it will be needed or extend your warranty :) Check