05-05-2005 1:29 AM
Hello,
I am trying to INSERT (10000+ rows) data into a SAP table from some other data source.
How can I achieve this most efficiently with the help of ABAP.
Thanks and Regards,
Sheetal
05-05-2005 4:57 AM
Hi Sheetal,
Just put all your records into an internal table and insert them all at one go! That is the best way to do it.
Regards,
Anand Mandalika.
05-05-2005 6:59 PM
Hello Anand,
Thanks you.
Let me explain my question in more details -
I have to insert data from sql server into SAP tables. The souce table and destination table are not fixed.I should be able to create an internal table structure dynamically depending on the destination table.
Read data from selected columns of sql server's source table and insert them into the selected columns from SAP table.
As you mentioned using internal tables is the efficient way of handling this.How to create an internal table dynamically?
Thanks and Regards,
Sheetal
05-05-2005 7:13 PM
Dynamic Internal Table: I found the follwing code which might help you create dynamic internal table. Then you can use this to update table in SAP.
-
CODE
-
DATA: struc_type TYPE REF TO cl_abap_structdescr,
table_type TYPE REF TO cl_abap_tabledescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp LIKE LINE OF comp_tab,
sref TYPE REF TO data,
tref TYPE REF TO data.
FIELD-SYMBOLS: <struc> TYPE ANY,
<table> TYPE ANY TABLE.
comp-name = 'column1'.
comp-type = cl_abap_elemdescr=>get_c( 40 ).
APPEND comp TO comp_tab.
comp-name = 'column2'.
comp-type = cl_abap_elemdescr=>get_i( ).
APPEND comp TO comp_tab.
struc_type = cl_abap_structdescr=>create( comp_tab ).
table_type = cl_abap_tabledescr=>create( struc_type ).
CREATE DATA: sref TYPE HANDLE struc_type,
tref TYPE HANDLE table_type.
ASSIGN: sref->* TO <struc>,
tref->* TO <table>.
...
LOOP AT <table> ASSIGNING <struc>.
...
ENDLOOP.
Thanks
Shashi Reddy
05-06-2005 6:24 AM
Hi!
There are also Weblogs about dynamic internal tables, e.g. this:
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
Regards,
Christian