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

passing variable to macros

Former Member
0 Likes
1,968

hi

i have a problem for passing the variable to macros

in the following code i have to pass the variable sy-index to the variable p_old&1,p_new&1 so that they become p_old1,p_old2,p_old3----p_old14 as the loop progresses. but it is throwing syntax error saying that p_oldsy-index is not defined

please help in this

DEFINE ADD_MAPPING.

TB_VALUE-OLD = P_OLD&1.

TB_VALUE-NEW = P_NEW&1.

APPEND TB_VALUE.

END-OF-DEFINITION.

DO 14 TIMES.

ADD_MAPPING 1." WRONG HERE

ENDDO.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,010

Hi Vijay,

Refer the following link to solve your problem.

<a href="http://www.sapsuperusers.com/forums/showthread.php?t=4863">http://www.sapsuperusers.com/forums/showthread.php?t=4863</a>

<b>Reward points if it helps.</b>

Regards,

Amit Mishra

4 REPLIES 4
Read only

Former Member
0 Likes
1,010

Vijay,

For macros you pass values not variable names. The value does not get concatenate and become P_OLD1, the way you are doing.

You will have to take care of the sy-index at the place where you are calling the macro.

Regards,

Ravi

Note : Please mark the helpful answers

Read only

Former Member
0 Likes
1,010

Hi vijay,

1. it should be like this (partly)

2.

report abc.

data : begin of tb_value occurs 0,

old(10) type c,

end of tb_value.

DEFINE ADD_MAPPING.

TB_VALUE-OLD = &1.

*TB_VALUE-NEW = P_NEW&1.

*APPEND TB_VALUE.

END-OF-DEFINITION.

DO 14 TIMES.

ADD_MAPPING 1." WRONG HERE

ENDDO.

regards,

amit m.

Read only

Former Member
0 Likes
1,011

Hi Vijay,

Refer the following link to solve your problem.

<a href="http://www.sapsuperusers.com/forums/showthread.php?t=4863">http://www.sapsuperusers.com/forums/showthread.php?t=4863</a>

<b>Reward points if it helps.</b>

Regards,

Amit Mishra

Read only

0 Likes
1,010

Hi Vijay,

Try this code...

DATA p_old1 TYPE i VALUE 10.
DATA p_c(10).
FIELD-SYMBOLS: <fs> TYPE ANY.

DEFINE ADD_MAPPING.
p_c = &1.
CONDENSE p_c.
CONCATENATE 'p_old' p_c INTO p_c.
ASSIGN (p_c) TO <fs>.
TB_VALUE-OLD = <fs>.

p_c = &2.
CONDENSE p_c.
CONCATENATE 'p_new' p_c INTO p_c.
ASSIGN (p_c) TO <fs>.
TB_VALUE-NEW = <fs>.

APPEND TB_VALUE.

END-OF-DEFINITION.

DO 14 TIMES.
ADD_MAPPING sy-index.
ENDDO.