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

Method parameter & variable in program - "is not type compatible"

csaba_szommer
Active Contributor
0 Likes
1,952

Hi All,

Sorry for my dummy question but by checking a few threads I couldn't find answer.

I have a method with a paramter and calling it I get error message:

"variable" is not type-compatible with formal parameter "parameter"

'variable' --> data element: 'zchar2' (CHAR 2)

'parameter' --> data element: 'zchar10' (CHAR 10)

It's clear that 'zchar2' and 'zchar10' are different.

What is not clear to me why cannot I import a 2 character string into a parameter of 10 characters.

There's no error if I change the parameter's type from 'zchar10' to 'c' in the method. However I don't want this since the parameter must have 10 characters or less (and no more).

How can I define the parameter in the method properly (I don't want to manipulate 'variable')? What is the solution?

Thanks,

Csaba

Additionally:

Tried char10, string10 - it didn't help...

Edited by: Csaba Szommer on Mar 19, 2011 7:17 PM

1 ACCEPTED SOLUTION
Read only

naveen_inuganti2
Active Contributor
0 Likes
1,242

Hi,

I am not trying to answer you about why SAP has provided that kind of validation.

But I wan to understand why are you passing PARAMETER with more than CHAR2 as there is no meaning as VARIABLE will truncate last 8 Characters.

Also we might want to pass PARAMETER to PARAMETER2 (Char2) and then pass PARAMETER2 to VARIABLE of method.

Thanks,

Naveen Inuganti

3 REPLIES 3
Read only

naveen_inuganti2
Active Contributor
0 Likes
1,243

Hi,

I am not trying to answer you about why SAP has provided that kind of validation.

But I wan to understand why are you passing PARAMETER with more than CHAR2 as there is no meaning as VARIABLE will truncate last 8 Characters.

Also we might want to pass PARAMETER to PARAMETER2 (Char2) and then pass PARAMETER2 to VARIABLE of method.

Thanks,

Naveen Inuganti

Read only

0 Likes
1,242

Naveen,

Thanks for your answer.

I want to import char2 from program (from where the method is called) into the method via a char10 parameter (export / import depends on from which point we see it).

CALL METHOD dummy=>dummy

EXPORTING parameter (remark: char10) = variable (remark: char2).

Thanks,

Csaba

Edited by: Csaba Szommer on Mar 19, 2011 7:25 PM

Read only

1,242

Hi Csaba,

declare the parameter as TYPE ANY. This works and you can call it as

dummy=>dummy( remark ).

Regards,

Clemens