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

Reusing a MACRO definition

kiran_k8
Active Contributor
0 Likes
698

HI Folks,

I have defined a macro to build up a RANGE as below.I need 4 to 5 ranges which are similar to this.Can anyone here please let me know how we can define one macro which can be reused to build up RANGE.



*For ex this is a macro m_r_mand for building up a range r_mand_fields.
define m_r_mand.
  r_mand_fields-sign   = &1.
  r_mand_fields-option = &2.
  r_mand_fields-low     = &3.
  append *r_mand_fields.* 
 clear  r_mand_fields.
end-of-definition.


m_r_mand 'I' 'EQ'  'BOART_AG'.
m_r_mand 'I' 'EQ'  'VKORG'.
m_r_mand 'I' 'EQ'  'VTWEG'.

*This is another macro m_r_sdh which builds up a range r_sdh.
define m_r_sdh.
r_sdh-sign   = &1.
r_sdh-option = &2.
r_sdh-low    = &3.
append *r_sdh.*
clear  r_sdh.
end-of-definition.

m_r_sdh 'I' 'EQ' 'VTWEG'    .
m_r_sdh 'I' 'EQ' 'SPART'    .
m_r_sdh 'I' 'EQ' 'BOTEXT'   .

The only difference is the RANGE.In one macro I am building up a range r_mand_fields and in another r_sdh.

Instead of defining two Macros is it possible to define one Macro which can be reused for a situation like the above?

Thanks,

Kiran.

1 ACCEPTED SOLUTION
Read only

former_member226519
Active Contributor
0 Likes
616

do you mean something like this?


define fill_range.
 &1-singn = &2.
 &1-option = &3.

  append &1.

3 REPLIES 3
Read only

former_member226519
Active Contributor
0 Likes
617

do you mean something like this?


define fill_range.
 &1-singn = &2.
 &1-option = &3.

  append &1.

Read only

0 Likes
616

Yes.Volker.I am looking at a way to define a macro where we can define the range as one of the parameter.Will tyr your option and update.

Read only

Sandra_Rossi
Active Contributor
0 Likes
616

Hi,

You could even add a second level macro to make things more "dynamic", as shown below.

In the code below, I didn't use header lines (they are obsolete), and I added the HIGH component, so that to make the macro fully reusable.

PS: I didn't test the code below, but I already did this kind of thing.


define m_r_any.
  clear  &1.
  &1-sign   = &3.
  &1-option = &4.
  &1-low     = &5.
  &1-high     = &6.
  append &1 to &2.
end-of-definition.

DATA ls_mand_fields LIKE LINE OF r_mand_fields.
define m_r_mand.
  m_r_any ls_mand_fields r_mand_fields &1 &2 &3 &4.
end-of-definition.
m_r_mand 'I' 'EQ'  'BOART_AG' ''.
m_r_mand 'I' 'EQ'  'VKORG' ''.
m_r_mand 'I' 'EQ'  'VTWEG' ''.

DATA ls_sdh LIKE LINE OF r_sdh.
define m_r_sdh.
  m_r_any ls_sdh r_sdh &1 &2 &3 &4.
end-of-definition.
m_r_sdh 'I' 'EQ' 'VTWEG' ''.
m_r_sdh 'I' 'EQ' 'SPART' ''.
m_r_sdh 'I' 'EQ' 'BOTEXT' ''.

Sandra