‎2007 Feb 28 5:04 PM
This could be a relatively simple question/answer, but I've spent a rediculously long time trying to figure it out...
I have a program that is reading a tab delimited file into an internal table. I can see that the internal table is being populated correctly. How do I get the data from the internal table inserted into a database table?
The database table is YMMOM and has five fields: mandt (clnt 3), matnr (char 18), ylegacy (char 4), ycount (char 4), and zbismt (char 30). The internal table is set up as follows:
data: begin of in_tab occurs 0,
matnr like ymmom-matnr,
ylegacy like ymmom-ylegacy,
ycount like ymmom-ycount,
zbismt like ymmom-zbismt,
end of in_tab.I've tried
MOVE-CORRESPONDING in_tab TO ymmom.and I can see in the debugger that the structure is being populated, but when I go back and try to look at the contents of ymmom, the data hasn't been actually uploaded.
Thanks in advance for any help you can provide.
‎2007 Feb 28 5:18 PM
Hi,
You have to user INSERT statement to insert records to the database table..
data: begin of in_tab occurs 0,
matnr like ymmom-matnr,
ylegacy like ymmom-ylegacy,
ycount like ymmom-ycount,
zbismt like ymmom-zbismt,
end of in_tab.
<b>MOVE-CORRESPONDING in_tab TO ymmom.
ymmom-mandt = sy-mandt.
Insert the records to the databse table.
INSERT ymmom.
IF SY-SUBRC = 0.
COMMIT WORK.
ENDIF.</b>
Thanks,
Naren
‎2007 Feb 28 5:18 PM
Hi,
You have to user INSERT statement to insert records to the database table..
data: begin of in_tab occurs 0,
matnr like ymmom-matnr,
ylegacy like ymmom-ylegacy,
ycount like ymmom-ycount,
zbismt like ymmom-zbismt,
end of in_tab.
<b>MOVE-CORRESPONDING in_tab TO ymmom.
ymmom-mandt = sy-mandt.
Insert the records to the databse table.
INSERT ymmom.
IF SY-SUBRC = 0.
COMMIT WORK.
ENDIF.</b>
Thanks,
Naren
‎2007 Feb 28 5:34 PM
This did the trick, thanks! And especially for the quick response!
‎2007 Mar 01 3:42 AM
‎2007 Feb 28 5:23 PM
Hi
Perhpas you're transfering records with the same key or that records are in the table YMMOM or you didn't do the insert.
Your code seems to be ok, only the insert is missing:
MOVE-CORRESPONDING in_tab TO ymmom.
<b>INSERT YMMOM.</b>
Max
‎2007 Mar 04 7:20 AM
Hi,
Use UPDATE statement to update Database table.
Regards,
Chandra
‎2007 Mar 05 9:54 AM
Hi Bryan,
<b>One important point is ..................... </b> You can use either OPEN sql
commands or NATIVE sql commands. But, if you insert records into the table
through program either using OPEN sql commands or NATIVE sql commands,
be aware that you are inserting records WITHOUT any checks like Check table validation,Fixed values, and some others validations which are required for the field. Always, insert records into database through screen for consistency
of the data. In very extreme cases we insert records through program.
If you want to insert bulk amount of records.You can acheive this
using BDC technique<b>( WITH consistency )</b> that is either using CALL TRANSACTION method or SESSION method, instead of using either OPEN sql commands or NATIVE sql commands<b>(WITHOUT consistency)</b> in program.
If you have queries regarding this, you are welcome.
If you already know this ignore this.
Hope that, the above desc. is helpful for you.
Regards,
V.Raghavender.