Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 923

Re: easy way to get the exception text returned by FM (without case/IF)

$
0
0

I think you could use the FM which Gopal Gupta suggested, FUNCTION_IMPORT_INTERFACE.

 

 

eg, here is a prototype using a date conversion FM and catching the exception generically...

REPORT Ztest_exceptions.

DATA lv_str TYPE string.

data:

my_fm type RS38L_FNAM,

my_EXCEPTION_LIST type standard table of RSEXC,

my_EXCEPTION type RSEXC,

my_EXPORT_PARAMETER type standard table of  RSEXP,

my_IMPORT_PARAMETER type standard table of  RSIMP,

my_TABLES_PARAMETER type standard table of RSTBL,

my_in_date type TUMLS_DATE value '32.01.2016',

my_out_date type TUMLS_DATE,

my_subrc type sysubrc.

 

 

my_fm = '/SAPDMC/LSM_DATE_CONVERT'.

* call the FM...

CALL FUNCTION my_fm

  EXPORTING

    DATE_IN                   = my_in_date

    DATE_FORMAT_IN            = 'DDMY'

*   TO_OUTPUT_FORMAT          = 'X'

*   TO_INTERNAL_FORMAT        = ' '

IMPORTING

   DATE_OUT                  = my_out_date

EXCEPTIONS

   ILLEGAL_DATE              = 1

   ILLEGAL_DATE_FORMAT       = 2

   NO_USER_DATE_FORMAT       = 3

   OTHERS                    = 4

          .

* save the subrc

my_subrc = sy-subrc.

 

 

* get the exception list for the FM

CALL FUNCTION 'FUNCTION_IMPORT_INTERFACE'

  EXPORTING

    FUNCNAME                      = my_fm

*   INACTIVE_VERSION              = ' '

*   WITH_ENHANCEMENTS             = 'X'

*   IGNORE_SWITCHES               = ' '

* IMPORTING

*   GLOBAL_FLAG                   =

*   REMOTE_CALL                   =

*   UPDATE_TASK                   =

*   EXCEPTION_CLASSES             =

*   REMOTE_BASXML_SUPPORTED       =

  TABLES

    EXCEPTION_LIST                = my_EXCEPTION_LIST

    EXPORT_PARAMETER              = my_EXPORT_PARAMETER

    IMPORT_PARAMETER              = my_IMPORT_PARAMETER

*   CHANGING_PARAMETER            =

    TABLES_PARAMETER              = my_TABLES_PARAMETER

*   P_DOCU                        =

*   ENHA_EXP_PARAMETER            =

*   ENHA_IMP_PARAMETER            =

*   ENHA_CHA_PARAMETER            =

*   ENHA_TBL_PARAMETER            =

*   ENHA_DOCU                     =

EXCEPTIONS

   ERROR_MESSAGE                 = 1

   FUNCTION_NOT_FOUND            = 2

   INVALID_NAME                  = 3

   OTHERS                        = 4

          .

 

 

IF MY_SUBRC <> 0.

* Implement suitable error handling here

  read table my_EXCEPTION_LIST index my_subrc into my_exception.

  concatenate my_in_date 'raises exception' my_exception-exception

   into lv_str separated by space.

  MESSAGE lv_str TYPE 'S'.

ENDIF.


Viewing all articles
Browse latest Browse all 923

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>