Code: Alles auswählen.
SELECT a~vbeln a~erdat a~lifsk a~bstnk a~kunnr
b~cmgst
c~posnr c~matnr c~matwa c~arktx c~pstyv
c~posar c~lfrel c~uepos c~abgru c~abdat
c~kdmat c~vkgru c~netwr c~waerk c~kwmeng c~vrkme c~netpr
c~stadat c~kannr c~zz_caufno c~werks
d~etenr d~edatu d~wmeng d~bmeng
FROM (vbak AS a JOIN vbuk AS b ON b~vbeln = a~vbeln JOIN vbap AS c ON c~vbeln = a~vbeln JOIN vbep AS d ON d~vbeln = a~vbeln AND d~posnr = c~posnr)
WHERE (a~kunnr = '1701199886' and a~erdat >= '20110908' and a~erdat <= '20111207' and ( a~vkorg like 'FR%' and a~lifsk <> 'Z9' ) and c~abgru in ('Z2', 'Z3') ' and c~pstyv in ('ZNN','ZNS','ZNCD','ZNSG') and ( d~bmeng > 0 or ( d~bmeng = 0 and b~cmgst in ('B', 'C')).
(Frage nicht was SAP für Dich tun kann..., sondern die Datenbank direkt)