‎2009 Dec 10 12:56 PM
hi gurus,
Iam taking value from the TXT file using GUI_upload into internal table and then inserting the value into the z table.
but it is inserting only the first row of the internal table... I have 150 records in internal table...
so plz help me on this matter..
thanx
man
‎2009 Dec 10 1:01 PM
Hi Manish Sharma,
Try to Debug your program and see what is happening... Please paste some part of your code what you have written ...
Also check the content of internal table as well..
Are you using loop to process the internal table or not ?
You need to clear header line or work area after INSERT Statement...
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya
‎2009 Dec 10 1:01 PM
Hi Manish Sharma,
Try to Debug your program and see what is happening... Please paste some part of your code what you have written ...
Also check the content of internal table as well..
Are you using loop to process the internal table or not ?
You need to clear header line or work area after INSERT Statement...
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya
‎2009 Dec 10 1:09 PM
my code is like that. YEAR1 is the PRIMARY KEY IN IT
itab1-mandt = wa-mandt.
itab1-year1 = wa-year1.
itab1-MATNR = wa-MATNR.
itab1-WERKS = wa-WERKS.
itab1-MENGE = wa-MENGE.
itab1-LGORT = wa-LGORT.
APPEND ITAB1.
clear itab1.
endloop.
LOOP AT ITAB1.
if itab1 is not initial.
insert into ZRG1_APRDATA1 values itab1.
endif.
ENDLOOP.
Its only taking first row of internal table
Edited by: Manish Sharma on Dec 10, 2009 2:09 PM
Edited by: Manish Sharma on Dec 10, 2009 2:12 PM
‎2009 Dec 10 1:16 PM
did you check whether you have duplicate entries?
try to delete the duplicate entries based on Primary key and then insert.
You have given only YEAR as primary key.
I feel, you might be having more than 1 entry with same year.
if so change the entries to different year for all the records.
Else, make Material as Primary key and pass diff material.
thanks
Padma
‎2009 Dec 10 1:18 PM
‎2009 Dec 10 1:28 PM
>
> LOOP AT ITAB1.
> if itab1 is not initial.
> insert into ZRG1_APRDATA1 values itab1.
> endif.
> ENDLOOP.
>
Instead give like this,
Insert ZRG1_APRDATA1 from table itab1.thanks,
Padma
Edited by: Padmashree RamMaghenthar on Dec 10, 2009 6:59 PM
‎2009 Dec 10 4:49 PM
Hi,
Please paste some records here(may be five records), that will help to solve the issue, as we have data and the code.
Thanks,
Srini.
‎2009 Dec 10 6:28 PM
Could you provide a little bit more of your code? Are you sure that you have more than one row in your internal table?
How are you looping to build the internal table?
What is the structure of you custom table?
Is the structure of your internal table the same as the custom (Z) table?
If you leave the "LOOP AT" and single row INSERT, you should be chekcing SY-SUBRC after the INSERT to see if there was problem.
When are you looking at your custom table to see if the inerts are there? Do you code a COMMIT?
Cheers
John
Edited by: John Louk on Dec 10, 2009 7:28 PM
‎2009 Dec 11 6:22 AM
Hi Manish,
Updating a database table is not a big issue. As all the experts have given the solutions, you can try with them.
The simplest & best way to update z-table from an internal table is:
INSERT <DBTAB> FROM TABLE <ITAB>.
Plz close the thread if your problem is answered.
Rgds
Prateek
Edited by: Parteek Arora on Dec 11, 2009 7:22 AM
‎2009 Dec 11 6:57 AM
my Primary key is year and non primary key field is matnr werks menge.
i want to insert value having same year but different matnr werks and menge.
like 2009 xyz abc 10
2009 xyz1 abc1 10
2010 xyz abc 10
2010 xyz1 abc1 10
but it only inserting first row.... so what i can do in it.. i had tried all logic in it .. but this has not been resolved
so plz help me on this.
‎2009 Dec 11 7:06 AM
If you want to store many records of same year then there is no use of using YEAR as a primary key hence remove the primary key (year) otherwise make more primary keys to fulfill the requirement.
Rgds,
Surendr@.
‎2009 Dec 11 7:12 AM
Hi Manish,
Make year matnr werks and menge as primary fields. Dont keep year alone as primary key.
Regards,
Swarna Munukoti.
‎2009 Dec 11 7:37 AM
weird.. wrong thread
Edited by: Maen Anachronos on Dec 11, 2009 8:37 AM
‎2009 Dec 11 8:37 AM
So please delete all entries from the table and set all the four fields as primary key.
This would solve your problem.
Regards,
praveen.
‎2009 Dec 11 9:25 AM
Hi
Primary key will accept unique values only.
Eg: 2009 xyz abc 10
2009 xyz1 abc1 10
2010 xyz abc 10
2010 xyz1 abc1 10. your table will not accept these values.
it will accept only
2009 xyz abc 10
2010 xyz abc 10
Reagards,
Manju
‎2009 Dec 11 2:32 PM
Hi Manish,
here there are only 2 unique records,
2009 xyz abc 10
2010 xyz abc 10
only these records will be inserted. so out of the 4 records only the 1st and 3rd will be inserted.
and the below 2 records are duplicates, as you have year repeated in these records,
2009 xyz1 abc1 10
2010 xyz1 abc1 10
if you want all these records to be inserted, you better make the MATNR also as the primany key, which
will make all your above 4 records unique.
if you don't want to make MATNR as the primary key, then sort the internal table on year and delete all the duplicates comparing year
which keeps only the unique records and insert will work.
hope this helps.
‎2009 Dec 18 7:51 PM
The others have pretty much answered your question. To get what you are after you are going to have to change the primary key of your table. Just note primary keys can only be of type character or NUMC. So, if ME\NGE is a QUAN field then it cannot be part of your primary key.
You do not have to delete the current records from your table. You may ac tually have to delete the table and re-create the table inorder to change the primary key. This will cause the data to be deleted anyway.
Cheers
John
‎2009 Dec 10 1:05 PM
Make sure you are using the correct syntax ("insert <dbtab> from table <itab>") and that your DB table has a primary key that allows for storing these 150 different records.
Thomas
‎2009 Dec 10 1:07 PM
‎2009 Dec 10 1:08 PM
Hi
Check length is restricted by the length of field of database table in which insertion is done.
Regards,
Tanaya
Edited by: Tanaya A on Dec 10, 2009 6:46 PM
‎2009 Dec 11 5:07 AM
Hi,
You need to check three things.
1. Your internal table contains multiple records for sure.
2. If yes, then the primary keys of the database table accommodates all the records.
3. You are not using commit work in your code. You need to use this.
If all thee things are OK, then your code should work.
Also One of the big mistakes you are making is accessing database inside the loop.
Press F1 help for INSERT and check the syntax so that you can insert the records in one go.
Regards,
Raveesh
‎2009 Dec 11 5:47 AM
Close the thread if the issue is resolved.
Regards,
Raveesh
Edited by: raveesh saurabh on Dec 11, 2009 6:48 AM
‎2009 Dec 11 7:02 AM
example
DATA: VALUE TYPE I,
ITAB TYPE I OCCURS 100 WITH HEADER LINE.
ITAB = 5.
VALUE = 36.
INSERT ITAB INDEX 1.
INSERT VALUE INTO ITAB INDEX 2.
INSERT INITIAL LINE INTO ITAB INDEX 2.
‎2009 Dec 11 7:08 AM
i have to insert data into database.. taking value from the excel file to internal table and from internal table to database table
‎2009 Dec 11 7:05 AM
‎2009 Dec 11 7:18 AM