Skip to Content

raising an exception in a class and losing contents of a table

Hi,

I have instantiated the BADI CRM_ICSS_PRODUCT_REG with the method check consistency. It has import parameters, one changing parameter, and exceptions.

The changing parameter is the standard BAPI return table. The invoking code will only check the return table if the sy-subrc isn't 0.

My problem is that I can fill out the BAPI return table and its contents get returned just fine, unless I raise an exception. If I raise an exception, my table has values in the method but in the invoking method it is empty. I can comment out the raise and see the contents of the return table or I can do the raise and not get the contents. To get the error recognized, I need both.

The code is

append lh_return to ct_return.

raise not_consistent.

endif.

endmethod.

With a breakpoint at the append, ct_return has one line in it after the append. If I comment out the raise, the invoking method will have that line in its corresponding table. However, if I execute the raise, the table will be empty on return.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2004 at 04:51 AM

    From the post, I assume that, you want to return the table with the values (why it failed) and at that point, stop processing further in that method.

    For this , you should , perhaps use <b>EXIT</b>, instead of raising exceptions.

    When you raise an exception, parameters which are passed as EXPORTING, CHANGING, RETURNING are only filled if they are <b>passed with reference</b>. I assume, you are not <b>passing values by reference</b> but <b>by value</b>.

    Therefore, the value in the internal table is not captured.

    Hope this helps.

    Regards,

    Subramanian V.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Deborah Castle

      Hi Deborah,

      Well now you do know.

      You can do this :

      a) Fill the table and use the <b>EXIT</b> statement as I had said in my earlier post.

      b) If , you cannot do a, use

      EXPORT BAPIRETURNTABLE TO MEMORY ID 'TABLE'.
      

      and then do an IMPORT to recover that table.

      For more information regarding usage of EXPORT/IMPORT , refer

      http://help.sap.com/saphelp_46c/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm

      BC- ABAP Programming -> ABAP Programming Language -> Saving Data Externally -> Saving Data Objects as Clusters

      -> Data Clusters in ABAP Memory

      However, if I were you, I would use <b>option 1</b> and try to <b>avoid option 2</b> as far as possible.

      Regards,

      Subramanian V.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.