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

Exception handling from standard function module

Former Member
0 Likes
869

hi guys,

how to handle the EXCEPTIONS from the standard bapi and write a custom message.

Regards,

selvamuthukumar.N

3 REPLIES 3
Read only

Former Member
0 Likes
550

Hi,

I think you require to give your message for the sy-subrc (Exception) value of FM.

After FM call

If sy-subrc <> 0.

case sy-subrc.

when '1'.

custom message.

when '2'.

custom message.

.

.

.

endcase.

else.

endif.

Hope this is ur requirement to be handled.

Regards,

Dwaraka.S

Read only

Former Member
0 Likes
550

hii..

you can try like this.

CALL FUNCTION 'BAPI_PO_GETDETAIL'
      EXPORTING
        PURCHASEORDER       = l_ebeln
        ITEMS                           = 'X'
        SERVICES                    = 'X'
      IMPORTING
        PO_HEADER                = wa_po_header
      TABLES
        PO_ITEMS                    = po_items
        PO_ITEM_SERVICES    = po_services
        RETURN                       = bapi_return_po.

  LOOP AT BAPI_RETURN_PO WHERE TYPE = 'E'.
    MESSAGE ID     BAPI_RETURN_PO-ID(2)
            TYPE   BAPI_RETURN_PO-TYPE
            NUMBER BAPI_RETURN_PO-NUMBER                    
            WITH   BAPI_RETURN_PO-MESSAGE_V1
                   BAPI_RETURN_PO-MESSAGE_V2
                   BAPI_RETURN_PO-MESSAGE_V3
                   BAPI_RETURN_PO-MESSAGE_V4.
    LEAVE.
  ENDLOOP.

like this, u can wite for SUCCESS also.

regards,

Padma.

Read only

Former Member
0 Likes
550

Most BAPIs don't have exceptions. Problems are dealt with by looking at the RETURN table. What BAPI are you looking at?

Rob