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

filter internal table with data in another internal table

Former Member
0 Likes
2,817

Hi all,

i need to filter a field(account) of one internal table with another 'account' filed that exist in another internal table.

and modify the first internal table accordingly..

how can i achieve this?

requirement given is " Filter the list of accounts by those returned via the GET_ORG_DATA FM for Reconciler, Approver, and Owner "

will this work:

    loop at t_items.   " first internal table is t_items
    read table t_items with key accounts = t_lookup-accounts. " t_lookup - 2nd IT
    if syst-subrc = 0.
    append t_items.
    endif.
    endloop.

thanks,

points assured

Message was edited by:

maahi verma

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,453

Hi,

Here is the correct one:


    loop at t_items.   " first internal table is t_items
      read table t_items with key accounts = t_lookup-accounts. " t_lookup - 2nd IT
      if syst-subrc <> 0. " if not found, delete fisrt table data.
        delete t_items.
      endif.
    endloop.

Regards,

4 REPLIES 4
Read only

Former Member
0 Likes
1,453

As the requirement says, you need to filter the data based upon list of accounts.

Here is a modified pseudo code -

loop at t_items. " first internal table is t_items

<b>read table t_lookups with key accounts = t_items-accounts. </b>

if syst-subrc ne 0.

delete t_items.

endloop.

Hope this helps.

ashish

Read only

0 Likes
1,453

hi ashish,

t_lookup is the table in which the data is coming from GET_ORG_DATA function module.

and i think we need to filter the data which is not common in both the tables.

Read only

0 Likes
1,453

requirement given is " Filter the list of accounts by those returned via the GET_ORG_DATA FM for Reconciler, Approver, and Owner "

So this is the reason - we are reading T_LOOKUP table in the T_ITEMS loop and flitering data of T_ITEMS based upon T_LOOKUP.

If entry is not found, delete entry from T_ITEMS.

Hope this is clear.

ashish

Read only

Former Member
0 Likes
1,454

Hi,

Here is the correct one:


    loop at t_items.   " first internal table is t_items
      read table t_items with key accounts = t_lookup-accounts. " t_lookup - 2nd IT
      if syst-subrc <> 0. " if not found, delete fisrt table data.
        delete t_items.
      endif.
    endloop.

Regards,