Application Development and Automation 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: 
Read only

Macro Definition.

Former Member
0 Likes
676

What does the Ampersand-2 and 1(&2 and &1 ) contain in this code?

DEFINE DBG.

IF DEBUGFLG = 'Y' OR DEBUGFLG = 'y'.

IF &2 NE SPACE.

WRITE: / &1, &2.

ELSE.

WRITE: / &1.

ENDIF.

ENDIF.

END-OF-DEFINITION

5 REPLIES 5
Read only

Former Member
0 Likes
643

It's the placeholder for the parameters you pass to the macro.

Example.

DBG 'value 1' ' value 2'.

&1 will get the value ' value 1' and &2 gets 'value 2'

Read only

0 Likes
643

Hi,

I cant clearly get you,

could you elaborate in detail....

Read only

0 Likes
643

Its the placeholders for your parameter you pass while calling the MACRO.

For example if you call a macro as;

MACRO1 var1 var2.....

Then here the var1 will be passed to &1, var2 passed to &2 and so on.

Got it?

Regards

Karthik D

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
643

hi ,

Ampersign are place holders . In a macro , maximum of 9 place holders can be used.

Advantage is reusability

for example

DATA : a TYPE i,
       b TYPE i,
       c TYPE i.
DEFINE mac1.
  a = &1.
  b = &2.
  c = a &3 b.
  write : / c.
END-OF-DEFINITION.

mac1 2 3 +. " this is for addition
mac1 2 3 *. " this is for multiplication
mac1 6 2 /. " this is for division
mac1 4 2 -. " this is for substraction

Thanks & Regards

Read only

Former Member
0 Likes
643

Close the thread as answered if you got the solution...