2018 Oct 26 7:25 AM
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.
2018 Oct 26 7:31 AM
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?
2018 Oct 26 7:31 AM
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?
2018 Oct 26 7:38 AM