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

Question on using table types in methods

Former Member
0 Likes
420

Hi

I have a simple question involving passing table types in method

I want to pass an internal table by reference - to a method and within the method populate the internal table (t1) using a select * into the internal table and then sort t1 by f1 and f2. t1 is an internal table based on a ABAP dictionary table ( at1 )

Question is : If I use a generic type TABLE declaration , it does not allow sort operation specifically by fields. If I use type at1 as in

the METHODS M1 exporting t1 type at1statement, syntax error is - t1 is not an internal table.

How do I achieve the above using the method implementation ?

Sample code that I try

***************************************************************************************************

CLASS C1 DEFINITION

PUBLIC SECTION

METHODS M1 exporting t1 type table

ENDMETHOD

ENDCLASS

CLASS C1 IMPLEMENTATION

METHOD M1

select * from at1 into t1.

sort t1 field f1 f2

ENDCLASS

1 ACCEPTED SOLUTION
Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
378

You should define a TABLE TYPE based upon the data dictionary type (at1) either in the data dictionary using SE11 or in the TYPES section of the class.

Then define the parameter of this new type.

Cheers

Graham Robbo

2 REPLIES 2
Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
379

You should define a TABLE TYPE based upon the data dictionary type (at1) either in the data dictionary using SE11 or in the TYPES section of the class.

Then define the parameter of this new type.

Cheers

Graham Robbo

Read only

0 Likes
378

Thanks for the prompt reply. Full points awarded.