Application Development 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: 

Method to read a result set from a select

Former Member
0 Kudos

Hello,

I am trying to build a method that will return the results in a internal table. But I am finding that I can only get the header row back.

Here is the code in my method:

class c1 implementation.

method m1.

select bukrs belnr bschl dmbtr koart kostl lifnr

from bseg

into gt_bseg

where bukrs = w_bukrs

and belnr = w_belnr.

endselect.

endmethod. "m1

endclass. "c1 IMPLEMENTATION

Here is my method call:

call method oref->m1

EXPORTING

w_bukrs = gt_bkpf-bukrs

w_belnr = gt_bkpf-belnr

RECEIVING

gt_bseg_t = gt_bseg.

I can see that the correct data is being passed to my method, but why doesn't it populate my internal table with rows.

If I put the select statement from my method in a loop of my internal table of gt_bkpf , it works fine.

Thanks!

2 REPLIES 2

athavanraja
Active Contributor
0 Kudos

Because the <i><b>append</b></i> is missing.

select bukrs belnr bschl dmbtr koart kostl lifnr

from bseg

into gt_bseg

where bukrs = w_bukrs

and belnr = w_belnr.

<i><b>append gt_bseg .</b></i>

endselect.

better option:

select bukrs belnr bschl dmbtr koart kostl lifnr

from bseg

into <i><b>table</b></i> gt_bseg

where bukrs = w_bukrs

and belnr = w_belnr.

Regards

Raja

Message was edited by: Durairaj Athavan Raja

nablan_umar
Active Contributor
0 Kudos

You forgot "TABLE" in "into gt_bseg" statement. It should be "into table gt_bseg"