‎2011 Sep 16 2:05 PM
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.
‎2011 Sep 16 2:51 PM
do you mean something like this?
define fill_range.
&1-singn = &2.
&1-option = &3.
append &1.
‎2011 Sep 16 2:51 PM
do you mean something like this?
define fill_range.
&1-singn = &2.
&1-option = &3.
append &1.
‎2011 Sep 17 8:17 AM
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.
‎2011 Sep 17 9:50 AM
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