Child pages
  • How to check if an Invoice exists over a Confirmation
Skip to end of metadata
Go to start of metadata


Purpose of this document is to provide an easy way to check if any Invoice document exists with reference to a Confirmation in a backend system.


There could be purchase orders with lots of items, and even more follow-on Confirmation documents and Invoices. When a Confirmation needs to be cancelled, existing Invoices may need to be checked. The following chapters will show two methods (A and B) how to check if an Invoice exists over a Confirmation.

Cancellation of Confirmation

Cancellation of Confirmation depends on various properties of documents which are described on Cancellation (of Confirmation) guide wiki page.

Delete/Cancel button

The purchaser wants to cancel a Confirmation, but the Delete/Cancel button is greyed out on POWL. This way Confirmation cannot be cancelled. The purchaser user should check first, if there are existing Invoices or not. For more information refer to Cancellation (of Confirmation) guide wiki page.

Important settings to check Invoice existence

Before checking Invoice existence, BUS2081 entries should be maintained in table BBP_FUNCTION_MAP according to SAP Note 2302495 (Driver functions for BUS2081)

How to check Invoice existence - Method A

Breakpoint has to be set at FORM: LBBP_PDF4H (ACTIVITY_CHECK_CF_CANCEL).
Then Confirmation has to be selected on POWL to trigger code run.

The following code section is checking whether ERS flag is set for item. If ERS is not set, then backend Invoices will be checked.

If number of Invoices (LV_INV_COUNT) are not equal to number of Credit Memos (LV_CAN_INV_COUNT) then Delete/Cancel button will be disabled on POWL. Number of Invoices are counted based on table LT_BE_POITEMHIST where existing Invoice has reference to backend Confirmation document.

Meaning of fields:

  • HIST_TYPE - 'Q' is the default value of an Invoice document
  • DB_CR_IND - 'S' is set when Invoice is created
  • DB_CR_IND - 'H' is set when Invoice is cancelled
  • LS_HEADER-BE_OBJECT_ID(10) - is the backend Confirmation document number


If LV_INV_COUNT is more than 0, then it means that table LT_BE_POITEMHIST contains an Invoice with reference to backend Confirmation. The document number of backend Invoice is stored at field LT_BE_POITEMHIST-MATDOC.

In this current case the backend Invoice number is 5105600792.

How to check Invoice existence - Method B

Breakpoint has to be set at class /SAPSRM/CL_PDO_META_BO_CONF, method GET_ACTION_DELETE_RETURN.
Then Confirmation has to be opened to trigger code run.

There is a function module META_INV_GETDETAIL that checks if an Invoice exists in backend or not.

Field LV_INV_NO contains the Invoice number which needs to be checked. If Invoice exists in backend, then LT_ITEM_DATA will be filled with data and LT_RETURN will not contain error message after META_INV_GETDETAIL has finished.

Related Content 

Related Documents

Cancellation (of Confirmation) guide

Related SAP Notes/KBAs

SAP Note: 2302495 - Driver functions for BUS2081