Application Development 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: 

Old and new exceptions cannot be used at the same time

Former Member

Hi,

I am getting this error, "Old and new exceptions cannot be used at the same time" for the following code, does anyone have any info on this

method add_item_to_cart.

*check if item exists
  try.
      zcl_ec_cart=>read_cart_item( i_cust_id = i_cartitem_att-cust_id
                                   i_produ = i_cartitem_att-produ ).
      RAISE EXCEPTION TYPE zcx_ec_cart
            EXPORTING
               textid = zcx_ec_cart=>already_exists
               produ = i_cartitem_att-PRODU.
      EXIT.
    catch zcx_ec_cart .
  endtry.

  data l_cart type ref to zcl_ec_cart.
  l_cart = zcl_ec_cart=>create_cart_item( i_cust_id = i_cartitem_att-cust_id
                                          i_produ = i_cartitem_att-produ  ).
  move-corresponding i_cartitem_att to l_cart->cart_att.

  l_cart->update_cart_item( ).
  commit work.
endmethod.

the error points to the RAISE EXCEPTION statement

Edited by: Bijo Samuel on May 6, 2010 5:38 PM

1 ACCEPTED SOLUTION

gerd_rother
Active Participant

Hi,

In the method definition (tab exceptions) check whether the "class exceptions" flag is set.

Regards,

Gerd Rother

3 REPLIES 3

gerd_rother
Active Participant

Hi,

In the method definition (tab exceptions) check whether the "class exceptions" flag is set.

Regards,

Gerd Rother

SuhaSaha
Advisor
Advisor

Does your method have any non-class based exceptions defined ? SAP says:

The statement RAISE EXCEPTION must not be used in a method or a function module in whose interface non class-based exceptions are declared.

Source: [http://help.sap.com/abapdocu_70/en/ABAPRAISE_EXCEPTION_CLASS.htm]

Former Member
0 Kudos

thanks gerd, problem solved. thanks

@suhas, no, see the code above. thanks