2013 Jan 05 12:17 PM
Hi experts,
I have one program( Test certificate printout program). After giving my input when i run the program . Some data is saved into one ztable. Its working fine till 2 months before. Now its not working, i mean when i run the program, the data is not getting saved into my table. The code which i have written for insert query is executing but it shows no effect. Please give me some suggestions.
My code:
insert zqm_tb_is1786n FROM table final2 ACCEPTING DUPLICATE KEYS.
Hints:
1) the internal table final2 having the values perfectly.
2) This code is working fine in quality server.
Thanks and Regards,
Linganathan.K
Replace
insert zqm_tb_is1786n FROM table final2 ACCEPTING DUPLICATE KEYS.with
insert zqm_tb_is1786n FROM final2. " single record, you already checked for duplicateAlso, you could try to remove the SELECT SINGLE from the LOOP/ENDLOOP, and replace it with a SELECT FOR ALL ENTRIES before the LOOP, checking final 2 is not empty, sort it, and use a READ TABLE BINATY SEARCH in the LOOP ENDLOOP to remove the records already in the database, then INSERT dbtab FROM TABLE final2 after the LOOP/ENDLOOP.
Regards,
Raymond
2013 Jan 05 12:31 PM
Hi
have you any authorization to debug(fire fighter) your code in production server????
Regards
Sabyasachi
2013 Jan 05 12:37 PM
I debugged in Production server. After that only i posted here my problem. In production server also. The insert query is executed . But not getting inserted.
Thanks and Regards,
Linganathan.K
2013 Jan 05 1:07 PM
Use commit work after insert statement.You need not to use COMMIT with INSERT statement, as it automatically COMMITS the work but once the processing of a PAI event is over, so best and safer option is to use COMMIT with INSERT/MODIFY/DELETE/UPDATE. to reflect the change into the database at once.
Regards
Sabyasachi
2013 Jan 05 12:39 PM
Hi,
Linga,
One Question,
Before this thread,U have many NOT ANSWERED THREAD OPEN,
If YOU got answer then u can close those FRIEND !!!!!! ..
Just Funny mood.
Thanks
Gourav.
2013 Jan 05 12:47 PM
HI kumar,
I will do it. Please can you help me for this thread.
Regards,
Linganathan.K
2013 Jan 05 1:05 PM
Hi,
Some thing is there,
the behaviour of ACCEPTING DUPLICATE KEYS,like
All rows inserted for this as far as possible,not insert all record,
then rejected remaining rows & sy-subrc is 4.
SY-DBCNT is set to the number of lines ,that are inserted already.
U can do like this,
At first declare one new internal table,
use select single based on PRIMARY OR SECONDARY key with check of SY-SUBRC.
Then u can insert Record.
U can also follow what SANDIP, SABYASACHI & others said.
Hope it is little helpful for u.
Thanks
Gourav.
2013 Jan 07 5:14 AM
Dear Kumar Gourav malik,
Thanks for your response,
Yes, In that Program they used SY-DBCNT . It is the primary key for that table. Every time inserting the values with this SY-DBCNT value in that table. And used sy-subrc condition also. I dont know what is the exact problem in that code. And i have pasted my code for your reference. Please help me for my issue.
My code
loop at final2.
select SINGLE ORDERNO TCYEAR from ZQM_TB_IS1786N INTO (ZQM_TB_IS1786N-ORDERNO,ZQM_TB_IS1786N-TCYEAR)
where cerno ne '' and orderno = final2-orderno and lotno = final2-lotno AND TCYEAR = FINAL2-TCYEAR.
if sy-subrc ne 0.
insert zqm_tb_is1786n FROM table final2 ACCEPTING DUPLICATE KEYS.
endif.
endloop.
Hints:
1) For the new input sy-subrc value is 4. My insert query is executed. But not saved into database tabele.
I confused whats the problem. Please do the helpful thing.
Thanks and Regards,
Linganathan.K
2013 Jan 07 5:26 AM
Hi,
Good Morning,
In this case u can try with
MODIFY statement instead of INSERT.
like
insert zqm_tb_is1786n FROM table final2 ACCEPTING DUPLICATE KEYS.
replace with
MODIFY table zqm_tb_is1786nitab FROM final2.
bcoz modify will works like modify for existing record & insert for new record.
Let see what happens!!!
Thanks
Gourav.
2013 Jan 07 6:16 AM
Hi linga,
try to avoid select statement between loop......endloop. its a performance issue....
Regards
Sabyasachi
2013 Jan 07 6:44 AM
Replace
insert zqm_tb_is1786n FROM table final2 ACCEPTING DUPLICATE KEYS.with
insert zqm_tb_is1786n FROM final2. " single record, you already checked for duplicateAlso, you could try to remove the SELECT SINGLE from the LOOP/ENDLOOP, and replace it with a SELECT FOR ALL ENTRIES before the LOOP, checking final 2 is not empty, sort it, and use a READ TABLE BINATY SEARCH in the LOOP ENDLOOP to remove the records already in the database, then INSERT dbtab FROM TABLE final2 after the LOOP/ENDLOOP.
Regards,
Raymond
2013 Jan 07 6:51 AM
Hi,
you mentiond that For the new input sy-subrc value is 4. My insert query is executed. But not saved into database tabele.
actually, the problem is, when insert statement executed then some how it gets same key field value...for that reason sy-subrc = 4. comment out 'Accepting duplicate keys' and execute. in this case, it gives a short dump. try to find out any existing key field values. better you can use modify statement insted of insert which kumar gaurav already mentiond.....
Regards
Sabyasachi
2013 Jan 05 12:57 PM
If you believe that everything is fine with your code and the values must be updated in DB, here are few things which you may like to check:
- try using explicit commit after INSERT
- check if the same record is locked by another update/insert etc or not in debug mode
- check system parameters for commit limit etc
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |