Application Development and Automation 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: 
Read only

Exceptions in Function module

Former Member
0 Likes
855

There is a Function Module which does not have any Exception defined.Inside that Function Module there is a FORM which raises an exception. How can I catch that exception?

6 REPLIES 6
Read only

Former Member
0 Likes
802

you should define that as EXCEPTION in EXCEPTIONS TAB of that function module.else it cant catch them.

regards

srikanth

Read only

Former Member
0 Likes
802

hi Anuritha,

But Before that make sure that you define that exception in exception Tab...

Check this one

call function 'ITS_DOWNLOAD'
         EXPORTING
              bin_filesize            = bin_filesize
              filename                = tempfile
              filetype                = typ
              mode                    = mode
              wk1_t_format            = wk1_t_format
              wk1_n_format            = wk1_n_format
         IMPORTING
              filelength              = filelength
         TABLES
              data_tab                = data_tab
         EXCEPTIONS
              file_write_error        = 1
              gui_refuse_filetransfer = 2
              others                  = 3.

    if sy-subrc = 1.
      raise file_write_error.
    elseif sy-subrc = 2.
      raise unknown_error.
    elseif sy-subrc = 3.
      raise unknown_error.
    endif.
    exit.
  endif.

Read only

0 Likes
802

It is a standard function mdule and EXCEPTIONS parameter is not defined...

Read only

0 Likes
802

What function module are you using?

How can a subroutine within a function raise an exception if the exception is not registered with the function?

Is the subroutine raising an exception or does it issue an error/abend message?

-Kiran

Read only

Former Member
0 Likes
802

Hi,

If any error occurs and is stored in the system messages, then they wud be stored in sy-msgid, sy-msgno, and msgv1, msgv2, msgv3,msgv4.

Use the FM: MESSAGE_TEXT_BUILD to display the error message.

Regards

Subbu

Read only

Former Member
0 Likes
802

Hi Anuritha,

Use <b>TRY..CATCH..ENDTRY.</b> to catch EXCEPTIONS .But before this you should know the name of the EXCEPTION.

Try this PSEUDO Code.


TRY
CALL FUNCTION'TEST'.
CATCH <Exception Name> into variable.
write variable.
ENDTRY.

And also Check this <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/a9/b8eef8fe9411d4b2ee0050dadfb92b/content.htm">Help</a>

Regards,

Raghav