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

Re : passing an internal table into a method

Former Member
0 Likes
484

hai,

how to pass an internal table into a method.

thanks and regards

mani

hai,

how to pass an internal table into a method.

thanks and regards

mani

2 REPLIES 2
Read only

Former Member
0 Likes
445

Check out the below related threads


TYPES lty_sflight TYPE STANDARD TABLE OF sflight WITH NON-UNIQUE DEFAULT KEY.
 
CLASS lcl_class DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      example1 EXPORTING et_sflight TYPE lty_sflight,
      example2 EXPORTING et_table   TYPE STANDARD TABLE.
ENDCLASS.                    "lcl_class DEFINITION
 
DATA:
  lt_sflight TYPE lty_sflight.
 
START-OF-SELECTION.
  lcl_class=>example1( IMPORTING et_sflight = lt_sflight ).
  lcl_class=>example2( IMPORTING et_table = lt_sflight ).
 
CLASS lcl_class IMPLEMENTATION.
  METHOD example1.
    SELECT * FROM sflight INTO TABLE et_sflight.
  ENDMETHOD.                                                "example1
  METHOD example2.
    SELECT * FROM sflight INTO TABLE et_table.
  ENDMETHOD.                                                "example2
ENDCLASS.                    "lcl_class IMPLEMENTATION 

Read only

Former Member
0 Likes
445

Hi,

Below program demonstrates how an internal table can be used as one of the interface parameters of a method.

The program contains a method: GETMARA in class: GET_MATERIALS. It accepts material group, MATGR as import parameter and details out the details of the materials belonging to that material group into I_TAB , which is an internal table used as EXPORTING parameter for the method.

REPORT ZINTTAB .

types : begin of typ_tab ,

matnr like mara-matnr ,

meins like mara-meins ,

end of typ_tab .

data : itab type standard table of typ_tab ,

x_tab LIKE LINE OF ITAB.

CLASS get_materials DEFINITION.

PUBLIC SECTION.

METHODS : getmara IMPORTING matgr TYPE C

EXPORTING l_tab TYPE ANY TABLE.

endclass.

CLASS get_materials IMPLEMENTATION.

METHOD : getmara .

SELECT matnr meins INTO TABLE l_tab

FROM MARA

WHERE MATKL = matgr.

ENDMETHOD.

ENDCLASS.

PARAMETERS : p_matkl like mara-matkl .

START-OF-SELECTION.

DATA : w_mat TYPE REF TO get_materials.

CREATE OBJECT : w_mat.

CALL METHOD w_mat->getmara EXPORTING matgr = p_matkl

IMPORTING l_tab = itab .

LOOP AT ITAB INTO X_TAB.

WRITE:/5 X_TAB-MATNR , X_TAB-MEINS.

ENDLOOP.

Best Regards

Suresh