Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Insert data using Open SQL.

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

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 found in thread:

-


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

0 Kudos

Hi!

There are also Weblogs about dynamic internal tables, e.g. this:

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

Regards,

Christian