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

OO ABAP programming

Former Member
0 Kudos
141

Dear experts,

Can i do this in OO abap prograaming that , declare an internal table t1 of type ty. and do something like

t1 = class ->method( exporting parameter)

where method returns me the internal table

in separate section

methos importing parameter returning itab type ty.

Plz i am very new to OO Programming.

2 REPLIES 2
Read only

Former Member
0 Kudos
99

Hi,

You can call the method in this fashion and get the output table in your internal table itab.

CALL METHOD Class=>method

EXPORTING

ex1 = ex1

IMPORTING

tab = itab.

-kshitija

Read only

0 Kudos
99

It depends on how table parameter is declared in class. U can do this only if it is a returning parameter in a method. To understand how to call method with shorter syntaxis check this example please.

program zjdtest.

constants: lc_a type c value 'A',
           lc_b type c value 'B'.

data: ld_c1 type c,
      ld_c2 type c,
      ld_c3 type char2.

class lcl_report definition.
  public section.
    class-methods: method1 importing id_parameter1 type c
                                     id_parameter2 type c
                           exporting ed_parameter1 type c
                                     ed_parameter2 type c,
                   method2 importing id_parameter1 type c
                                     id_parameter2 type c
                           returning value(rd_parameter) type char2.


endclass.

class lcl_report implementation.
  method method1.
    ed_parameter1 = id_parameter1.
    ed_parameter2 = id_parameter2.
  endmethod.
  method method2.
    concatenate id_parameter1 id_parameter2 into rd_parameter.
  endmethod.
endclass.

start-of-selection.
  lcl_report=>method1( exporting id_parameter1 = lc_a
                                 id_parameter2 = lc_b
                       importing ed_parameter1 = ld_c1
                                 ed_parameter2 = ld_c2 ).

  write: ld_c1, ld_c2.

  ld_c3 = lcl_report=>method2( id_parameter1 = lc_a
                               id_parameter2 = lc_b ).
  write: / ld_c3.