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

Pass tables-parameter to method

Former Member
0 Likes
969

Hi, all!

How do I pass a functions-modules tables-parameter, which refers to a ddic-structure, to a method (WAS 6.20). When trying to compile the method call it always gives me an error "actual parameter not compatibel to formal parameter". I even declared function modules tables parameter and methods importing parameter of same ddic-tables type.

Any help is more than appreciated!

Regards,

Thomas

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
927

Check this example Thomas,



*&---------------------------------------------------------------------*
*& Report  ZKB_TEST
*&---------------------------------------------------------------------*

REPORT  zkb_test.

TYPES: i_flight_list  TYPE TABLE OF bapisfldat,
       i_return  TYPE TABLE OF bapiret2.

*----------------------------------------------------------------------*
*       CLASS lcl_test DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_test DEFINITION.
  PUBLIC SECTION.
    METHODS: flights CHANGING it_flight_list TYPE i_flight_list
      it_return TYPE i_return.
ENDCLASS.                    "lcl_test DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_test IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_test IMPLEMENTATION.
  METHOD flights.
    DATA: lw_flight_list TYPE LINE OF i_flight_list.
    CALL FUNCTION 'BAPI_FLIGHT_GETLIST'
      EXPORTING
        airline     = 'AA'
      TABLES
        flight_list = it_flight_list
        return      = it_return.

    LOOP AT it_flight_list INTO lw_flight_list.
      WRITE:/ lw_flight_list-airline, lw_flight_list-connectid.
    ENDLOOP.

  ENDMETHOD.                    "flights
ENDCLASS.                    "lcl_test IMPLEMENTATION

START-OF-SELECTION.

  DATA: o_flight TYPE REF TO lcl_test,
        li_flight TYPE i_flight_list,
        li_return TYPE i_return.

  CREATE OBJECT o_flight.

  CALL METHOD o_flight->flights
    CHANGING
      it_flight_list = li_flight
      it_return      = li_return.

Regards

Kathirvel

8 REPLIES 8
Read only

Former Member
0 Likes
927

Create a table type in SE11 and use the same in your class.

Regards

Kathirvel

Read only

0 Likes
927

Hi, Kathirvel!

I tried so, but this unfortunatly resulted in the same error (see my other answer).

Regards,

Thomas

Read only

Former Member
0 Likes
927

Hi Thomas,

Can You show the call to the subroutine and the

subroutine's declaration?

Regards,

Ravi

Read only

0 Likes
927

Hi, Ravi!

Here' s the method:

methods CHECK_AUTHROLES
    importing
      !P_AUTHROLES type ZTBAPIROLLE
    exporting
      !P_INT_AGRNAME type ZBER_IT_INT_AGRNAME
    raising
      ZCX_ZBER_AUTHROLES_UNKNOWN .

And here' s the calling function module:

*" TABLES
*"      AUTHROLES TYPE  ZTBAPIROLLE OPTIONAL

And here the call:


l_user_manager->check_authroles(
      EXPORTING p_authroles = authroles
      IMPORTING p_int_agrname = int_agrname ).

Regards,

Thomas

Read only

0 Likes
927

Hi Thomas,

Checkout if there is any CHANGING parameter available for the method which is of type table

Read only

0 Likes
927

Hi Thomas,

You can create a TABLE TYPE for ZTBAPIROLLE in se11 , say <b>ZTBAPIROLLE_TAB</b>.

Then Use it in the methods statement.

methods CHECK_AUTHROLES

importing

!P_AUTHROLES type <b>ZTBAPIROLLE_TAB</b>

exporting

!P_INT_AGRNAME type ZBER_IT_INT_AGRNAME

raising

ZCX_ZBER_AUTHROLES_UNKNOWN .

Regards,

Ravi

Read only

Former Member
0 Likes
928

Check this example Thomas,



*&---------------------------------------------------------------------*
*& Report  ZKB_TEST
*&---------------------------------------------------------------------*

REPORT  zkb_test.

TYPES: i_flight_list  TYPE TABLE OF bapisfldat,
       i_return  TYPE TABLE OF bapiret2.

*----------------------------------------------------------------------*
*       CLASS lcl_test DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_test DEFINITION.
  PUBLIC SECTION.
    METHODS: flights CHANGING it_flight_list TYPE i_flight_list
      it_return TYPE i_return.
ENDCLASS.                    "lcl_test DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_test IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_test IMPLEMENTATION.
  METHOD flights.
    DATA: lw_flight_list TYPE LINE OF i_flight_list.
    CALL FUNCTION 'BAPI_FLIGHT_GETLIST'
      EXPORTING
        airline     = 'AA'
      TABLES
        flight_list = it_flight_list
        return      = it_return.

    LOOP AT it_flight_list INTO lw_flight_list.
      WRITE:/ lw_flight_list-airline, lw_flight_list-connectid.
    ENDLOOP.

  ENDMETHOD.                    "flights
ENDCLASS.                    "lcl_test IMPLEMENTATION

START-OF-SELECTION.

  DATA: o_flight TYPE REF TO lcl_test,
        li_flight TYPE i_flight_list,
        li_return TYPE i_return.

  CREATE OBJECT o_flight.

  CALL METHOD o_flight->flights
    CHANGING
      it_flight_list = li_flight
      it_return      = li_return.

Regards

Kathirvel

Read only

Former Member
0 Likes
927

Thanks for your help. Created a local variable of same type, assigned the fm-table-parameter and used it as parameter for the method.