LOOP AT xh_itabl.
SELECT SUM( erfmg ) SUM( dmbtr ) INTO (wa_it-erfmg, wa_it-dmbtr)
FROM mseg
WHERE bwtar IN so_bwart AND
mseg~matnr = xh_itabl-matnr AND
werks = xh_itabl-werks AND
shkzg = 'H'.
IF wa_it-erfmg <> space.
xh_itabl-nprice = wa_it-dmbtr / wa_it-erfmg.
MODIFY xh_itabl.
ENDIF.
endloop.
要求:
1. 将 select 从loop 里面拿出来。
2. 不用select sum.