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 Help

Former Member
0 Likes
1,122

Hi Experts,

I can't figure out how to do the following:

Pass an internal table to a ABAP Method by reference

In the Method, use the internal table data to do a SELECT FROM INTO TABLE FOR ALL ENTRIES WHERE.

The internal table I'm passing can have different structure but will always have the fields used in the WHERE clause.

I've tried typing it "Table" in the method parameters but then I can't use the field name in the WHERE clause since it's not explicitly defined.  I could loop thru the table using field symbols and recreate the table but that defeats the purpose.  I might as well do the SELECT outside of the method and pass the end result to the Class.

Any help would be much appreciated.

Thank you,

Dae

1 ACCEPTED SOLUTION
Read only

UmaArjunan
Active Participant
0 Likes
1,086

Hi Experts,

I can't figure out how to do the following:

Pass an internal table to a ABAP Method by reference

In the Method, use the internal table data to do a SELECT FROM INTO TABLE FOR ALL ENTRIES WHERE.

The internal table I'm passing can have different structure but will always have the fields used in the WHERE clause.

I've tried typing it "Table" in the method parameters but then I can't use the field name in the WHERE clause since it's not explicitly defined.  I could loop thru the table using field symbols and recreate the table but that defeats the purpose.  I might as well do the SELECT outside of the method and pass the end result to the Class.

Any help would be much appreciated.

Thank you,

Dae

5 REPLIES 5
Read only

UmaArjunan
Active Participant
0 Likes
1,087
Read only

arindam_m
Active Contributor
0 Likes
1,086

Hi,

Have you done something like shown in the screenshot for using as reference Check the entry ET_KEYVALUE that should pass an internal table to a ABAP Method by reference, I got confused on the below statement

I've tried typing it "Table" in the method parameters but then I can't use the field name in the WHERE clause since it's not explicitly defined.

Can you clarify a bit more.

Cheers,
Arindam

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,086

You could define a local structured internal table in the method with only the field(s) required for the SELECT statement. At start of method use a LOOP ASSIGNING a ANY TYPE field-symbols then assign the component required to another FIELD-SYMBOLS of the required type and append it to the local internal table. Use this local internal table in the FOR ALL ENTRIES clause.

Regards,

Raymond

Read only

Former Member
0 Likes
1,086

FIELD-SYMBOLS: <l_i_ref> TYPE STANDARD TABLE.

DATA: i_tab TYPE t_tab,

ASSIGN i_temp TO <l_i_ref>.

  SELECT matnr

          maktx

    FROM z_table

    INTO TABLE i_tab

    FOR ALL ENTRIES IN <l_i_ref>

    WHERE (matnr EQ <l_i_ref>-matnr ).

Read only

matt
Active Contributor
0 Likes
1,086

Exactly as in the links posted by Uma Arjunan.

Thread locked. Please search before posting questions.