Deciphering ABAP OO exceptions

Deciphering ABAP OO exceptions

ABAP OO Exceptions are highly useful in detecting error conditions, and one of the more helpful methods is the inherited method GET_SOURCE_POSITION. The method returns the name of the main program, the include, and the line where the exception was generated. Unfortunately, it is difficult to reconcile these values with global classes built with the Class Builder, since the Class Builder hides the Program/Include implementation. The short program below resolves this issue.

I wrote the version on a 6.20 WebAS and it won't work on a version in which STRING is not defined. STRING is defined on the 4.6B kernel, though, so it will work down to 4.6B. Any lower release could use the coding below.
****
types:
  ty_char_string(72) type c,
  ty_char_string_tab type standard table of ty_char_string.
data:
  gv_string      type ty_char_string,
  gt_stringtab   type ty_char_string_tab.
read report program into gt_stringtab.
*/etc.
****
Real strings are cleaner, though.
report  z_print_include.

*/Parameters
parameters:
*/Name of include
  gp_incl         type progname obligatory,
*/Line number where exception raised
  gp_line         type i.

*/Variables
data:
  gt_strings      type stringtab.
*/Field symbols
field-symbols:
  <gv_string>     type string.


start-of-selection.

  read report gp_incl into gt_strings.

  loop at gt_strings assigning <gv_string>.
    if sy-tabix = gp_line.
      write: / <gv_string>  color col_negative.
    else.

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

write: / <gv_string>. endif. endloop. end-of-selection.

This was first published in October 2003

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.