Code: Alles auswählen.
CLEAR lt_mbew.
SELECT matnr vprsv verpr stprs FROM mbew INTO CORRESPONDING FIELDS OF ls_preis
WHERE matnr IN so_matnr
AND bwkey IN so_werks.
IF ls_preis-vprsv = 'S'.
ls_preis-preis = ls_preis-stprs.
ELSEIF ls_preis-vprsv = 'V'.
ls_preis-preis = ls_preis-verpr.
ENDIF.
APPEND ls_preis TO lt_preis.
ENDSELECT.
CLEAR lt_outtab.
SELECT
a~matnr,
a~werks,
a~ekgrp,
b~matkl,
b~mtart,
b~meins,
c~maktx,
d~lbkum,
f~preis
FROM marc AS a
INNER JOIN mara AS b
ON a~matnr = b~matnr
INNER JOIN makt AS c
ON a~matnr = c~matnr
INNER JOIN mbew AS d
ON a~matnr = d~matnr
AND a~werks = d~bwkey
INNER JOIN @lt_preis AS f
ON a~matnr = f~matnr
WHERE a~matnr IN @so_matnr
AND a~werks IN @so_werks
AND a~ekgrp IN @so_ekgrp
AND b~matkl IN @so_matkl
AND b~mtart IN @so_mtart
AND c~spras = @sy-langu
INTO CORRESPONDING FIELDS OF TABLE @lt_outtab.
LOOP AT lt_outtab INTO ls_outtab.
SELECT MAX( netpr ) INTO @DATA(lv_netpr)
FROM ekpo
WHERE matnr = @ls_outtab-matnr
AND werks = @ls_outtab-werks.
ls_outtab-netpr = lv_netpr.
SELECT SINGLE * FROM ekpo INTO ls_ekpo
WHERE matnr = ls_outtab-matnr
AND werks = ls_outtab-werks
AND netpr = lv_netpr.
ls_outtab-peinh = ls_ekpo-peinh.
MODIFY lt_outtab FROM ls_outtab.
ENDLOOP.
LOOP AT lt_outtab INTO ls_outtab.
SELECT SINGLE * INTO @DATA(ls_salk)
FROM mbew
WHERE matnr = @ls_outtab-matnr
AND bwkey = @ls_outtab-werks.
ls_outtab-salk3 = ls_salk-salk3.
MODIFY lt_outtab FROM ls_outtab.
ENDLOOP.
LOOP AT lt_outtab INTO ls_outtab.
LOOP AT lt_rdate INTO ls_rdate.
CLEAR: lv_requr, lv_aquis, lv_eomstk, lv_salk.
SELECT SINGLE * FROM mdkp INTO ls_mdkp
WHERE matnr = ls_outtab-matnr
AND plwrk = ls_outtab-werks.
lv_dtnum = ls_mdkp-dtnum.
PERFORM calculate-plumi.
SELECT * INTO TABLE lt_mdkpdb FROM mdkpdb
WHERE matnr = ls_outtab-matnr
AND plwrk = ls_outtab-werks.
LOOP AT lt_mdkpdb INTO ls_mdkpdb.
lv_dtnum = ls_mdkpdb-dtnum.
PERFORM calculate-plumi.
ENDLOOP.
ls_outtab-requr = lv_requr.
ls_outtab-aquis = lv_aquis.
PERFORM calculate_month_year.
ls_outtab-period = lv_date.
PERFORM get_eomstk.
ls_outtab-eomstk = lv_eomstk.
PERFORM salk.
ls_outtab-salk3 = lv_salk.
ls_outtab-lbkum = 0.
INSERT ls_outtab INTO lt_outtab.
ENDLOOP.
ENDLOOP.
SORT: lt_outtab BY matnr.
Code: Alles auswählen.
INTO ls_outtab
Code: Alles auswählen.
LOOP AT lt_outtab ASSIGNING FIELD-SYMBOL(<fs_outtab>)