Skip to Content
Technical Articles
Author's profile photo Niveditha Reddy AMMIREDDY

How to handle the “RFC error: An exception has occurred that was not caught” when using HR_INFOTYPE_OPERATION

Introduction:

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…

 

 

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Matthew Billingham
      Matthew Billingham

      First point. It would be far more interesting to have some analysis of why calling an empty form in SAPFP05P suppresses this error. It looks from the comments on that form that it's something to do with COMMON AREAs defined in the module.

      Second - is right to suppress the error. Isn't this effectively allowing an error to go unhandled?

      Third if you're writing code to be called by other code, don't use a program. Create a class with a method with the functionality you need. Performs are obsolete and should NOT be used in new developments.

      CLASS z_my_class DEFINITION
        PUBLIC
        FINAL
        CREATE PUBLIC.
      
      PUBLIC SECTION.
        METHODS:
          constructor,
          infotype_operations
            IMPORTING
              ...
            RETURNING
              VALUE(r_Result) TYPE ... " Some structure/table with the results
      
      ENDCLASS.
      
      CLASS u_my_class IMPLEMENTATION.
        METHOD constructor.
          PERFORM do_nothing(sapfp50p).
        ENDMETHOD.
      
      METHOD infotype_operations.
      ...
        CALL FUNCTION 'HR_INITIALIZE_BUFFER'
      ...
      **__ Lock the  Employee
        CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
      ...
      **__ Infotype Operation
        CALL FUNCTION 'HR_INFOTYPE_OPERATION'
      ...
      
      **__ Dequeue Employee
        CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
      ...
      
      **__ Initialize Buffer
        CALL FUNCTION 'HR_PSBUFFER_INITIALIZE'.
      
      ENDMETHOD.

      Which you can call with:

      DATA(my_report_data) = NEW z_my_class( )->infotype_operations( EXPORTING ... ).
      Author's profile photo Niveditha Reddy AMMIREDDY
      Niveditha Reddy AMMIREDDY
      Blog Post Author

      Hi Matthew,

      Thank's for your suggestion. Before going with this approach, we tried the same approach for calling the subroutine in the Method. But we can't call this subroutine (perform do_nothing) in the Method. We got an error and then we followed the next possible way.

      Yes, I agree with you by following the OOABAP concepts is best..., but it doesn't allow in our scenario.

      THANK YOU!

      Author's profile photo Satheesh Sambandamurthy
      Satheesh Sambandamurthy

      Hi Niveditha,

      Appreciate the efforts spent on resolving the issue. The FM in problem here is an unreleased one which makes it using risky in long term. Have you considered the options mentioned in the attached KBA.