2014 Apr 11 5:40 AM
Hi Experts,
I have created a RFC BAPI to delete an entry from Z table. Whenever I run the BAPI from any workstation (PC), BAPI is executes correctly and an entry is deleted from the database table.
But whenever call the bapi from a remote system, say mobile, then delete query is executed successfully (sy-subrc = 0 ) but same is not reflected in the database table.
For a workaround,
I tried explicit commit using COMMIT WORK immediately after delete query in the BAPI itself and
I also tried calling bapi using "BAPI_TRANSACTION_COMMIT" from the remote device for explicit commit.
Either way delete query was not reflected in the database. Please give some suggestion as I am not able to figure out the reason for this.
Regards,
Saurabh
2014 Apr 11 6:10 AM
Hi Saurabh ,
Normally commit or BAPI_TRANSACTION_COMMIT works fine in RFC call .Try giving the statement SET UPDATE TASK LOCAL after the commit .
Regards ,
Juneed Manha
2014 Apr 11 6:17 AM
Hi,
please try to call BAPI_TRANSACTION_COMMIT in your BAPI (not as an own call from other system).
Regards,
Klaus
2014 Apr 11 7:05 AM
2014 Apr 11 10:15 AM
Juneed, Klaus and RSK.
Thanks for quick response.
I will try BAPI_TRANSACTION_COMMIT in the BAPI and will revert back.
2014 Apr 11 7:27 AM
Hi,
before return from the rfc call system performs implicit commit work in the destination system so the explicit commit should really not help. I suppose you did not do any rollback in your bapi...
Could you share related pieces of your code? calling rfc and deleting db lines
Br
Bohuslav
2014 Apr 11 8:27 AM
Bohuslav,
please find the code below:
FUNCTION ZEPAY_APP_DELETE_SESSION.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(MY_USER) TYPE UNAME
*" VALUE(MY_GRP) TYPE ZAPGP
*" VALUE(I_BANK) TYPE HBKID
*" TABLES
*" RETMSG STRUCTURE BAPI_MATRETURN2
*"----------------------------------------------------------------------
DATA : wa_retmsg TYPE BAPI_MATRETURN2.
*"----------------------------------------------------------------------
DELETE FROM zepay_session
WHERE sname = my_user
AND app_grp = my_grp
AND hbkid = i_bank.
*"----------------------------------------------------------------------
IF SY-SUBRC EQ 0.
wa_retmsg-type = 'S'.
wa_retmsg-MESSAGE = 'Session is successfully logged off' .
ELSEIF my_grp eq ' '.
wa_retmsg-type = 'E'.
wa_retmsg-MESSAGE = 'User Group not found. Please verify the Session log' .
ELSEIF my_user eq ' '.
wa_retmsg-type = 'E'.
wa_retmsg-MESSAGE = 'User not found. Please verify the Session log' .
ENDIF.
APPEND wa_retmsg to retmsg.
*"----------------------------------------------------------------------
CLEAR : i_bank,my_user,my_grp.
ENDFUNCTION.
2014 Apr 11 8:36 AM
that looks correct I suppose you get back successful message.
did you check the rfc connection setting (SM59) - especially user authorization and login client, aren't you deleting in another client then you expect? to be sure where you are deleting you could append sy-mandt to the return message temporaily. is it trusted connection or with filled client/username/passwd?
2014 Apr 11 9:32 AM
Why don't you check for empty fields BEFORE you execute your delete statement ?
For me that would make more sense.
In general when you do database updates you would have to do checks on fields before you do the actual update.
Maybe it has to do with how the data is coming in (e,g, leading zeroes or not).
You can add some logging to your code and write the fields that are coming in to the log, so you know if there is something incorrect with the data coming into the Bapi.
I can imagine that because of that no entry is found in the table and therefore your delete will not happen. You are also not checking sy-subrc = 4. This would be the case if no entry can be found with that key to delete.
I also do not see a commit or rollback in your code. You need to commit the delete transaction.
You can also return/use sy-dbcnt to see how many rows (if any) have been deleted.
2014 Apr 11 7:45 AM
Write the code below BAPI_TRANSACTION_COMMIT
WAIT UP TO 3 SECONDS.
2014 Apr 11 7:26 PM
Call the following FM in sequence-
i) CALL FUNCTION 'ZEPAY_APP_DELETE_SESSION' DESTINATION 'XYZ'.
ii) If successful-> CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
DESTINATION = 'XYZ'.
or put the 'BAPI_TRANSACTION_COMMIT' inside the RFC.
Ideally, as Bohuslav suggested synchronous RFC should do implicit commit for every call.
RFC Restrictions (SAP Library - Components of SAP Communication Technology)