问题
I need to extract data from a SAP ABAP system in a format that can then be loaded into an Oracle database (xlsx,csv,dmp.. etc)
Once the data is extracted I'll use Pentaho to upload it into the Oracle database.
Is there a way to extract the data from SAP? I will also need to automate it (the extraction) but that is not too much of a problem right now, I can figure/worry about that part later.
If it is not possible to do so, an explanation why would be helpful!
回答1:
You have a number of options to do this.
If you are running SAP BW, there are many standard tools to help you do extractions and automate the processes.
Otherwise, you can write a simple ABAP program (type 1) to read data from tables and put it into a flat file.
Otherwise, you could write a remote-enabled function module (RFC) and call it using SAP's RFC library.
You could also wrap your RFC function with a web service and call it via SOAP/HTTP.
Lastly, if you have access to the database, you might even be able to write a script to extract the data you need.
A simple example of a program to extract something from a DB table:
report ZEXTRACT_EXAMPLE.
data: lt_t001 type table of t001.
data: ls_t001 type t001.
data: lv_filename type string value '/tmp/outfile.txt'.
select * from t001 into table lt_t001.
open dataset lv_filename for output in text mode encoding default.
loop at lt_t001 into ls_t001.
transfer ls_t001-bukrs to lv_filename.
endloop.
close dataset lv_filename.
This is really primitive, but you get the idea. It selects data from a DB table into an internal table (in memory) and writes it to a file called /tmp/outfile.txt
on the server, from where you can pick it up. (You would have to alter the output to be in your required format).
You could then schedule your program with SM36 to run periodically as a background job.
回答2:
You can also use the remote enabled function module 'RFC_READ_TABLE', you can give it any table name and a separator and it will return the internal table nicely formatted for you.
回答3:
One option to solve this is to find an JDBC driver to the SAP ERP data that gathers the tables by looking at the SAP logical table level.
Once you have the right JDBC driver you can use that from Pentaho.
I have tried this kind of JDBC over SAP ERP solution with Talend and it works great.
RFC_READ_TABLE as pointed out by previous comments is pretty limited in terms of the number of table fields and also the number of records, not to mention conversion issues.
来源:https://stackoverflow.com/questions/9107008/how-to-extract-data-from-a-sap-abap-system