One way to approach this is to create the required detail and group levels individually, then union together and "order by" to get the results. Using CTEs keeps the individual sets simple and readable.
WITH totals (vendno, company, sumtotstdcost, myLevel) -- First get subtotals
AS ( SELECT fvendno
, fcompany
, SUM(totstdcost), 'subtotal'
FROM #mytable
GROUP BY fvendno, fcompany
)
, myUNION -- then union detail, subtotal, and report totals rows
AS ( SELECT fvendno
, fcompany
, POitemKey
, CONVERT(VARCHAR(50), PORelsDate) as PORelsDate
, totstdcost, ID
, 'detail' as myLevel
FROM #mytable UNION ALL
SELECT vendno
, company
, 'Subtotal'
, ''
, sumtotstdcost
, 0
, myLevel
FROM totals
UNION ALL
SELECT 'Report Total'
, ''
, ''
, ''
, SUM(totstdcost)
, 0
, 'zReportTotal'
FROM #mytable
)
-- select from union and order by to get the desired order
SELECT fvendno
, fcompany
, POitemKey
, PORelsDate
, totstdcost
FROM myUNION
ORDER BY fvendno
, myLevel
, ID