cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Method in Odata _DPC_EXT Class

Former Member
0 Kudos

Hi All,

I am trying to add custom method in *DPC_EXT class while activating they are in RED.. I want to define methods in Class which I am planning to use in standard methods of the class.. Can I define custom methods in *DPC_EXT class and it good approach..

Thanks

Rajesh

Accepted Solutions (1)

Accepted Solutions (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi Rajesh,

yes you can add custom method in DPC_EXT class. I added one method and called it from _GET_ENTITYSET standard method. There were no error while activation or while runtime generation.

so answer to your question is, Yes you can define custom methods in *DPC_EXT class.

Regards,

Chandra

Former Member
0 Kudos

Thanks Chandrashekhar confirming..

We were looking for confirmation if its right approach.. thou re-generation of class dont overwrite the custom code..

Regards

Former Member
0 Kudos

Hi,

I am calling custom method from *GET_ENTITY method..and trying to raise exception using following code and want to send my custom message. It works if i am raising it in *GET_ENTITY.

RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception

     EXPORTING

       textid            = /iwbep/cx_mgw_busi_exception=>business_error

       message_container = gv_message_container.

If process fails in custom method and I want raise the exception.. any how its going uncaught..

Regards,

Rajesh

kammaje_cis
Active Contributor
0 Kudos

Rajesh,

May be in the signature of the custom method you need to declare that you are raising this exception? Try that.

Thanks

Krishna

Former Member
0 Kudos

Hi Krishna,

I have tried it.. but i have to exception handling for it in my standard methods GET_ENTITY or ENTITYSET.. I am looking to create custom method which will do exception handling and can raise standard exception - *business or *techincal. So if i can call custom method for any business logic can raise standard exception.. I am trying to condense and reuse the code..

Please advice any useful pointers..

Regards,

Rajesh

kammaje_cis
Active Contributor
0 Kudos

I am not able to understand the problem. May be you can provide a snippet of your custom method, signature and handling.

Former Member
0 Kudos

Here is the details what we are trying to achieve:

In standard *DPC_EXT class we have defined custom methods/attributes, so we can reuse the method in service. We also want to handle the exception here.. And raise exception as we do in GET_ENTITY or *ENTITYSET.

I have created a method and added standard exceptions to method:

/IWBEP/CX_MGW_BUSI_EXCEPTION

/IWBEP/CX_MGW_TECH_EXCEPTION

Also raising the exception in custom method as:

    gv_message_container->add_messages_from_bapi(

       it_bapi_messages         = lt_return

       iv_determine_leading_msg = /iwbep/if_message_container=>gcs_leading_msg_search_option-first

     ).

*    RAISE

     RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception

       EXPORTING

         textid            = /iwbep/cx_mgw_busi_exception=>business_error

         message_container = gv_message_container.

   ENDIF.


But "RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception" is giving error.. Our intention is to raise exception for custom class if some error occurred..


Following is the screen shot & signature of custom method


Regards

kammaje_cis
Active Contributor
0 Kudos

This has to do with the flag for class based exceptions.

See here.

Former Member
0 Kudos

Thanks Krishna,

I followed the link.. and set the class exception for method.. now its not giving compilation error.. But when i am raising exception it is giving following error:

I am passing error message.. which needs to be displayed..same thing work if I raise it within standard method *ENTITY/*ENTITYSET..

<?xml version="1.0" encoding="utf-8" ?>

- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<code>/IWFND/CM_BEC/026</code>

<message xml:lang="en">RFC Error: An exception occurred that was not caught.</message>

- <innererror>

<transactionid>5300EFFFEEF06392E100000014949326</transactionid>

<errordetails />

</innererror>

</error>

kammaje_cis
Active Contributor
0 Kudos

Can you also show the place where you are calling this method? Is there any Try catch surrounding it?

Former Member
0 Kudos

Thanks Krishna,

I am able to resolve the issue.. we don't need to put code in TRY...CATCH block.. as suggested need to select exception class button for method and add exceptions we need to take care..

Let me know if other possible approach to handle the exception..

Regards,

Rajesh

Answers (0)