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: 

Filtering records from one internal table based on ranges in another itab

Former Member
0 Kudos

Hi guys,

I have 1 internal table with set of GL accounts. I have 2nd internal table where lower interval and upper interval of GL accounts

How to filter out records from 1 internal table by comparing with the GL account ranges present in 2nd internal table.

Please reply.

1 ACCEPTED SOLUTION

asik_shameem
Active Contributor

Hi

Create a RANGE for GL Accounts.

LOOP the second Internal Table.

And assign HIGH & LOW to ranges from second ITAB.

And Delete the accounts which are not there in the range.

Use the below code as reference.

DATA: itab TYPE TABLE OF mara WITH HEADER LINE.

DATA: r_matnr TYPE RANGE OF matnr WITH HEADER LINE.

  SELECT * FROM mara INTO TABLE itab UP TO 10 ROWS.
  
  r_matnr-sign = 'I'.
  r_matnr-option = 'BT'.
  r_matnr-low  = '000000000016900036'.
  r_matnr-high = '000000000016900040'.
  APPEND r_matnr.
  
  DELETE itab WHERE matnr NOT IN r_matnr.

4 REPLIES 4

kiran_k8
Active Contributor
0 Kudos

Vinay,

sort itab2 ascending by hkont.

loop at itab1.

read table itab2 where hkont = itab1-hkont.

if sy-subrc ne 0.

delete itab1.

endloop.

K.Kiran.

asik_shameem
Active Contributor

Hi

Create a RANGE for GL Accounts.

LOOP the second Internal Table.

And assign HIGH & LOW to ranges from second ITAB.

And Delete the accounts which are not there in the range.

Use the below code as reference.

DATA: itab TYPE TABLE OF mara WITH HEADER LINE.

DATA: r_matnr TYPE RANGE OF matnr WITH HEADER LINE.

  SELECT * FROM mara INTO TABLE itab UP TO 10 ROWS.
  
  r_matnr-sign = 'I'.
  r_matnr-option = 'BT'.
  r_matnr-low  = '000000000016900036'.
  r_matnr-high = '000000000016900040'.
  APPEND r_matnr.
  
  DELETE itab WHERE matnr NOT IN r_matnr.

former_member181995
Active Contributor
0 Kudos

Post your whole requirement here(data decleration aslo) here.

definatly i'll code for you its saturday only.

Former Member
0 Kudos

Thanks Asik. It was helpful.

Amit-Thanks for offering your help.