Code: Alles auswählen.
TABLES: vbap, kna1.
TYPES: BEGIN OF t_wa_wagr,
matkl TYPE t023t-matkl,
wgbez TYPE t023t-wgbez,
END OF t_wa_wagr,
BEGIN OF t_wa_pos,
matnr TYPE vbap-matnr,
maktx TYPE makt-maktx,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
END OF t_wa_pos.
SELECT-OPTIONS: smatkl FOR vbap-matkl,
skunnr FOR kna1-kunnr.
DATA: wa_wagrp TYPE t_wa_wagr,
wa_pos TYPE t_wa_pos.
START-OF-SELECTION.
SELECT t023t~matkl wgbez INTO wa_wagrp
FROM t023t
INNER JOIN vbap ON t023t~matkl = vbap~matkl
WHERE t023t~matkl IN smatkl AND spras = syst-langu
GROUP BY t023t~matkl wgbez.
WRITE: / wa_wagrp-wgbez.
SELECT makt~matnr makt~maktx kna1~kunnr name1 INTO wa_pos
FROM vbap
INNER JOIN vbak ON vbap~vbeln = vbak~vbeln
INNER JOIN makt ON vbap~matnr = makt~matnr
INNER JOIN kna1 ON vbak~kunnr = kna1~kunnr
WHERE kna1~kunnr IN skunnr AND vbap~matkl = [b][color=#FF0000]wa_wagrp~matk[/color][/b].
WRITE: / wa_pos-matnr, wa_pos-maktx, wa_pos-kunnr, wa_pos-name1.
ENDSELECT.
ENDSELECT.