Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Thursday, February 21, 2008

Break Points in ABAP

You can now create (de)activable breakpoints in your programs. You can release these breakpoints in production and a customer will have the opportunity to activate and debug your code more easily.

The following is an activable break-point : BREAK-POINT ID dany.

The checkpoint group is defined by double clicking on the checkpoint group in the editor OR directly via transaction SAAB.

Below is the SAAB screen. In the breakpoints part of the screen, you can set it to "inactive" or "break". All breakpoint groups will be shipped inactive by default.

Assert :

An assertion is a condition which must be true during program execution. By using asserts in your program, you can find cause of error in shorter time. The reaction when violating an assertion depend on a customizing and could be :

  1. Start the debugger from this assert

  2. Do nothing, ignore the assert

  3. Log the assertion in a log

  4. Terminate the program with runtime error ASSERTION_FAILED

The assertions are defined in SAAB (exactly like the breakpoints, see screen above).Here is an example of a use for an assertion :

METHOD sort_by_name.
     
DATA: l_f1 TYPE i VALUE 2,
      l_f2 TYPE c LENGTH 10 VALUE 'test',
      l_t1 TYPE TABLE OF sflight.
     
   the_sorting_algorithm.
     
   ASSERT ID        dany
          SUBKEY    'danysub1'
          FIELDS    l_f1 l_f2 l_t1
          CONDITION itab->is_sorted_by_name( ) <> ' '.                
ENDMETHOD.

This will ensure that the table is sorted. Below is the result of the log for this assert

You can now create (de)activable breakpoints in your programs. You can release these breakpoints in production and a customer will have the opportunity to activate and debug your code more easily.

The following is an activable break-point : BREAK-POINT ID dany.

The checkpoint group is defined by double clicking on the checkpoint group in the editor OR directly via transaction SAAB.

Below is the SAAB screen. In the breakpoints part of the screen, you can set it to "inactive" or "break". All breakpoint groups will be shipped inactive by default.

Assert :

An assertion is a condition which must be true during program execution. By using asserts in your program, you can find cause of error in shorter time. The reaction when violating an assertion depend on a customizing and could be :

  1. Start the debugger from this assert

  2. Do nothing, ignore the assert

  3. Log the assertion in a log

  4. Terminate the program with runtime error ASSERTION_FAILED

The assertions are defined in SAAB (exactly like the breakpoints, see screen above).Here is an example of a use for an assertion :

METHOD sort_by_name.
     
DATA: l_f1 TYPE i VALUE 2,
      l_f2 TYPE c LENGTH 10 VALUE 'test',
      l_t1 TYPE TABLE OF sflight.
     
   the_sorting_algorithm.
     
   ASSERT ID        dany
          SUBKEY    'danysub1'
          FIELDS    l_f1 l_f2 l_t1
          CONDITION itab->is_sorted_by_name( ) <> ' '.                
ENDMETHOD.

This will ensure that the table is sorted. Below is the result of the log for this assert

No comments:

Post a Comment

Content

Recent Topics