Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

macro

Former Member
0 Kudos

can we debug a macro? if how and why?

7 REPLIES 7

Former Member
0 Kudos

I don't think macros can be debugged.

Regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

HI

GOOD

Since debugging a MACRO is not really possible, prevent the use of them (I've never used them, but seen them in action). If the subroutine is used only local (called internal) use a FORM. If the subroutine is called external (used by more than one program) use a FUNCTION.

1-

A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice.

2-Macros can only be used in the program the are defined in and only after the definition.

3-Macros can take max 9 parameters.

4-Macros are expanded at compilation / generation.

THANKS

MRUTYUN

0 Kudos

u can see the macro defn but debugging not achievable!!

former_member186741
Active Contributor
0 Kudos

Never say never. Macros can be very useful, especially if they represent say only a few lines of code which don't warrant a subroutine.

You can't debug but if you are writing your own you can of course debug the code which you are going to turn into a macro. You can't use the &1s etc but it might help.

Former Member
0 Kudos

No. We cannot debugg a MACRO.

If u feel the need for it, then change from macro to a subroutine. this can be acheived quite easily by sending the parameters to the subroutine in the same way as u r sending to the macro.

But remember one thing: Macro's are comparitively faster

Reward points if helpful

Regards

raymond_giuseppi
Active Contributor
0 Kudos

You cannot debug a macro, because there are not actual lines in the source which execute the macro. Macro definition is copied with &parameter converted when pre-compilation of Abap is carried out.

<i>DEFINE

DEFINE Syntax Diagram

Effect

Defines a section of source code (macro) that you can address using the name macro. Source code saved as a DEFINE macro may only consist of complete ABAP statements

All macro use is expanded fully in translation. Macros are a text substitute for the translation phase - not a modularization technique for runtime use.

You conclude a macro with the END-OF-DEFINITION statement.

When you define a macro, you can use placeholders (&n, where n = 1, 2, ..., 9). When the macro is expanded, &n is replaced with the n-th current parameter.

Example

Suppose you define a macro "INCREMENT", which you then use in your program.

DEFINE INCREMENT. 

ADD 1 TO &1.
END-OF-DEFINITION.

DATA: NUMBER TYPE I VALUE 1.
...
INCREMENT NUMBER.

<b>Notes : As a rule, you should use subroutines (FORM, FUNCTION) instead of macros. This is because subroutines - unlike macros - are supported by all of the ABAP Workbench tools (debugging, runtime analysis, runtime error handling, ...).</b>

You cannot define a macro within a macro using the

DEFINE statement.

You cannot use an ABAP keyword as a macro name.

The validity of a macro definition is determined by its position in the source code. You can use a given macro in any line of code following its definition. There is no distinction between global and local macros. For example, the fact that a macro is defined within a subroutine has no effect on its validity.

If you redefine a macro, that is, assign a new meaning to an existing name, the new meaning takes effect from the position in the program where the macro was redefined.</i>

Notice on debug in bold upper lines.

Regards.

Former Member
0 Kudos

thanks.