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

Processing in 2 internal tables -Performance wise better option

Former Member
0 Likes
1,219

Hi Experts,

I have 2 internal tables.

ITAB1 and ITAB2 both are sorted by PSPHI.

ITAB1 has PSPHI some more fields INVOICE DATE and AMT

ITAB2 has PSPHI some more fields amount.

Both itab1 and itab2 will always have same amount of data.

I need to filter data from ITAB2 based invoice date given on selection screen.since ITAB2 doesnt have invoice date field.

i am doing further processing to filter the records.

I have thought of below processing logic and wanted to know if there is a better option performance wise?

loop at ITAB1 into wa where invoice_date > selection screen date. (table which has invoice date)

lv_index = sy-tabix.

read table itab2 where psphi = wa-psphi and index = lv_index.

if sy-subrc = 0.

delete itab2 index lv_index.

endif.

endloop.

Thanks for for your response.

9 REPLIES 9
Read only

Arun_Prabhu_K
Active Contributor
0 Likes
1,191

delete itab1 where invoice_date <= selection-screen date.

loop at itab1.

delete itab2 where psphi = itab1-psphi.

endloop.

Read only

madhu_vadlamani
Active Contributor
0 Likes
1,191

HI Bhanu,

You can try in this way.You have a b c in itab1 ,a,d,e in itab2.After loop you have data in first table.As per your requirement you need data in second table depends on first one.delete the data from first table in that selection.Now your first itab1 with the data what you need ,depends on this get fom itab2..

Regards,

Madhu.

Read only

0 Likes
1,191

Hi Madhu,

My Requirement is as below could you please advice on this ?

ITAB1

Field 1 PSPHI , FIELD 2 INVOICE, FIELD 3 INVOICE_DATE , FIELD4 AMT

15245, INV1, 02/2011 , 400

15245 INV2 02/2012 , 430

ITAB2

Field 1 PSPHI , FIELD 2 PSNR, FIELD 3 MATNR , FIELD4 AMT

15245, PSNR1, X . 430

15245 IPSNR2 Y, 400

When user enteres date on sel screen as 02/2011

I want to delete the data from itab1 and itab2 for invoice date greater then 02/2011/

If i delere ITAB1 for date > selection screen date.

Loop itab1.

delete itab2 where psphi in itab1 will delete both rows in above example because the field psphi which is common can be mutiple.

endloop.

Can you advice ?

Read only

0 Likes
1,191

I was thinking to sort itab2 based on psphi and amount but that would be risky ??

Read only

0 Likes
1,191

Hi Bhanu,

There is no risk.You check the report with all the features what you can keep.That will be a good practice and learn some new things,then only possible to learn new keywords.

Regards,

Madhu.

Read only

0 Likes
1,191

Delete itab2 where date is greater than entered date.

Loop at itab2.

Read itab1 with key psphi

IF not found delete itab2 index

Endloop.

Nabheet

Read only

0 Likes
1,191

Hi bhanu,

Your requirement vl be met by using this

nabheet-changing ur code a lil

delete itab1 where inv_date gt so_date.

Loop at itab2 into wa.

L_index = sy-tabix.

Read itab1 into wa1 with key psphi = wa-psphi

inv_amt = wa-amt transporting no fields.

If sy-subrc ne 0.

Delete itab2 index l_index.

Endloop.

Regards,

Harsh Bansal

Read only

0 Likes
1,191

Thanks for for your response.

Read only

Former Member
0 Likes
1,191

You can use TRANSPORTING NO FIELDS whiling reading ITAB2.


loop at ITAB1 into wa where invoice_date > selection screen date. (table which has invoice date)
    read table itab2 with key psphi = wa-psphi TRANSPORTING NO FIELDS.
    if sy-subrc = 0.
        delete itab2 index sy-tabix.
    endif.
endloop.