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

error message from FM exception

Former Member
0 Likes
1,136

Hi Gurus,

Please help me.

I am having a function module BDC_OPEN_GROUP.

In this we are having 11 exceptions.

I have to catch these exceptions and display an error message if sy-subrc ne 0.

Promise to reward points

Mac

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
881

Hi ,

You can use Catch .. End Catch syntax .

Please look in that .

6 REPLIES 6
Read only

Former Member
0 Likes
881

Use the statement Raise

Just like this

if sy-subrc ne 0.

Raise <exception name>.

endif.

Thanks

Read only

Former Member
0 Likes
882

Hi ,

You can use Catch .. End Catch syntax .

Please look in that .

Read only

Former Member
0 Likes
881

Hi Mohan,

In the driver program u want to catch the exception right?

use like this.

if sy-subrc <> 0

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

endif.

If the given solution is not suitable means tell me your problem clearly

Thanks,

Suma.

Read only

Former Member
0 Likes
881

if sy-subrc ne 0.

message message-id wiht ' all the variables of the exception can be put here',

endif.

Read only

Former Member
0 Likes
881

Hi Mac,

In the calling program you code should look something like this:

CALL FUNCTION 'BDC_OPEN_GROUP'

  • EXPORTING " -->> If required

  • CLIENT = SY-MANDT

  • DEST = FILLER8

  • GROUP = FILLER12

  • HOLDDATE = FILLER8

  • KEEP = FILLER1

  • USER = FILLER12

  • RECORD = FILLER1

  • PROG = SY-CPROG

  • IMPORTING "-- >> If required

  • QID =

EXCEPTIONS

CLIENT_INVALID = 1

DESTINATION_INVALID = 2

GROUP_INVALID = 3

GROUP_IS_LOCKED = 4

HOLDDATE_INVALID = 5

INTERNAL_ERROR = 6

QUEUE_ERROR = 7

RUNNING = 8

SYSTEM_LOCK_ERROR = 9

USER_INVALID = 10

OTHERS = 11

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

This will definitely work.

Reward points if helpful.

Regards,

Renuka.

Read only

Former Member
0 Likes
881

Hi Mohan,

If you've noticed, each of the 11 exceptions have a number assosciated with it. The significance of this number is, when a particular exception occur, the SY-SUBRC would take the number corresponding to that particular exception. Thus, you just to check for these numbers and handle the exceptions accordingly.

Hope this helps.

Regards

Anil Madhavan