Goods receipts of a purchase order
SELECT FROM ekpo AS i
INNER JOIN ekbe AS h
ON h~ebeln = i~ebeln
AND h~ebelp = i~ebelp
FIELDS i~ebeln, i~ebelp, i~matnr,
h~belnr AS gr_doc, h~gjahr,
h~menge, h~dmbtr, h~shkzg
WHERE i~ebeln = @lv_ebeln
AND h~vgabe = '1'
INTO TABLE @DATA(receipts).Tables
EKPO, EKBE
What you get
Every goods receipt per PO item, with quantity, local currency value and the material document number.
Watch out
VGABE 1 is goods receipt and 2 invoice receipt. Reversals are lines of their own with SHKZG = H, so net them before you report quantities.