表MSEG中,根据物料号MATNR,对MENGE字段进行求和 。
当SHKZG = H ,MENGE*( -1 );
SHKZG = S, MENGE*1,,然后求和
参考ABAP SQL CASE 语法
代码语言:javascript复制SELECT mseg~matnr,
SUM( mseg~menge * (
CASE mseg~shkzg
WHEN 'H' THEN ( -1 )
WHEN 'S' THEN ( 1 )
END
) ) AS sl
FROM mseg
INTO TABLE @DATA(lt)
GROUP BY mseg~matnr
ORDER BY mseg~matnr
.
cl_demo_output=>display( lt ).