Application Development 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: 

I am getting wrong parameter type error . I don't know why this error is coming.

former_member579349
Participant
0 Kudos
1,067

Hi Experts,

For following program I am getting following error: During a dynamic call of method "METH" of class "MAIN", parameter "H1" was passed with the wrong parameter type.

Please help me why I am getting this error.

Thanks!

FUNCTION ZTEST_PROG_PARAM1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"----------------------------------------------------------------------
DATA itab TYPE TABLE OF string.
DATA class TYPE string.
DATA oref TYPE REF TO object.
DATA c1 TYPE CURSOR.
DATA h2 TYPE demo_expressions.
DATA holder TYPE demo_expressions.
DATA prog TYPE C LENGTH 8.

APPEND 'program subpool.' TO itab.
APPEND 'class main definition.' TO itab.
APPEND ' public section.' TO itab.
APPEND ' methods meth EXPORTING h1 TYPE demo_expressions.' TO itab.
APPEND 'endclass.' TO itab.
APPEND 'class main implementation.' TO itab.
APPEND ' method meth.' TO itab.
APPEND ' DATA c1 TYPE cursor. ' TO itab.
APPEND ' DATA holder TYPE TABLE OF demo_expressions INITIAL SIZE 10.' TO itab.
APPEND ' OPEN CURSOR WITH HOLD @c1 ' TO itab.
APPEND ' FOR SELECT ' TO itab.
APPEND ' * ' TO itab.
APPEND 'FROM ' TO itab.
APPEND 'demo_expressions.' TO itab.
APPEND 'DO.' TO itab.
APPEND 'FETCH NEXT CURSOR @c1 INTO TABLE @holder.' TO itab.
APPEND ' IF sy-subrc <> 0. ' TO itab.
APPEND ' CLOSE CURSOR @c1. ' TO itab.
APPEND ' EXIT.' TO itab.
APPEND 'ELSE.' TO itab.
APPEND 'READ TABLE holder INTO h1 INDEX 1.' TO itab.
APPEND 'ENDIF.' TO itab.
APPEND 'ENDDO.' TO itab.
APPEND ' endmethod.' TO itab.
APPEND 'endclass.' TO itab.

GENERATE SUBROUTINE POOL itab NAME prog.

CONCATENATE `\PROGRAM=` prog `\CLASS=MAIN` INTO class .

CREATE OBJECT oref TYPE (class).

CALL METHOD oref->('METH') RECEIVING h1 = h2.




ENDFUNCTION.

1 ACCEPTED SOLUTION

0 Kudos
279

Hi Partish,

you declared h1 as EXPORTING parameter:

APPEND ' methods meth EXPORTING h1 TYPE demo_expressions.' TO itab.

But you expect it to be a RECEIVING parameter in the code below:

CALL METHOD oref->('METH') RECEIVING h1 = h2.

Maybe changing the definition to RETURNING VALUE() or replacing RECEIVING by IMPORTING helps?

2 REPLIES 2

0 Kudos
280

Hi Partish,

you declared h1 as EXPORTING parameter:

APPEND ' methods meth EXPORTING h1 TYPE demo_expressions.' TO itab.

But you expect it to be a RECEIVING parameter in the code below:

CALL METHOD oref->('METH') RECEIVING h1 = h2.

Maybe changing the definition to RETURNING VALUE() or replacing RECEIVING by IMPORTING helps?

0 Kudos
279

Thanks. Its working now.