cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple entries in SAP system

saprookieat
Explorer
0 Kudos

Hello,

I am new developing a Java SAP JCo application and currently trying to send data over a tRFC interface to the customer.

Basically what it does:

We have a JCoServer that receives iDocs and saves them to a database table e.g. SAP_INBOUND. After processing the data, we store it in another table e.g. SAP_OUTBOUND. The SAP JCoClient will then pick up records from this table and sent them to the SAP gateway. Both use the IDOC_INBOUND_ASYNCHRONOUS JCoFunction.

Client specifics

In the client I just get the JCoDestination, try to get the JCOFunction for the IDOC_INBOUND_ASYNCHRONOUS.

After that I get the JCoTable with

JCoTable idocControlTable = getIDocInboundAsynchronousFunction().getTableParameterList().getTable("IDOC_CONTROL_REC_40");

Then I append one row:

idocControlTable.appendRow();

and iterate all values of a Java Map to set the JCoTable values:

idocControlTable.setValue("KEY", "VALUE");

After that I do the same with the IDOC_DATA_REC_40 table with the only difference, that there are of course more entries to iterate.

The last step is:;

getIDocInboundAsynchronousFunction().execute(jcoDestination);

The problem

The customer claims that there are more iDocs arriving, than they expect. We previously used a .NET SAP interface and the customer received the same amount of iDocs we wrote in the IDOC_CONTROL_REC_40 table. The issue occurred since we used the Java SAP JCo solution.

The program logs (iteration of rows from the database as well as iteration of the IDOC_CONTROL_REC_40 itself) as well as the SAP traces show for instance 10 iDocs have been sent, but the customer has received 30.

Expectation

I know, that without the source code it is more difficult to analyze. The main goal was to ask, if there is another way to add rows to a table or trigger the transmission to the SAP Gateway in SAP JCo?

Maybe other people have experienced the same kind of thing and it is a configuration side effect?

AlexGourdet
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thank you for visiting SAP Community to get answers to your questions.

As you're looking to get most out of your community membership, please consider include a profile picture to increase user engagement & additional resources to your reference that can really benefit you:

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

All the best,

Alex

View Entire Topic
Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert

There can only be three reasons for this kind of problem:

  • either the JCo server program is saving the data incorrectly to the DB table (creating duplicate rows etc.)
  • or the JCo client program is reading them incorrectly (adding more rows to the JCoTable than it should)
  • or the JCo client program is running with multiple threads and two threads are sending the same IDoc twice with different TIDs, before the IDoc is finally deleted from the DB table.

But if this can be reproduced consistently, then it should not be difficult to find such a mistake by comparing the JCo trace from the server program with the JCo trace from the client program!

Especially if the client program is running with multiple threads, you need to have a very good "lock concept" for preventing that two threads are working on the same IDoc at the same time... And my recommendation would be that the server program saves the TID of the incoming IDoc into the DB table together with the IDoc data, and the client program then uses the same TID for its call to the target system. That should already prevent duplicates in case two threads are sending the same IDoc into the target system: the target system will ignore one of the two, because the TID is already known!

saprookieat
Explorer
0 Kudos

It seems like it was a caching issue of a variable that has not been reinitialized. Thank you very much!