Skip to Content

ABAP: Smartform exception handling

Dear Abap Experts ,

How can I handle exception while calling the smartform and when incorrect parameters are sent to the smartfom.

I have used following code but problem not resolved.

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Thanks,

Aneel

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 07, 2014 at 05:24 AM

    Hi Aneel,

    What do you want when a smartform exception happens, I mean apart from the fact that what you have mentioned. What you have written is correct to handle exceptions.

    Simply put you can insert a message i.e.,

    IF SY-SUBRC <> 0.

    MESSAGE 'Incorrect Parameters' TYPE S DISPLAY LIKE 'E'.

    EXIT.

    ENDIF.

    Cheers,

    Varun

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 07, 2014 at 05:20 AM

    Hi Aneel.

    After each generated FM call, make sure you get the errors as well whenever there is any exception. Call FM SSF_READ_ERRORS to retrieve the error message. Pass these message back to the NAST protocol if the SmartForm is being called from the Output control.

    Check the below code.Hope this will help you.

    CALL FUNCTION lf_fm_name

    EXPORTING

    archive_index = toa_dara

    archive_parameters = arc_params

    control_parameters = ls_control_param

    mail_recipient = ls_recipient

    mail_sender = ls_sender

    output_options = ls_composer_param

    user_settings = SPACE

    IMPORTING job_output_info = ls_job_info

    EXCEPTIONS formatting_error = 1

    internal_error = 2

    send_error = 3

    user_canceled = 4

    OTHERS = 5.

    IF sy-subrc <> 0.

    *

    DATA: LT_ERRORTAB TYPE TSFERROR.

    FIELD-SYMBOLS: <FS_ERRORTAB> TYPE LINE OF TSFERROR.

    *

    * get smart form protocoll

    CALL FUNCTION 'SSF_READ_ERRORS'

    IMPORTING

    ERRORTAB = LT_ERRORTAB.

    *

    * add smartform protocoll to nast protocoll

    LOOP AT LT_ERRORTAB ASSIGNING <FS_ERRORTAB>.

    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'

    EXPORTING

    MSG_ARBGB = <FS_ERRORTAB>-MSGID

    MSG_NR = <FS_ERRORTAB>-MSGNO

    MSG_TY = <FS_ERRORTAB>-MSGTY

    MSG_V1 = <FS_ERRORTAB>-MSGV1

    MSG_V2 = <FS_ERRORTAB>-MSGV2

    MSG_V3 = <FS_ERRORTAB>-MSGV3

    MSG_V4 = <FS_ERRORTAB>-MSGV4

    EXCEPTIONS

    OTHERS = 1.

    ENDLOOP.

    ELSE.

    *

    *

    ENDIF.

    Thanks

    KH

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.