cancel
Showing results for 
Search instead for 
Did you mean: 

Cancelling sales orders for unpaid invoices

Former Member
0 Kudos

I have a requirement to get the list of all unpaid invoices and then cancel billing documents. For this, what is the link between SD tables and FI tables to get the information of all unpaid invoices? Any help is appreciated.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

By invoice you can check to table BKPF with invoice number is store in BKPF-AWKEY and System ID store in BKPF-AWSYS. with this you'll have no performance issue.

With selection result, check whether the document is in BSAD table, If yes, it's mean the invoice is paid(cleared document).

check payment document to BSID table with BKPF-belnr and bkpfp-gjahr. for detail getting payment.

WHERE BUKRS EQ BKPF-BUKRS

AND KUNNR EQ Custno

AND UMSKS EQ SPACE AND UMSKZ EQ SPACE

AND GSBER EQ BKPF-GSBER

AND REBZZ EQ BSEG-BUZEI AND REBZG EQ BKPF-BELNR AND BLART =(doc type of payment doc)

Former Member
0 Kudos

Thanks Marti and Hengky. It was great help.

mvoros
Active Contributor
0 Kudos

Hi,

in the table BSEG, there are fields VBEL2 and POSN2. These two fields should point to item of the sales document. So you need to select all your unpaid invoices from the tables BKPF - header and BSEG - items. Then use these two fields to find corresponding sales documents. A reading from the tables BKPF and BSEG is usually very slow, so maybe it will be better to use secondary index tables such as BSIS/BSAS.

Cheers