This Blog is about to explain that how to handle the “RFC error: An exception has occurred that was not caught” when using FM HR_INFOTYPE_OPERATION.
As per our requirement, user will enter the data in FIORI APPLICATION and when the user submits the data then our ODATA service will call. In ODATA Service method we have used FM HR_INFOTYPE_OPERATION for updating the data in Info type. But here we are getting an error sometimes and sometimes without getting an error it is working.
By overcoming to stop that error, we found by calling the subroutine “PERFORM do_nothing(sapfp50p).“ at LOAD-OF-PROGRAM Event in a Report then we can handle this error to disappear.
But this sub routine can be used only in a reports. So, first we wrote a “Z” Program for our functionality and called this Z Program in our ODATA Service Method at a required place.
Note – below is the sample code for your reference and you can change it as per our requirement.
REPORT zxx_xx NO STANDARD PAGE HEADING.
LOAD-OF-PROGRAM.
**__ To avoid the Dump
PERFORM do_nothing(sapfp50p).
START-OF-SELECTION.
PERFORM infotype_operations.
*&---------------------------------------------------------------------*
*& Form INFOTYPE_OPERATIONS
*&---------------------------------------------------------------------*
FORM infotype_operations.
Data: ls_p2003 TYPE p2003,
ls_return TYPE bapireturn1,
ls_key TYPE bapipakey.
ls_p2003-subty = '03'.
ls_p2003-vtart = '03'.
ls_p2003-otype = 'S'.
ls_p2003-infty = '2003'.
ls_p2003-seqnr = '000'.
ls_p2003-plans = '30000009'.
**__extra pay ID
ls_p2003-aufkz = '+'.
CALL FUNCTION 'HR_INITIALIZE_BUFFER'
EXPORTING
tclas = 'A'
pernr = ls_p2003-pernr.
**__ Lock the Employee
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = ls_p2003-pernr
IMPORTING
return = ls_return.
**__ Infotype Operation
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '2003'
number = ls_p2003-pernr
subtype = ls_p2003-subty
validityend = ls_p2003-begda
validitybegin = ls_p2003-endda
record = ls_p2003
operation = 'INS'
IMPORTING
return = ls_return
key = ls_key.
**__ Dequeue Employee
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = ls_p2003-pernr
IMPORTING
return = ls_return.
**__ Initialize Buffer
CALL FUNCTION 'HR_PSBUFFER_INITIALIZE'.
ENDFORM infotype_operations.
Above Z report is called using SUBMIT syntax with needed input parameters in our ODATA service method.
Note – here is the sample syntax for calling the report, you can add the needed parameters accordingly.
**__ Report to do operations on Info type 2003
SUBMIT zxx_xx WITH p_xx EQ lv_xx
WITH p_xx EQ lv_xx
EXPORTING LIST TO MEMORY
AND RETURN.
Hope this Blog might help you. Thank you…