Problem solve Get help with specific problems with your technologies, process and projects.

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.

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.
      write: / <gv_string>.
    endif.
  endloop.

end-of-selection.
This was last published in October 2003

Dig Deeper on SAP ABAP

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close