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

How to declare table in a method using OOP abap

Former Member
0 Likes
1,332

Hi every one i have a problem while exporting the the table from the method in a class.

I am using the the method GETDATA as below . Inside the method i am giving


import parameters are "OTYPE, OBJID, DATE1"  type Hrp1001

Export type as  Itab type zhrp1001(table type like hrp1001, created in se11 ).

Now the code inside the method GETDATA is

method GETDATA.

    select  otype objid begda endda sclas sobid relat plvar from hrp1001 into corresponding fields of table itab where otype eq otype and objid eq objid and begda <= date1 and endda >= date1.

endmethod.

Aftre declaring the method now in se38 program i am calling the  method GETDATA as below.


DATA : acct1 type ref to ZHRP1001.

DATA: itab TYPE STANDARD TABLE OF hrp1000,

        wa LIKE   LINE OF itab.

Data: itabfinal TYPE  TABLE OF hrp1001 with header line.


create object acct1.

select * from hrp1000 into table itab where otype in otype and objid in objid and begda <= date1 and endda >= date1.

   delete adjacent duplicates from itab.

clear wa.

   loop at itab into wa.

CALL METHOD acct1->getdata

   EXPORTING

     otype  = wa-otype

     objid  = wa-objid

     date1  = date1

   IMPORTING

     itab   = itabfinal.

endloop.

But iam getting the error as "ITAB-Final is not  type-compatible with the formal parameter "ITAB".

Please help me how to solve the above error and get output.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
986

Hi,

Modify the below code and check.

CALL METHOD acct1->getdata

   EXPORTING

     otype  = wa-otype

     objid  = wa-objid

     date1  = date1

  IMPORTING

     itab   = itabfinal[ ] .

Because your ITABFINAL is of table with header line.

Thanks

KH

1 REPLY 1
Read only

Former Member
0 Likes
987

Hi,

Modify the below code and check.

CALL METHOD acct1->getdata

   EXPORTING

     otype  = wa-otype

     objid  = wa-objid

     date1  = date1

  IMPORTING

     itab   = itabfinal[ ] .

Because your ITABFINAL is of table with header line.

Thanks

KH