Check if invoice already exists
Hi,
I want to check if an invoice is already in the system before I can create it with an own dynpro (with reduced fields). The criteria should be vendor, comp_code, ref_doc_no_long. I still need to add the total sum.
Currently I am using the following code (but this will only identify the parked invoices):
select b~belnr into (lv_inv_no) from bkpf as b
inner join vbsegk as v
on v~belnr = b~belnr
and v~bukrs = b~bukrs
where
v~lifnr = lv_vendor_no
and b~bukrs = ls_documentheader-comp_code
and b~xblnr eq ls_documentheader-ref_doc_no_long
and b~blart in ('KD', 'NE')
.
endselect.
Can someone make a suggestion which tables I need to check for the posted documents and the logistic (parked) invoices?
Is it correct to check also the XREVERSAL field and select only those that are empty (and not 1 or 2)?
Regards,
Vanessa