2012 Jan 07 1:13 AM
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.
2012 Jan 07 3:29 AM
delete itab1 where invoice_date <= selection-screen date.
loop at itab1.
delete itab2 where psphi = itab1-psphi.
endloop.
2012 Jan 07 3:45 AM
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.
2012 Jan 07 3:55 AM
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 ?
2012 Jan 07 3:57 AM
I was thinking to sort itab2 based on psphi and amount but that would be risky ??
2012 Jan 07 4:33 AM
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.
2012 Jan 07 5:24 AM
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
2012 Jan 07 7:05 AM
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
2012 Jan 09 2:59 PM
2012 Jan 07 7:01 AM
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.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |