Application Development and Automation 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: 
Read only

Insert Statement is not working in production server

former_member242166
Participant
0 Likes
1,743

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 duplicate

Also, 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

12 REPLIES 12
Read only

Former Member
0 Likes
1,558

Hi

    have you any authorization to debug(fire fighter) your code in production server????

Regards

Sabyasachi

Read only

0 Likes
1,558

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

Read only

0 Likes
1,558

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

Read only

gouravkumar64
Active Contributor
0 Likes
1,558

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.


Read only

0 Likes
1,558

HI kumar,

I will do it. Please can you help me for this thread.

Regards,

Linganathan.K

Read only

0 Likes
1,558

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.


Read only

0 Likes
1,558

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



Read only

0 Likes
1,558

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.



Read only

0 Likes
1,558

Hi linga,

        try to avoid select statement between loop......endloop. its a performance issue....

Regards

Sabyasachi

Read only

0 Likes
1,558

Replace

insert zqm_tb_is1786n FROM table final2 ACCEPTING DUPLICATE KEYS.

with

insert zqm_tb_is1786n FROM final2. " single record, you already checked for duplicate

Also, 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

Read only

0 Likes
1,558

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

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,558

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