‎2006 May 29 8:56 AM
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.
‎2006 May 29 9:06 AM
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
‎2006 May 29 9:00 AM
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
‎2006 May 29 9:05 AM
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.
‎2006 May 29 9:06 AM
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
‎2006 May 29 9:12 AM
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.