Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member196098
Participant

This is just a step to think over how do we allow the programs to be debuggable. Its one of the ideas that i come to think over. We keep writing lots of code but at the end we need to debug them especially in the Production system. So debugging becomes an important issue!!.

DEBUGGING CONFIGURATION VIA USER PARAMETERS

Step 1- We will enable the program to be debugged thru the user parameters!!

This way we can add or remove the parameters and enable the code to be debugged in any system.

Lets say: we create parameters like: debug level, debug tcode and debug program name.

Some code snippet is:

CONSTANTS: c_param_debug_level TYPE memoryid VALUE 'DEBUG_LEVEL',     

c_param_debug_tcode TYPE memoryid VALUE 'DEBUG_TCODE',   

c_param_debug_prog  TYPE memoryid VALUE 'DEBUG_PROG'.

We will put a debug point in the program smth like this _debug_level 1. For more please see the implementation code i will attach!!

Step 2- We need to create a Function or a object that is going to be reading the parameters and checking the level of debugging and loading the details for debugging. Object that will be loading all the required data for debugging!!.

This should be called first then everything in the code! For example at the Standard report at initialization section.

As the code the name of this class is zcl_debug.

Step 3- We need to write a Macro in the code we want it to be debugged, so that we can stop the code at that execution point.

Why macro? Because via macro we can put Break-point and as macros can not be debugged thats the best candidate for this.

Code snippet: ***Writing the MAcros!!!

DEFINE _debug_level.

  if zcl_Debug=>get_instance( )->is_debug_level_correct( iv_debug_level =  CONV string( '&1' ) )  = abap_true.   "#EC USER_OK      BREAK-POINT.                                        "#EC NOBREAK

  endif.

END-OF-DEFINITION.

Step 4- we could be able to configure the level? We can use config table but that will complicate the debugging and most often its forgotten. So why not we use a pop up screen where we can change the debugging level dynamically!!

DEFINE _debug_configure.

  zcl_Debug=>get_instance( )->configure_debug_level( ).

END-OF-DEFINITION.

Step 5- Final Look Report zxxx.

DEFINE _debug_configure.

zcl_Debug=>get_instance( )->configure_debug_level( ).

END-OF-DEFINITION. …

İnitialization.

_debug_configure.

Start-of-selection.

_debug_level 3. …

By this way we can enable the code to be debuggable which will make our life much easier!!

Any suggestions, please feel free to suggest me

23 Comments