Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error Passing subrc to Fuinction

Former Member
0 Kudos

Hi All ,

I Am getting this error in an upgrade environment testing

Passing the formal parameter "SUBRC" to the field SY-SUBRC is not appropriate .

since SY-SUBRC is set by the statement,

This is while calling FM 'HR_READ_INFOTYPE'.

Thanks in advance for any input on the reason for error .

Vinay

2 REPLIES 2

Former Member
0 Kudos

Reason is clearly mentioned.

you can't change sy-subrc on your own.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Vinay

You try to fetch the value of EXPORTING parameter SUBRC into sy-subrc which is not correct because the sy-subrc will be set by the fm (either = 0 or in case of an exception = 1).

Not correct:


  data: gt_pa0001     type STANDARD TABLE OF pa0001.
  CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
*     TCLAS                 = 'A'
      pernr                 = '12345678'
      infty                 = '0001'
*     BEGDA                 = '18000101'
*     ENDDA                 = '99991231'
*     BYPASS_BUFFER         = ' '
*     LEGACY_MODE           = ' '
    IMPORTING
      SUBRC                 = sy-subrc
    tables
      infty_tab             = gt_pa0001
    EXCEPTIONS
      INFTY_NOT_FOUND       = 1
      OTHERS                = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Correct:


  data: gt_pa0001     type STANDARD TABLE OF pa0001,
        gd_rc         type syst-subrc.
  CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
*     TCLAS                 = 'A'
      pernr                 = '12345678'
      infty                 = '0001'
*     BEGDA                 = '18000101'
*     ENDDA                 = '99991231'
*     BYPASS_BUFFER         = ' '
*     LEGACY_MODE           = ' '
    IMPORTING
      SUBRC                 = gd_rc
    tables
      infty_tab             = gt_pa0001
    EXCEPTIONS
      INFTY_NOT_FOUND       = 1
      OTHERS                = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Regards

Uwe