06-14-2007 6:18 AM
Ex : If internal table for PO looks like :
POSNR - Plant
00010 - 204
00020 - 202
00030 - 204
00040 - 202
00050 - 206
After sorting with respect to plant and then posnr,
the layout is :
00020 - 202
00040 - 202
Page-break
00010 - 204
00030 - 204
Page-break
00050 - 206
In this case, the 1st item displayed on the 1st page is item # 00020
Our key users do not like it, and wish to see the 1st item (# 00010) on the 1st page
The desired result is to change the sequence displaying the "plant block" containing the 1st item :
00010 - 204
00030 - 204
Page-break
00020 - 202
00040 - 202
Page-break
00050 - 206
The general rule is still to sort by plant (ascending) and then by item number (ascending also), but to move the block
of the plant containing the lowest item number on top of the sequence.
Please be careful not to generate regression in case there is only 1 item, or only 1 plant, or any other case.
Kindly provide a solution.
Thanks & Regards,
Tejas
06-14-2007 6:21 AM
Hi,
You have to sort with posnr first and then sort with the plant..
SORT ITAB BY POSNR PLANT
Thanks
Naren
06-14-2007 6:22 AM
Use this logic. Create a copy of the internal table.
itab_temp[] = itab[].
SORT ITAB BY POSNR.
LOOP AT ITAB.
LOOP AT ITAB_TEMP WHERE ITAB_TEMP-PLANT = ITAB-PLANT.
WRITE ITAB_TEMP-PLANT , ITAB_TEMP-POSNR.
ENDLOOP.
DELETE ITAB_TEMP WHERE PLANT = ITAB-PLANT.
ENDLOOP.
06-14-2007 6:39 AM
hi,
i suggest you create another intrnal table ( I_TAB2 ) and do it like this
sort I_TAB by posnr
move the first record of I_TAB to I_TAB2
delete the 1st record of I_TAB
transfer all remainingrecords of I_TAB into I_TAB2 where plant = I_TAB2-plant
delete from I_TAB all records with plant = I_TAB2 plant
sort I_TAB by plant posnr
transfer all records of I_TAB into I_TAB2
your I_TAB2 will be the result