cancel
Showing results for 
Search instead for 
Did you mean: 

EXCEPTIONS

Former Member
0 Kudos

what is usage of parametes EXCEPTION in function module

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

If a function module encounters an error it will raise an exception, and this will be part of the function module design (i.e. the exceptions will be different for different function modules).

In your calling program you map these exceptions to a number, and if the exception is raised the return code SY-SUBRC will hold this number.

Regards,

Nick

Former Member
0 Kudos

An exception is a name for an error that occurs within a function module. Exceptions are described in detail in the following section.

Syntax for the call function Statement

The following is the syntax for the call function statement.

call function 'F'

http://exporting p1 = v1 ...

http://importing p2 = v2 ...

http://changing p3 = v3 ...

http://tables p4 = it ...

[exceptions x1 = n others = n].

where:

F is the function module name.

p1 through p4 are parameter names defined in the function module interface.

v1 through v3 are variable or field string names defined within the calling program.

it is an internal table defined within the calling program.

n is any integer literal; n cannot be a variable.

x1 is an exception name raised within the function module.

The following points apply:

All additions are optional.

call function is a single statement. Do not place periods or commas after parameters or exception names.

The function module name must be coded in uppercase. If it is coded in lowercase, the function will not be found and a short dump will result.

Use the call function statement to transfer control to a function module and specify parameters. Figure 19.9 illustrates how parameters are passed to and received from the function module.

sample FM

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

  • EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab =

  • EXCEPTIONS

  • PROGRAM_ERROR = 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.

Example

1 report ztx1905.

2 parameters: op1 type i default 2, "operand 1

3 op2 type i default 3. "operand 2

4 data rslt type p decimals 2. "result

5

6 call function 'Z_TX_DIV'

7 exporting

8 p1 = op1

9 p2 = op2

10 importing

11 p3 = rslt.

12

13 write: / op1, '/', op2, '=', rslt.

Regards,