2012 Dec 07 6:36 PM
Hi ABAPers,
I am new to this and would like a little help from you. I am going through the Teach yourself ABAP book and there are a few sample programs that I am trying to see work. But I constantly get and error saying
"P" and "C" are type-incompatible.
Here is the source code:
parameters p(20) default 'c::\\\xx\\yy'.
data: c type c,
n type c.
do 19 times varying c from p+0 next p+1
varying n from p+1 next p+2.
check c ca ':\'.
if c = n.
write: / 'duplicate', c, 'found', 'at position', sy-index.
endif.
enddo.
I am typing it exactly how it is n the book. Can someone tell me if there is a solution to this?
Look forward to hearing from you guys...
Thanks.
M
2012 Dec 07 6:49 PM
Hi Manish,
In my system, I get get this working by specifying an explicit number of characters to capture in the offset. My system also requires the RANGE addition, but depending on your release level, your system may not.
DO 19 TIMES VARYING c FROM p+0(1) NEXT p+1(1) RANGE p
VARYING n FROM p+1(1) NEXT p+2(1) RANGE p.
...
ENDDO.
To make life more interesting, the VARYING addition for DO...ENDO is now obsolete. Check out ASSIGN ... INCREMENT which replaces it.
Cheers,
Amy
Hi Manish,
In my system, I get get this working by specifying an explicit number of characters to capture in the offset. My system also requires the RANGE addition, but depending on your release level, your system may not.
DO 19 TIMES VARYING c FROM p+0(1) NEXT p+1(1) RANGE p
VARYING n FROM p+1(1) NEXT p+2(1) RANGE p.
...
ENDDO.
To make life more interesting, the VARYING addition for DO...ENDO is now obsolete. Check out ASSIGN ... INCREMENT which replaces it.
Cheers,
Amy
2012 Dec 07 6:49 PM
Hi Manish,
In my system, I get get this working by specifying an explicit number of characters to capture in the offset. My system also requires the RANGE addition, but depending on your release level, your system may not.
DO 19 TIMES VARYING c FROM p+0(1) NEXT p+1(1) RANGE p
VARYING n FROM p+1(1) NEXT p+2(1) RANGE p.
...
ENDDO.
To make life more interesting, the VARYING addition for DO...ENDO is now obsolete. Check out ASSIGN ... INCREMENT which replaces it.
Cheers,
Amy
2012 Dec 07 7:13 PM
Thanks Amy. You suggestion of including the below:
p+0(1) next p+1(1)
has allowed the syntax check to complete and the program run successfully.
Can you tell me what the (1) after the p+0 and RANGE actually do?
Thanks again for the quick reply!
M
2012 Dec 07 7:21 PM
Hi Manish,
The (1) is a length specification and indicates how many characters to transfer in the assignment. Let's say we have two character variables:
DATA: lv_var_one TYPE char10,
lv_var_two TYPE char10.
The statement...
lv_var_one = lv_var_two+3(7).
takes lv_var_two, skips the first 3 characters and assigns the next 7 characters to lv_var_one.
If you wrote...
lv_var_one = lv_var_two+3.
then the first 3 characters of lv_var_two would be skipped and the rest of the value of lv_var_two would be assigned to lv_var_one.
It can be useful when you want to capture just part of another variable value, like...
lv_current_month = sy-datum+4(2).
Here are a couple of documents about offset and length if you want to read more.
RANGE specifies an explicit memory area which the VARYING components may access.
Cheers,
Amy
2012 Dec 07 8:32 PM
2012 Dec 07 6:54 PM
Hi,
P is a packed data type that is numeric data type and you cannot use characters inside it because you cannot convert P to C and they are incompatible.
Read this link...
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/content.htm
also read this which tells about conversion rules.
http://help.sap.com/SAPHELP_470/Helpdata/EN/fc/eb3434358411d1829f0000e829fbfe/content.htm
thanks.
2012 Dec 07 6:59 PM
Hi Aswatha,
Actually, in Manish's code snippet, variable P is a character field of length 20.
parameters p(20) default 'c::\\\xx\\yy'.
Cheers,
Amy
2012 Dec 07 7:02 PM
Hi Amy,
thanks for waking me up here .... i didnt see that at all.......
thanks.
2012 Dec 07 7:06 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |