‎2013 May 17 6:31 AM
Message was edited by: Kesavadas Thekkillath
‎2013 May 17 6:48 AM
‎2013 May 17 7:03 AM
Hi,
Take cursor on the word do F1 you will know
Cheers,
Arindam
‎2013 May 17 7:12 AM
Hi Pradeep,
That insert statement is used to insert multiple lines/records from internal table to database table.
INSERT (<ls_fieldname>-name) FROM TABLE <lt_data>.
Here <ls_fieldname>-name contains the name of the DB Table. ( ) Represents token. So that <ls_fieldname>-name is replaced with its containing value. And <lt_data> is the field symbol pointing to a table.
In short,
Inserting Several Lines
To insert several lines into a database table, use the following:
INSERT <target> FROM TABLE <itab> [ACCEPTING DUPLICATE KEYS] .
This writes all lines of the internal table <itab> to the database table in one single operation. The same rules apply to the line type of <itab> as to the work area <wa> described above.
Refer following link.....
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm
- Regards
ShashanK MarathE
‎2013 May 17 7:15 AM
Hi Pradeep,
The following insert statement will throw you dump.....
INSERT (<ls_fieldname>-name) FROM TABLE <lt_data>...........since that table name is not existing.....
regards,
narayan
‎2013 May 17 7:15 AM
Hi Pradeep,
According to my knowledge it gives dump, because the attribute <ls_fieldname>-name holds the field name no the database table name. So it is not possible to insert the work area into field name.
INSERT <dbname> FROM TABLE itab.
The syntax is use should use the database table name.
So it gives dump.
Or you can store your database table name into some variable and it can be used as:
INSERT (lv_database) FROM TABLE itab.
‎2013 May 17 7:28 AM
If you use variable name inside the ( ), then the value inside that variable name will be considered.
‎2013 May 17 7:20 AM
Hi Pradeep,
This will give you a Dump.
I guess you are using type descriptor, If that is the case the proper way to insert is using a Table Name. This can be done using a method in type descriptor get_ddic_structure. Use this and you will get the table name, now store it in a variable (lv_name) now use INSERT ( lv_name )
Regards,
Pratheek
‎2013 May 17 7:23 AM
Hi Pradeep,
your code should be somewhat like this.......
field-symbol: <f1> type any.
LOOP AT lr_strucdescr->components ASSIGNING <ls_fieldname>.
ASSIGN COMPONENT <ls_fieldname>-name OF STRUCTURE ls_insert to <f1>.
INSERT (lv_tablename) FROM <f1>.
endloop.
since your assign statement will be returning a name from structure ls_insert and not an internal table
regards,
narayan