11-08-2006 7:07 PM
Hello Experts,
I have an internal table with two fields. WERKS, for the site, and ERZET, for time counts were created. ERZET will either have a valid time or be blank (article wasn't counted). I need the earliest time brought to the top of the internal table for each site, but not the blank.
If I sort descending by WERKS ERZET I get the latest ERZET by site. If I sort ascending by WERKS ERZET I get the blank ERZET by site.
Problem: I want the earliest time for each site, but because of the blanks if I sort ascending I get the blanks first. Any syntax out there that would allow me to sort the table that would bring the first non-blank ERZET to the top of the internal table.
Thank-You
11-08-2006 7:14 PM
Well, you will have to work around it. Here is one solution, copy the internal table to another, delete out all of the lines where ERZET is initial, then sort the table ascending, then you will have the records in order.
itab2[] = itab1[].
delete itab2 where ERZET is initial.
sort itab2 ascending by WERKS ERZET.
Regards,
Rich Heilman
11-08-2006 7:13 PM
Hi,
I believe there is no syntax in sort to bring the non-blank values first..
Try this..
SORT ITAB BY WERKS ERZET.
LOOP AT ITAB WHERE WERKS = '1234'
AND NOT ERZET IS INITIAL.
EXIT.
ENDLOOP.
This will get the first record that is that not having a blank value..
Thanks,
Naren
11-08-2006 7:14 PM
Well, you will have to work around it. Here is one solution, copy the internal table to another, delete out all of the lines where ERZET is initial, then sort the table ascending, then you will have the records in order.
itab2[] = itab1[].
delete itab2 where ERZET is initial.
sort itab2 ascending by WERKS ERZET.
Regards,
Rich Heilman