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: 

Trap FM Exception Error MEssage

Former Member
0 Kudos

Can anyone tell me how I can trap an error message

which is triggered in a fm I am calling.

e.g.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = spoolno

NO_DIALOG = ' '

  • DST_DEVICE =

  • PDF_DESTINATION =

IMPORTING

PDF_BYTECOUNT = numbytes

PDF_SPOOLID = pdfspoolid

  • LIST_PAGECOUNT =

BTC_JOBNAME = jobname

BTC_JOBCOUNT = jobcount

TABLES

PDF = pdf

EXCEPTIONS

ERR_NO_ABAP_SPOOLJOB = 1

ERR_NO_SPOOLJOB = 2

ERR_NO_PERMISSION = 3

ERR_CONV_NOT_POSSIBLE = 4

ERR_BAD_DESTDEVICE = 5

USER_CANCELLED = 6

ERR_SPOOLERROR = 7

ERR_TEMSEERROR = 8

ERR_BTCJOB_OPEN_FAILED = 9

ERR_BTCJOB_SUBMIT_FAILED = 10

ERR_BTCJOB_CLOSE_FAILED = 11.

case sy-subrc.

when 0.

WRITE: / 'Error 0'(006) COLOR COL_POSITIVE.

when 1.

WRITE: / 'Error 1'(002) COLOR COL_negative.

when 2.

WRITE: / 'Error 2'(003) COLOR COL_negative.

The error is occuring in the actual FM itself. My program

does not reach the case sy-subrc statement above. Can

this be forced in anyway???

Cheers

1 REPLY 1

Former Member
0 Kudos
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
  EXPORTING
    src_spoolid                    =
*   NO_DIALOG                      =
*   DST_DEVICE                     =
*   PDF_DESTINATION                =
* IMPORTING
*   PDF_BYTECOUNT                  =
*   PDF_SPOOLID                    =
*   LIST_PAGECOUNT                 =
*   BTC_JOBNAME                    =
*   BTC_JOBCOUNT                   =
* TABLES
*   PDF                            =
* EXCEPTIONS
*   ERR_NO_ABAP_SPOOLJOB           = 1
*   ERR_NO_SPOOLJOB                = 2
*   ERR_NO_PERMISSION              = 3
*   ERR_CONV_NOT_POSSIBLE          = 4
*   ERR_BAD_DESTDEVICE             = 5
*   USER_CANCELLED                 = 6
*   ERR_SPOOLERROR                 = 7
*   ERR_TEMSEERROR                 = 8
*   ERR_BTCJOB_OPEN_FAILED         = 9
*   ERR_BTCJOB_SUBMIT_FAILED       = 10
*   ERR_BTCJOB_CLOSE_FAILED        = 11
*   OTHERS                         = 12
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

<b>CALL FUNCTION 'TB_MESSAGE_BUILD_TEXT'
       EXPORTING
            LANGU = SY-LANGU
            MSGID = P_SY_MSGID
            MSGNO = P_SY_MSGNO
            MSGV1 = P_SY_MSGV1
            MSGV2 = P_SY_MSGV2
            MSGV3 = P_SY_MSGV3
            MSGV4 = P_SY_MSGV4
       IMPORTING
            TEXT  = P_L_ERR_MSG.</b>

ENDIF.