03-14-2007 1:29 PM
I have the following two simple abap programs, the first one runs just fine, but the second one will generate run time error: assign to non-existent memory area error.
The only differenence is the first one uses parameters, and the second one uses data.
Could anybody explain why this happens?
Thanks in advance.
dliu
REPORT ZTX1202.
data: c.
parameters: p(10) default 'ABCDEFGHIJ'.
do 10 times varying c from p0 next p1.
write: /, 'index:', sy-index.
enddo.
*********************start of the second report********
REPORT ZTX1203.
data: c.
data: p(10) value 'ABCDEFGHIJ'. " will get assign to non-existent memory area error
do 10 times varying c from p0 next p1.
write: /, 'index:', sy-index.
enddo.
03-14-2007 1:40 PM
Hello,
I have executed ur second report in my system and it is working fine and gave the result like this:
index: 1
index: 2
index: 3
index: 4
index: 5
index: 6
index: 7
index: 8
index: 9
index: 10
Regards,
Vasanth
03-14-2007 1:33 PM
Change to
data: p(10) type c value 'ABCDEFGHIJ'.
and check ..
I have checked ur 2 prog code as it is and its working fine.
Try the above change for the 2 prog and check
regards,
Vijay
03-14-2007 1:35 PM
03-14-2007 1:39 PM
data: c.
data: p(10) .
p = 'ABCDEFGHIJ'.
do 10 times varying c from p+0 next p+1.
write: /, 'index:', sy-index.
enddo.
try this ..
no error from my side ..
03-14-2007 1:37 PM
Hi,
I tried to run your code for me it is not given error.
Which version you working?
aRs
03-14-2007 1:40 PM
03-14-2007 1:40 PM
Hello,
I have executed ur second report in my system and it is working fine and gave the result like this:
index: 1
index: 2
index: 3
index: 4
index: 5
index: 6
index: 7
index: 8
index: 9
index: 10
Regards,
Vasanth
03-14-2007 1:45 PM
May be due to IDES? I am not sure.
Try to run this code in development client.
aRs
03-15-2007 4:12 AM
Yeah, it is the problem with my IDES 4.7, I tried on another version, it works fine.
Thanks for all your reponses.
dliu
03-14-2007 7:49 PM
Hi David,
The basic difference between DATA and PARAMETERS is tht :
First of all both are used to declare variables. But in order to enable the user to enter values thru a selection-screen we use PARAMETERS. But if we want to do any calculations with a particular field we use DATA clause.
So, try the following example:
parameters :
p(10) type c default 'ABCDEFGHIJ'.
data:
w_c type c.
do 10 times varying w_c from p0 next p1.
write: /, 'index:', sy-index.
enddo.
Try this out and reward points to me if u find this helpful.
Regards
Swapna.