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

Return Messages in FM

Former Member
0 Likes
1,093

Hi Experts,

How we will handle return messages in function module.

IF A = 0.

ERROR.

ELSE.

RESULT.

ENDIF.

I REQUIRED ERROR MESSAGE WHEN I WILL EXECUTE MY FM

Hi Experts,

How we will handle return messages in function module.

IF A = 0.

ERROR.

ELSE.

RESULT.

ENDIF.

I REQUIRED ERROR MESSAGE WHEN I WILL EXECUTE MY FM

4 REPLIES 4
Read only

Former Member
0 Likes
674

after u call the FM , u will get the SY-MSGID , SY-MSGN0 .... with that u can build the error message , chk this

DATA :   L_ERR_MSG(500).

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.

Read only

Former Member
0 Likes
674

raise an exception.

Set up exceptions in your FM header to deal with different exceptions.

Then when you encounter the error simply write, Raise (Exception name).

Then you can hande that from the return of the FM.

Read only

Former Member
0 Likes
674

Hi,

Use EXCEPTIONS.

Also u can write the error message using Message Statement.

U can do like this :

Define an Exception say : 'DATA_INVALID'.

Now, in the code write :

IF A = 0.

MESSAGE E000(0K) WITH 'Data Invalid' RAISING 'DATA_INVALID'.

ELSE.

RESULT.

ENDIF.

Regards,

Himanshu

Read only

Former Member
0 Likes
674

make use of keyword and maintain Execptions in ur FM

RAISE

Regards

Prabhu