Правильно, в BSEG поле EBELN не заполнено, потому что согласно ноте
Note 152335 - Field EBELN in line layout variant for cust./vendor
Quote:
Since Release 3.0, several purchase orders can be offset in one invoice. As a result, different purchasing document numbers (BSEG-EBELN) can be contained in the different G/L account line items.
Попробуйте использовать таблицу история докуметов закупок EKBE.
Code:
DATA: lt_ekbe TYPE TABLE OF ekbe,
ls_ekbe TYPE ekbe.
DATA: l_awkey TYPE bkpf-awkey,
l_awtyp TYPE bkpf-awtyp.
DATA: BEGIN OF lt_doc OCCURS 0,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
gjahr TYPE bkpf-gjahr,
END OF lt_doc.
PARAMETERS: p_ebeln TYPE ekko-ebeln.
SELECT belnr gjahr
FROM ekbe
INTO TABLE lt_ekbe
WHERE ebeln = p_ebeln
AND vgabe IN ('1', '2'). "1 - GR, 2 - IR
CHECK sy-subrc = 0.
SORT lt_ekbe.
DELETE ADJACENT DUPLICATES FROM lt_ekbe.
LOOP AT lt_ekbe INTO ls_ekbe.
l_awkey+00(10) = ls_ekbe-belnr.
l_awkey+10(10) = ls_ekbe-gjahr. "BELNR+YEAR
* Uses index BKPF~4 (4.7)
SELECT SINGLE bukrs belnr gjahr "Accounting Doc Header
FROM bkpf
INTO lt_doc
WHERE awtyp = l_awtyp
AND awkey = l_awkey.
IF sy-subrc = 0.
APPEND lt_doc.
ENDIF.
ENDLOOP.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.