Application Development 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: 

INSERT statement failing

Former Member
0 Kudos

Hello Experts,

I am having trouble with insert statement in an RFC function module. I created an RFC enable function module in SAP which called by TIBCO. TIBCO calls this FM and passes data in tables format. Lets say it passed 4000 records to RFC function module. The Function module processes data and finally all the data needs to be inserted in Z table.

In debug mode the insert statement works fine everytime with expected results. But in background it behaves differently each time. In background each time different number of records are loaded. I am checking for duplicates before inserting also.

Here are the methods I tried which did not work.

INSERT z_table from table i_ztable.

Then I tried inserting one record at a time from work area.

Used MODIFY statement instead of INSERT.

After all the statements I used COMMIT WORK.

Even tried Putting a WAIT statement.

I ran the SQL trace whent the insertion happens in background, and the number of insert statements in trace differ which I understand is the cause of wrong number of records inserted. But I need to find a solution which makes the insertion stable and consistent all times.

Also the sy-dbcnt value all times comes out correctly, both in foreground as well as background.

I have had this problem for 4 days now and could not find any good solution. Please help me out. I really appreciate it.

Message was edited by:

pratyusha vemuluri

3 REPLIES 3

Former Member
0 Kudos

I had similar problem earlier and we debugged RFC from TIBCO and found that internal tables are not getting refreshed correctly. Before using any internal table, you need to refresh them. It is strange, i used to feel that with new instance, system will clear all earlier runtime values. But that was not the case with TIBCO RFC and when i put REFRESH statement before using each internal table and variable, it started working fine.

0 Kudos

I already do that. The internal table is cleared and refreshed each time in the beginining of function module itself. But in debug mode, how does it work fine. This behavior happens when I test the function module internally in SAP.

Thanks

Pratyusha

Former Member
0 Kudos

I created another function module just for insertion of data of "Update" type and called this FM in the first RFC in update task. It seems to work fine.