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

error in passing internal table as returning parameter

Former Member
0 Likes
1,125

Hi

Im new to ABAP OO.

I declared a parameter ret_kna1 Returning Type KNA1.

Inside the method, I am retrieving data from table KNA1 into internal table and then I want return the interal table value.

But Im not able to assing the internal table for eg : code

method READ_CUSTOMER_LIST.

data: lt_kna1 type TABLE OF kna1,
      wa_kna1 LIKE LINE OF lt_kna1.

data: lv_kunnr type kna1-kunnr,
      lv_land1 type kna1-LAND1.
SELECT * FROM kna1
INTO TABLE lt_kna1
WHERE land1 eq lv_land1.
insert LINES OF lt_kna1 INTO TABLE ret_kna1.
endmethod.

when I try to activate the error says 'ret_kna1 is not an internal table "OCCURS n" specification is missing.

but I can not declare the internal table 'ret_kna1' once again in the code, as it already defined in the parameter as type KNA1.

please help me how to assign internal table values to the returing structur.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
655

If you have mentioned KNA1 as the TYPE for returing parameter (in RETURNING part of method defintiion), method can only pass a single record. If you want to return an internal table from the method, define the type as LB_T_BIL_KNA1 (Table type for KNA1).

2 REPLIES 2
Read only

Former Member
0 Likes
656

If you have mentioned KNA1 as the TYPE for returing parameter (in RETURNING part of method defintiion), method can only pass a single record. If you want to return an internal table from the method, define the type as LB_T_BIL_KNA1 (Table type for KNA1).

Read only

Former Member
0 Likes
655

Are you passing it as an EXPORT parameter?

use and define it in the TABLES section of your function module as so:


*"  IMPORTING
*"     VALUE(INCLUDE_X_LEVELS) TYPE  CHAR1 OPTIONAL
*"  TABLES
*"      I_SELECTED_OU STRUCTURE  HRROOTOB
*"      I_SELECTED_EE STRUCTURE  OBJEC
*"      E_VIP_EPM_DISTR STRUCTURE  ZHR_VIP_EPM_DISTR
*"      E_RETURN STRUCTURE  BAPIRET1

That way you can pass value in the table (if needed) and then pass the table with your values based on your own logic