2010 Aug 17 7:18 PM
Hi,
I have the custom database table and i'm fetching records from this table in to my internal table. Now i need to filter this internal table with respect two fields po and version as below:-
1.) Let say 10 records are fetched from custom databas table into ITAB1 in the following manner:
PO No. VERSION No.
po1 1
p01 2
p01 3
p02 1
p02 2
p03 1
p04 1
p05 1
p05 2
po5 3
2.) Now this should be filtered in to ITAB2 as below:-
PO No. VERSION No.
p01 3
p02 2
p03 1
p04 1
p05 3
Please let me know the logic to get this. I was trying SORT ITAB1 by VERSION No.
DELETE ADJACENT DUPLICATES COMPARING PO No. field.
But that did'nt work for me.
Thanks in advance,
Naveen
2010 Aug 17 7:47 PM
Hi
Please refer the below code snippet.
REPORT ZTEXT_EDITOR .
data : begin of itab1 occurs 1,
ponum(3),
versnum(1),
end of itab1.
data : begin of itab2 occurs 1,
ponum(3),
versnum(1),
end of itab2.
clear itab1.
itab1-ponum = 'PO1'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO1'.
itab1-versnum = '2'.
append itab1.
clear itab1.
itab1-ponum = 'PO1'.
itab1-versnum = '3'.
append itab1.
clear itab1.
itab1-ponum = 'PO2'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO2'.
itab1-versnum = '2'.
append itab1.
clear itab1.
itab1-ponum = 'PO3'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO4'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO5'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO5'.
itab1-versnum = '2'.
append itab1.
clear itab1.
itab1-ponum = 'PO5'.
itab1-versnum = '3'.
append itab1.
sort itab1 by ponum versnum descending.
delete adjacent duplicates from itab1 comparing ponum.
itab2[] = itab1[].
write itab1.Close the thread if this solves your query.
Regards
Abhii
Hi,
I have the custom database table and i'm fetching records from this table in to my internal table. Now i need to filter this internal table with respect two fields po and version as below:-
1.) Let say 10 records are fetched from custom databas table into ITAB1 in the following manner:
PO No. VERSION No.
po1 1
p01 2
p01 3
p02 1
p02 2
p03 1
p04 1
p05 1
p05 2
po5 3
2.) Now this should be filtered in to ITAB2 as below:-
PO No. VERSION No.
p01 3
p02 2
p03 1
p04 1
p05 3
Please let me know the logic to get this. I was trying SORT ITAB1 by VERSION No.
DELETE ADJACENT DUPLICATES COMPARING PO No. field.
But that did'nt work for me.
Thanks in advance,
Naveen
2010 Aug 17 7:36 PM
Sort gt_out by po version descending.
Delete adjacent duplicates from gt_out comparing po.
2010 Aug 17 7:47 PM
Hi
Please refer the below code snippet.
REPORT ZTEXT_EDITOR .
data : begin of itab1 occurs 1,
ponum(3),
versnum(1),
end of itab1.
data : begin of itab2 occurs 1,
ponum(3),
versnum(1),
end of itab2.
clear itab1.
itab1-ponum = 'PO1'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO1'.
itab1-versnum = '2'.
append itab1.
clear itab1.
itab1-ponum = 'PO1'.
itab1-versnum = '3'.
append itab1.
clear itab1.
itab1-ponum = 'PO2'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO2'.
itab1-versnum = '2'.
append itab1.
clear itab1.
itab1-ponum = 'PO3'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO4'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO5'.
itab1-versnum = '1'.
append itab1.
clear itab1.
itab1-ponum = 'PO5'.
itab1-versnum = '2'.
append itab1.
clear itab1.
itab1-ponum = 'PO5'.
itab1-versnum = '3'.
append itab1.
sort itab1 by ponum versnum descending.
delete adjacent duplicates from itab1 comparing ponum.
itab2[] = itab1[].
write itab1.Close the thread if this solves your query.
Regards
Abhii
2010 Aug 18 8:02 AM
2010 Aug 18 8:06 AM
2010 Aug 18 9:22 AM
hi,
loop at the internal table itab1. and at last of PO NO append the work area to itab2.
you get the desired output.
regards,
sirisha
2010 Aug 18 9:56 AM
Hi Sirisha,
on AT LAST you cannot specify any field like you said AT LAST PO.
Jaikrishna,
Follow the code I have written, you will get the desired output.
Regards
Abhii
2010 Aug 18 1:20 PM
Abhii,
yes you were right, i mean it was AT END OF PO.
regards,
sirisha
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |