‎2019 Dec 13 2:30 PM
Hello experts,
i have written a simple code to understand the difference between the changing and using parameters, but i am getting the value as 3 4 0. why am i not getting the value as 1 2 0 for p1 p2 p3.
START-OF-SELECTION.
perform test.
form test.
data: p1 type i value 1,
p2 type i value 2,
p3 type i.
perform test1 using p1 p2 changing p3.
WRITE: p1,p2,p3.
ENDFORM.
form two USING p2 p3.
write:/ p3,' ',p2.
endform.
FORM test1 USING p1 TYPE i p2 TYPE i CHANGING p3 TYPE i.
data : p4 type i.
p1 = 3.
p2 = 4.
ENDFORM.
‎2019 Dec 13 2:48 PM
it is possible but it is "illegal" for SAP
if you would like to work with this kind of things, the better is to use Object oriented
‎2019 Dec 13 3:11 PM
HI,
If the additions USING and CHANGING are specified, a type-friendly actual parameter p1 p2 ... must be assigned to each of the formal parameters p1 p2 ... and change p3 ... defined using the same additions of the statement FORM TEST1. Together, the actual parameters specified after USING and CHANGING are a single shared list. They are assigned to the formal parameters using the position in the shared list.
that why you value will change according to that. If you need to print 1 2 0 you have pass only the value. kindly look at bellow code .
START-OF-SELECTION.
perform test.
form test.
data: p1 type i value 1,
p2 type i value 2,
p3 type i.
perform test1 using p1 p2 changing p3.
WRITE: p1,p2,p3.
ENDFORM.
form two USING p2 p3.
write:/ p3,' ',p2.
endform.
FORM test1 USING VALUE(p1) VALUE(p2) CHANGING VALUE(p3).
data : p4 type i.
p1 = 3.
p2 = 4.
ENDFORM.Further plz refer this.PERFORM - parameter_list
‎2019 Dec 13 3:42 PM
USING and CHANGING have an identical "changing" behavior if the parameter is passed by reference, but have the expected behaviors (USING arguments cannot change) if the parameter is passed by value.
Creating subroutines is obsolete, use methods instead.