Writing Data from a Table to Excel
Hi Experts
I have a requirement to load data from an Oracle Table to an excel File. I was able to use OdiSqlUnload to achieve this, but the problem is I am not getting Header Information in my Excel. Please advise if there is any other method through which I can achieve this.
Thanks
Hi,
Create a datastore in the file tecnology and make it delimited by ";".
After that create an interface from table to it.
In the IKM, you can chose to generate the header
OR
Use 2 OdiSqlUnload where the first just create the file and the header (a select column name from dual where column names are constants ) and the 2 append the real data
Make any sense?
Similar Messages
-
Writing data from a table to Excel file
Hello friends,
I am using Forms 5.0 on Windows NT. I need to write data from table A to Excel sheet from trigger 'when-botton-pressed'. Could you help me Any help will be appriciated.
Thanks
Charg
nullHERE IS THE CODE.
YOU CAN RUN IT USING THE DEPT TABLE.
PROCEDURE export_transaction_to_excel IS
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
fdes varchar2(250);
rowcounter number:=1;
local_cursor_record number:=:system.cursor_record;
old_cursor_style varchar2(100);
errors_occured boolean:=false;
ole_error exception;
pragma exception_init(ole_error, -305500);
my_alert_id alert;
alert_respnse number;
procedure place_value_in_cell(rownum_in in number,colnum_in in number,value_in in varchar2) is
args ole2.list_type;
begin
args:=ole2.create_arglist;
ole2.add_arg(args,rownum_in);
ole2.add_arg(args,colnum_in);
--cell:=ole2.invoke_obj(worksheet,'Cells',args);
cell:=ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value',value_in);
ole2.release_obj(cell);
end place_value_in_cell;
procedure savespreadsheet is
args ole2.list_type;
vDatestamp varchar2(20);
begin
fdes:='C:\TESTFORM.XLS';
vDatestamp:=to_char(sysdate,'mmddyyyyy')| |'-'| |to_char(sysdate,'hh24miss');
args:=ole2.create_arglist;
ole2.add_arg(args,fdes);
ole2.invoke(worksheet,'SaveAs',args);
ole2.destroy_arglist(args);
ole2.invoke(application,'Quit');
end savespreadsheet;
procedure open_excel_workbook is
begin
application:=ole2.create_obj('Excel.Application');
workbooks:=ole2.get_obj_property(application,'Workbooks');
workbook:=ole2.invoke_obj(workbooks,'Add');
worksheets:=ole2.get_obj_property(application,'Worksheets');
worksheet:=ole2.invoke_obj(worksheets,'Add');
end open_excel_workbook;
procedure write_column_header is
begin
place_value_in_cell(rowcounter,1,'Depart No');
place_value_in_cell(rowcounter,2,'Depart Name');
place_value_in_cell(rowcounter,3,'Loc');
rowcounter:=rowcounter+1;
end write_column_header;
procedure export_the_data is
original_receipt number;
original_date date;
original_transmital_number number;
begin
go_block('dept');
first_record;
loop
place_value_in_cell(rowcounter,1,to_char(:deptno));
place_value_in_cell(rowcounter,2,:dname);
place_value_in_cell(rowcounter,3,:loc);
exit when :system.last_record='TRUE';
next_record;
rowcounter:=rowcounter+1;
end loop;
end export_the_data;
BEGIN
begin
old_cursor_style:=get_application_property(cursor_style);
set_application_property(cursor_style,'BUSY');
open_excel_workbook;
write_column_header;
export_the_data;
exception
when form_trigger_failure then
raise;
when ole_error then
message('error sending data to excel');
message(' ');
errors_occured:=true;
end;
savespreadsheet;
ole2.release_obj(worksheet);
ole2.release_obj(worksheets);
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.release_obj(application);
if not errors_occured then
go_record(local_cursor_record);
end if;
set_application_property(cursor_style,old_cursor_style);
END export_transaction_to_excel; -
Gui_download for transferring the data from internal table to excel sheet.
hi all,
i am using gui_download for transferring the data from internal table to excel sheet.
I have a internal table with 3 columns col1,col2,col3 and I am getting the file at the specified path,but my problem is that,in the excel sheet(path specified) all the 3 columns values are printed in one column.Please help me.
Thanks in advance.Hi Venkata,
plz use FM 'SAP_CONVERT_TO_XLS_FORMAT' :
call function 'SAP_CONVERT_TO_XLS_FORMAT'
exporting
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_filename = p_file
* I_APPL_KEEP = ' '
tables
i_tab_sap_data = t_mbew
* CHANGING
* I_TAB_CONVERTED_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.
Hope this helps,
Erwan -
How to Export data from a Table to Excel using PL/SQL Code
Hi,
I need to export data from a table to the excel sheet using PL/SQL script.
could you pls provide with custom codes or sample procedures.
Bobbyhttp://asktom.oracle.com/pls/ask/f?p=4950:8:7947129213057862756::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:728625409049
-
Store data from a table into excel sheet and email
Hi all,
I am just wondering, i m not sure where to start. I want to insert data from a table into an excel spread sheet.
I'm working on a stored procedure with 3 input parameters:
1. the actual query
2. userid
3. the column headers (comma separated) - these will be in the same order as the outer select statement in the query itself. I will use the column headers for the respective columns in Excel worksheet.
When the proc is executed, the excel is populated. If the record count is > 65536, then I need to create multiple worksheets in the same excel file.
How can i do that? Can any body please help with this..?We are doing like this ( Not sure whether it is the best method available)
--Get the output of the query (Since the number of columns is not fixed you would have to use dbms_sql package)
--loop through the output and write into a file, for example test.csv, using UTL_FILE package
--load the file into a blob variable(we are doing it by loading it into a table)
--For mailing You can use the below package
http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
Mailing code we are using is given below:
CREATE OR REPLACE procedure xls_mail(
p_sender varchar2, -- sender, example: 'Me <[email protected]>'
p_recipients varchar2, -- recipients, example: 'Someone <[email protected]>'
p_subject varchar2, -- subject
p_text varchar2, -- text
p_filename varchar2, -- name of xls file
p_blob blob -- xls file
) is
conn utl_smtp.connection;
i number;
len number;
BEGIN
conn := demo_mail.begin_mail(
sender => p_sender,
recipients => p_recipients,
subject => p_subject,
mime_type => demo_mail.MULTIPART_MIME_TYPE);
demo_mail.begin_attachment(
conn => conn,
mime_type => 'application/xls',
inline => TRUE,
filename => p_filename,
transfer_enc => 'base64');
-- split the Base64 encoded attachment into multiple lines
i := 1;
len := DBMS_LOB.getLength(p_blob);
WHILE (i < len) LOOP
IF(i + demo_mail.MAX_BASE64_LINE_WIDTH < len)THEN
UTL_SMTP.Write_Raw_Data (conn
, UTL_ENCODE.Base64_Encode(
DBMS_LOB.Substr(p_blob, demo_mail.MAX_BASE64_LINE_WIDTH, i)));
ELSE
UTL_SMTP.Write_Raw_Data (conn
, UTL_ENCODE.Base64_Encode(
DBMS_LOB.Substr(p_blob, (len - i)+1, i)));
END IF;
UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
i := i + demo_mail.MAX_BASE64_LINE_WIDTH;
END LOOP;
demo_mail.end_attachment(conn => conn);
demo_mail.attach_text(
conn => conn,
data => p_text,
mime_type => 'text/html');
demo_mail.end_mail( conn => conn );
END; -
Data from word tables to excel master spreadsheet
Hello, I'm looking to take data from my damage report forms that come in maybe 20 times a week. This data needs to goto a master excel spreadsheet. I've managed to find a macro that does this but it does not paste it into excel the way I require and also
extracts data I do not require.
The word document contains a column of headings on the left, these will be the master spreadsheet sheet column headers. These will be on the spreadsheet already so I don't need them copied.
The other two columns contains the data I will need to xfer to excel. I was thinking bookmarks can help here but I'm unsure if these will save over from the original template?
So, if there is some code out there that can help, brilliant. It will be an excel macro in the master spreadshee. TThat takestthe datadfrom the active word doc or by selecting the word doc in its folder.
Fingers crossed.
JosephHi Joseph,
You should be able to run below code to get the data out of the Tabel(s) of a Word Document from within Excel.
You can modify the code accordingly to your needs to specify the range where you want the data to be copied.
I have already slightly modified the code to skip the header information.
Sub ImportWordTable()
Dim wdDoc As Object
Dim wdFileName As Variant
Dim TableNo As Integer 'table number in Word
Dim iRow As Long 'row index in Excel
Dim iCol As Integer 'column index in Excel
wdFileName = Application.GetOpenFilename("Word files (*.docx),*.docx", , _
"Browse for file containing table to be imported")
If wdFileName = False Then Exit Sub '(user cancelled import file browser)
Set wdDoc = GetObject(wdFileName) 'open Word file
With wdDoc
TableNo = wdDoc.tables.Count
If TableNo = 0 Then
MsgBox "This document contains no tables", _
vbExclamation, "Import Word Table"
ElseIf TableNo > 1 Then
TableNo = InputBox("This Word document contains " & TableNo & " tables." & vbCrLf & _
"Enter table number of table to import", "Import Word Table", "1")
End If
With .tables(TableNo)
'copy cell contents from Word table cells to Excel cells
' start with row 2 to skip headers
For iRow = 2 To .Rows.Count
For iCol = 1 To .Columns.Count
' Define starting point here
Cells(iRow - 1, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
Next iCol
Next iRow
End With
End With
Set wdDoc = Nothing
End Sub
The source is this link:
Export Word Table in Excel
Also this Forum is more for generic Excel questions, for better response post in Excel For Developer Forum.
Hope this helps,
Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"
Please vote an answer helpful if they helped. Please mark an answer(s) as an answer when your question is being answered. -
Writing data from a table into a spreadsheet file
I've managed to figure out putting a table on the screen for user in put (I think I made it more difficult for myself than it actually was) and I can have LabVIEW convert the data into a spreadsheet string and display that for me. Now I'd like to send the data entered into the table out as a tab-delimited text file. What's holding me up at the moment is that not all the data in the table is numeric. I've got four columns, the first of which will hold an 8- or 9-digit serial number, presently starting with 0. Columns 2-4 will be numeric (integer) information. What's the proper way to get my table data into this tab-delimited text file?
Thank you for your help.
-DanHi,
The attached example shows how table content is convert to spreadsheet string for storing, as well as converting read spreadsheet string to table data for displaying.
Hope this is useful
Regards,
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010
依恩与LabVIEW
LVVILIB.blogspot.com
Attachments:
IFK_TABLE_Saving & Retrieving Table Content.vi 69 KB -
Download data from internal table to excel sheet from the background
Hello Experts,
I have written a code where the data is stored in the internal table . Now when i run this code in the background i want this internal table data to get downloaded in the excel sheet. The function module GUI_DOWNLAOD is not supported in the background. So is there any other function module that can be used or is there any other way to do this
Thanks in advanceHi Aditya,
I would provide you 2 advice:
1. save the file on the application server as text file and the fileds in it separated by TAB,you can download the file whenever you want and open it with excel.
2.generate excel files and send it to the email address whatever you specify in the selection-screen.
Thanks,
Sam -
Downloding from internal table to excel
Hi All,
I am using ole concept to download data from internal table to excel because i want to fill few records with colors and few with bold etc.
But this ole concept is downloading to excel line by line and taking much time.
How can i improve the performance in this concept or is there any other concept please let me know.
i am using fallowng logic to download to excel.
*Generating the Excel report in the foreground
data: h_excel type ole2_object, " Excel object
h_mapl type ole2_object, " list of workbooks
h_map type ole2_object, " workbook
start Excel
create object h_excel 'EXCEL.APPLICATION'.
set property of h_excel 'Visible' = 1.
get list of workbooks, initially empty
call method of h_excel 'Workbooks' = h_mapl.
perform err_hdl.
add a new workbook
call method of h_mapl 'Add' = h_map.
perform err_hdl.
output column headings to active Excel sheet
perform fill_cell using 1 1 1 000 'Job Name'(001).
perform fill_cell using 1 2 1 000 'Variant'(002).
perform fill_cell using 1 3 1 000 'Description'(003).
perform fill_cell using 1 4 1 000 'Run Date'(004).
perform fill_cell using 1 5 1 000 'Run Time'(005).
perform fill_cell using 1 6 1 000 'Duration'(006).
perform fill_cell using 1 7 1 000 'Spool'(007).
perform fill_cell using 1 8 1 000 'Records Upl'(008).
perform fill_cell using 1 9 1 000 'Error'(009).
perform fill_cell using 1 10 1 000 'Total'(010).
perform fill_cell using 1 11 1 000 'Action'(011).
perform fill_cell using 1 12 1 000 'ReRun'(012).
loop at t_final.
copy datato active EXCEL sheet
h = sy-tabix + 1.
perform fill_cell using h 1 0 000 t_final-jobname.
perform fill_cell using h 2 0 000 t_final-variant.
perform fill_cell using h 3 0 000 t_final-description.
perform fill_cell using h 4 0 000 t_final-strtdate.
perform fill_cell using h 5 0 000 t_final-strttime.
perform fill_cell using h 6 0 000 t_final-duration.
perform fill_cell using h 7 0 000 t_final-listident.
perform fill_cell using h 8 0 000 t_final-rec_upl.
perform fill_cell using h 9 0 000 t_final-rec_err.
perform fill_cell using h 10 0 000 t_final-rec_tot.
if t_final-comment eq 'job did not run'.
perform fill_cell using h 11 0 200 t_final-comment.
elseif t_final-rec_err eq 0.
perform fill_cell using h 11 0 000 t_final-comment.
else.
perform fill_cell using h 11 0 200 t_final-comment.
endif.
perform fill_cell using h 12 0 000 t_final-rerun.
endloop.
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
call method of h_excel 'Worksheets' = h_mapl." EXPORTIN G #1 = 2.
perform err_hdl.
add a new workbook
call method of h_mapl 'Add' = h_map exporting #1 = 2.
perform err_hdl.
tell user what is going on
set property of h_map 'NAME' = 'COPY'.
loop at t_final.
copy flights to active EXCEL sheet
h = sy-tabix + 1.
perform fill_cell using h 1 0 000 t_final-jobname.
perform fill_cell using h 2 0 000 t_final-variant.
perform fill_cell using h 3 0 000 t_final-description.
perform fill_cell using h 4 0 000 t_final-strtdate.
perform fill_cell using h 5 0 000 t_final-strttime.
perform fill_cell using h 6 0 000 t_final-duration.
perform fill_cell using h 7 0 000 t_final-listident.
perform fill_cell using h 8 0 000 t_final-rec_upl.
perform fill_cell using h 9 0 000 t_final-rec_err.
perform fill_cell using h 10 0 000 t_final-rec_tot.
if t_final-comment eq 'job did not run'.
perform fill_cell using h 11 0 200 t_final-comment.
elseif t_final-rec_err eq 0.
perform fill_cell using h 11 0 000 t_final-comment.
else.
perform fill_cell using h 11 0 200 t_final-comment.
endif.
perform fill_cell using h 12 0 000 t_final-rerun.
endloop.
free object h_excel.
perform err_hdl.
*& Form ERR_HDL
outputs OLE error if any *
form err_hdl.
if sy-subrc <> 0.
write: / 'Batch Job Automation Carried Out Succesfully'.
stop.
endif.
endform. " ERR_HDL .
FORM FILL_CELL *
sets cell at coordinates i,j to value val boldtype bold *
form fill_cell using i j bold col val.
call method of h_excel 'Cells' = h_zl exporting #1 = i #2 = j.
perform err_hdl.
set property of h_zl 'Value' = val .
perform err_hdl.
get property of h_zl 'Font' = h_f.
perform err_hdl.
set property of h_f 'Bold' = bold .
perform err_hdl.
set property of h_f 'Color' = col.
perform err_hdl.
endform. "FILL_CELLHi,
You are populating the Cells one by one from the internal table, and all of them are coloured and font is bold. the method is OK, but when the amount of data is huge - it is going to take a longer time. May be the performance will improve a little if you turn the visibility off.
I ll suggest you to use ALV_XXL_CALL, it can color the key columns, at the same time you can have colored headings - and the performance is good. It is the same function module called when you do a "Export to Excel" from an ALV grid. But you can compain about the Font characteristics - as this does not change the Font size etc.
Your code has got a lot of freedom as long as the formatting is concerned - for bigger data - i ll suggest you to use a WS_DOWNLOAD kind of a function module to get the data at once in the presentation server and then call Excel methods and do the formatting. -
Writing data from Java to Excel
Hi,
I am trying to writhe data from Java to an Excel Sheet by using JACOB.
This is my code :
import java.util.*;
import java.io.*;
//import cost.util.*;
import com.jacob.com.*;
import com.jacob.activeX.*;
class XLStock
public static void main(String argv[])
XLStock xls = new XLStock();
xls.main2(argv);
public void main2(String argv[])
System.setSecurityManager(null);
System.runFinalizersOnExit(true);
Vector v = new Vector();
XLSPutItem pi;
String sheetfile = null;
ActiveXComponent xl;
Object xlo=null;
Object workbooks;
Object workbook;
Object sheets;
Variant vOptn = new Variant();
vOptn.noParam();
try
xl = new ActiveXComponent("Excel.Application");
xlo = xl.getObject();
Dispatch.put(xlo, "Visible", new Variant(true));
xl.setProperty("Visible", new Variant(true));
workbooks = xl.getProperty("Workbooks").toDispatch();
Variant vTemp = new Variant(argv[0]);
workbook = Dispatch.invoke(workbooks, "Open", Dispatch.Method,
new Variant[] {vTemp, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn},
new int[1]).toDispatch();
sheets = Dispatch.get(workbook,"Sheets").toDispatch();
pi = new XLSPutItem();
if (pi.Parse("1:A1;ciao;6"))
v.addElement(pi);
for (int i=0; i<v.size(); i++)
pi = (XLSPutItem)v.elementAt(i);
pi.sheet = Dispatch.invoke(sheets, "Item", Dispatch.Get, new Object[] {new Variant(pi.sheetNumber)}, new int[1]).toDispatch();
pi.cell = Dispatch.invoke(pi.sheet, "Range", Dispatch.Get, new Object[] {pi.cellName}, new int[1]).toDispatch();
catch (Exception e)
e.printStackTrace();
pi = (XLSPutItem)v.firstElement();
Dispatch.put(pi.cell, "Value", "ciao");
What happen is that my code always fail at this line :
xl = new ActiveXComponent("Excel.Application");
whit this error :
C:\VJWorks\JNI\jxls>java jxls.XLStock
com.jacob.com.ComFailException: Can't co-create object
at com.jacob.com.Dispatch.createInstance(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java)
at jxls.XLStock.main2(XLStock.java:53)
at jxls.XLStock.main(XLStock.java:28)
Exception in thread "main" java.util.NoSuchElementException
at java.util.Vector.firstElement(Vector.java:450)
at jxls.XLStock.main2(XLStock.java:79)
at jxls.XLStock.main(XLStock.java:28)
I task that something is wrong in my system configuration.
I work on a Win2000 platform and Office 97.
Someone knows the reason of this error and can suggest what to make.
Thanks in advance.
Antonio M.Antonio, maybe you can post this back to the Jacob list. As an alternative to Jacob, what about Apache POI or writing the data as comma-delimited and opening the file using Runtime?
Hope that may help.
Good luck. -
Loading data from multiple tables to multiple sheets of excel using SSIS
I have a requirement in which I want to load data from 13 tables to 13 respective sheets of single excel file using SSIS.
Can anyone know SSIS logic for developing package for this?see similar example here
http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
In your case you need to use loop to iterate through tables
First get list of tables in a object variable created in SSIS using INFORMATION_SCHEMA.TABLES view
Then add a for each loop based on ADO.NET variable enumerator to iterate through tables and inside loop follow method as in the above link to create the sheet first and populate it.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How can i extract data from oracle table to flat file or excel spread shee
Hello,
DB Version is 10.1.0.3.0
How can i extract data from oracle table to flat file or excel spread sheet by using sub programs?
Regards,
DHere what I did
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
Sql> SPOOL bing
select * from -------;
SPOOL OFF;
I do not see file.
I also tried
Sql> SPOOL /tmp/bing
select * from -------;
SPOOL OFF;
But still not seeing the fie, -
Generic datasource by function module to fetch data from multiple tables?
I'm writing a function module to fetch price, for generic datasource.
At first, extract test is OK. But InfoPackage never stop when loading data to PSA in BW.
And I find the example codes:
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT (S_S_IF-T_FIELDS) FROM SFLIGHT
WHERE CARRID IN L_R_CARRID AND
CONNID IN L_R_CONNID.
ENDIF. "First data package ?
* Fetch records into interface table.
* named E_T_'Name of extract structure'.
FETCH NEXT CURSOR S_CURSOR
APPENDING CORRESPONDING FIELDS
OF TABLE E_T_DATA
PACKAGE SIZE S_S_IF-MAXSIZE.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
ENDIF.
There using Cursor to fetch data package by package, and raise exception NO_MORE_DATA to stop the loading process.
Now I fetch data from multiple tables, I don't think I can use Cursor.
Then How can I handle this?
Thanks a lot.Thanks
IF IT_999[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A999 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_999
WHERE
* A~KNUMH = IT_999-KNUMH AND
( ( A~KSCHL = 'ZPRC' AND VKORG = 'Z000' AND VTWEG = 'Z1' ) OR
( A~KSCHL = 'ZPRD' AND VKORG = 'A000' AND VTWEG = 'Y3' ) ) AND
* A~DATBI >= SY-DATUM AND
LOEVM_KO = ''.
SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A999 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_999
WHERE
* A~KNUMH = IT_999-KNUMH AND
A~KSCHL = 'ZPR3' AND A~VKORG = 'I000' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
IF IT_997[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A997 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_997
WHERE
* A~KNUMH = IT_997-KNUMH AND
A~KSCHL = 'ZPRA' AND VTWEG = 'Y1' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
IF IT_996[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A996 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_996
WHERE
* A~KNUMH = IT_996-KNUMH AND
A~KSCHL = 'ZPRB' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
SELECT MATNR "u7269u6599u53F7u7801
MEINH "u4ED3u50A8u5355u4F4Du7684u5907u7528u8BA1u91CFu5355u4F4D
UMREZ "u57FAu672Cu8BA1u91CFu5355u4F4Du8F6Cu6362u5206u5B50
UMREN "u8F6Cu6362u4E3Au57FAu672Cu8BA1u91CFu5355u4F4Du7684u5206u6BCD
FROM MARM
INTO CORRESPONDING FIELDS OF TABLE IT_MARM
FOR ALL ENTRIES IN TP_DATA
WHERE MATNR = TP_DATA-MATNR AND MEINH = TP_DATA-KMEIN.
LOOP AT TP_DATA.
IF TP_DATA-KPEIN NE 0.
TP_DATA-KBETR = TP_DATA-KBETR / TP_DATA-KPEIN.
TP_DATA-KHETR = TP_DATA-KHETR / TP_DATA-KPEIN.
ENDIF.
IF TP_DATA-KSCHL = 'ZPRA'.
* TP_DATA-MEINH = 'ZI'.
* TP_DATA-KSCHL = 'B4'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'CT'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPRB'.
* TP_DATA-KSCHL = 'L0'.
* TP_DATA-MEINH = 'ZI'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPRC' OR TP_DATA-KSCHL = 'ZPRD'.
* TP_DATA-MEINH = 'ZI'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'WZI'.
TP_DATA-KBETR = TP_DATA-KBETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPR3'.
* TP_DATA-KSCHL = 'B2'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ENDIF.
TP_DATA-MEINH = '01'.
MODIFY TP_DATA.
E_T_DATA-MATNR = TP_DATA-MATNR.
E_T_DATA-KSCHL = TP_DATA-KSCHL.
E_T_DATA-KHETR = TP_DATA-KHETR.
E_T_DATA-KBETR = TP_DATA-KBETR.
E_T_DATA-KMEIN = TP_DATA-KMEIN.
E_T_DATA-DATAB = TP_DATA-DATAB.
E_T_DATA-DATBI = TP_DATA-DATBI.
APPEND E_T_DATA.
CLEAR WA_MARM1.
CLEAR WA_MARM2.
ENDLOOP.
Edited by: Shen Peng on Oct 20, 2010 10:09 AM -
How can i convert the data from mutiple-table to the other database(MSSQL)?
Dears,
How can i convert the data from mutiple-table to the other database such as MS-SQL?
I have a third party system based on MS-SQL 2000.
Now we want to make a integration between SAP R/3(Oracle) and SQL server.
When my user releases the purchase order in R/3, the application we coded will convert the releated data to the temp database on the SQL server.
But i don't know which tools will help me reach the purpose. BAPI, LSMW, IDoc... ???
Would anybody tell me which way is better and how to do?
Thanks a lot!
Kevin WangHello Kevin,
The question to use which method depend on your detail requirements. If you use BAPI, you need to find which Bapi can provide the data you want. Bapi normally use as a function called by external system. So you need to develop an external program like VB/Java to call this Bapi and move it to SQL. LSMW is use when you want to upload data from an external system to SAP. So it does not serve your requirement. Idoc can be use to export data to an external system. Again like Bapi, you need to find what Idoc can provide the data you want. However, it does not any programming from the external system. If I were you, based on your requirements, I think writing an Abap program that read the data you want and download it to NT/SQL server will be faster and easier. -
[b]export data from a table to a csv or .txt file[/b]
hi plz i need help in how to export data from a table to a csv or .txt file
If you are using TOAD, then you can execute the statement like SELECT * FROM TABLE1
Then, you can go to Output Grid and you can say save as and you can save it as you want, excel, tab delimited or whatever.
Thanx,
Cheers,
Maybe you are looking for
-
Unable to install the downloaded camera raw for PSE10 on Mac
At first, I wasn't able to open .nef files from my Nikon D800E. I then realized that I needed to update my camera raw installers. The available versions were 6.5, 6.6, and 6.7 from the adobe website. I also downloaded the Adobe App Manager as it was
-
Add Files java applet does not trust our certificate
We have installed Novell Filr and it is working great except for one issue. The java applet that runs when the Add Files button is clicked does not trust our certificate authority. We purchased and installed a SSL certificate, and both IE and Firefox
-
When I want to make a phonecall with my iphone5, I hear absolutely nothing....no ringing and no talking when connection established. When I make the same call but now on speaker, no problem or what so ever, can anyone help me ?
-
Use GET PERNR without any screen default from Logical DB.
Could anyone help me how to avoid using screen default from logical DB if using GET PERNR?
-
How do I deauthorize a lost iPod touch
How do I deauthorize a lost iPod touch