cancel
Showing results for 
Search instead for 
Did you mean: 

Avoid same TID used multiple times

Former Member
0 Kudos

Hello everybody,

I have a little problem with transaction id. What I do at the Moment:

I have an JAVA based RFC Client that connects to SAP ECC 6.0 via JCo3. If I have a message for upload to SAP...

1) ... I request a TID

2) ... I add the received TID to the iDoc and store that iDoc to a database

3) ... I send the iDoc (including the TID) to SAP, using the stored TID for the sending-process

I store all the iDoc information in the database to be able to re-send the iDoc - in case of a connection problem or simmilar. Now I had a problem where I managed sending some iDocs twice. Basically I thought ECC would not proceed an iDoc that has an already used TID but it did. I wonder if there is a way to avoid a TID being used multiple times with JCo. Or should it be handled from ECC?

Thanks for help

Sebastian

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Now I had a problem where I managed sending some iDocs twice. Basically I thought ECC would not proceed an iDoc that has an already used TID but it did. I wonder if there is a way to avoid a TID being used multiple times with JCo. Or should it be handled from ECC?

Please note that in general transactional RFC (tRFC) is used to prevent multiple execution in case of errors, not for successful calls (see for example [sending and executing tRFC LUWs|http://help.sap.com/saphelp_nw04/helpdata/en/25/bcfa40badbf46fe10000000a1550b0/content.htm]). In essence the TID reference can be deleted by the client and the server once the RFC call was executed successfully. So you cannot use it to prevent sending (and processing) and IDoc multiple times in general.

Now, if we talk about errors for tRFC calls, we do not talk about normal errors in the IDoc processing (i.e. a failed IDoc which might be in status 51 or 56 or something like that). For IDocs it's important to distinguish between creating them on the database and processing the IDocs (in most systems configured to be done in a separate LUW, even if immediate processing is chosen in the partner profile). Most likely you don't want to resend an IDoc once it exists in SAP (as any error handling from then on should be done in SAP).

So TID handling is not build for successful RFCs. This is why you see in some application code provisions to prevent duplicate postings (e.g. issue an error as soon as for example a duplicate reference number is encountered).

Cheers, harald

Former Member
0 Kudos

Hi Harald,

thank you for this information. In that case I have to figure out some prevent mechanism myself, like you explained.

Thanks again

Sebastian

Former Member
0 Kudos

Get all the iDoc from database and store it in a java collection set.

This will eliminate duplicates.

Anyways can you elaborate when you say "Somehow I manage to send few iDoc twice".

How are you achieving above statement in java.

Former Member
0 Kudos

Sorry, of course:

I keep the information (even of already send iDocs) for 4 Weeks in the database after that they are deleted since I asume that any error will be addressed till then. What I did was updating my datatable with several dummy-information and I found out that I had some older non-dummy entries in it. So those nun-dummy entries where send to ECC with their old TIDs and where booked...

Thx,

Sebastian

Former Member
0 Kudos

OK

Now, I feel that you will be able to solve the problem if your database does not allow duplicate entries in it for TID field.

If such is the case than you can set your TID field as a primary key in database.

So, it will give an exception if you will try to insert a duplicate key.

Catch this exception in java code. Inside catch delete existing entry in database and enter fresh entry.

try{

If(insert gives exception)

}catch(Primarykeyexception e)

{

// delete old enrty

// insert new entry

OR

// update old entry

}

Revert back if above scenario is not possible to be implemented in your case.

Edited by: Saurabh Agarwal on Jun 16, 2010 2:03 PM

Former Member
0 Kudos

Basically thats not exactly what I need.

- The TID is not in an extra field but inside of the idoc.

- In general it should be possible to have the same TID in more than 1 iDoc in the database - because if the first try was not successfull (due to connection problems) the second one should have the same TID or the third or...

So I need the possibility to have the same iDoc multiple times in the database but not having it in SAP for multiple times. Also I would still have the problem that the iDoc would have been send, because the old-entry was already deleted when I resend it accidentially.