Skip to Content

Magical Function (2) of SAP Query

Query Report of PO Payment Status

Several days ago I read one thread “Re: PO wise venodr payment status” in SCN forum, let me remind that long time ago my SAP users asked me the same question –“How to get the payment status of purchase orders in SAP system?” as well. Somebodies suggested to use standard report ME80RN, but it only shows whether invoice verification of PO was done, or not? Not payment status! Because base on SAP standard process, after invoice verification is completed, the purchasing process will be regarded as closed in MM module, although the PO is really closed after FI account payable cleared. Till now I don’t find any standard report to display PO payment status. But as far as we know there are very perfect function of document management in SAP system, in the tables we must have found the data records of relationship status between PO, IV and AP clearing, so I decide to work it out by self-development.

After search tables, I found several key tables for my case, they are:
EKKO: Purchasing document header
EKPO: Purchasing document item
RSEG: Document item: Incoming invoice
BKPF: Accounting Document Header
BSAK: Accounting: Secondary Index for Vendors (Cleared Items)
From table EKKO and EKPO, we can find the PO number; if PO did invoice verification, then we can find the invoice document number with table RSEG and accounting document number of IV with table BKPF as well; at last if the AP is cleared, we will find the clearing account document number in table BSAK. With these tables, we can easily generate the report of PO payment status.

Now let’s generate the query report:

  1. In the SAP Query InfoSet create the extras as follows:

     Extras List

  2. Join these tables as follows:

    Join Tables

  3. Because table BKPF can’t be used in SAP query directly, here we should use the embedded ABAP code again in SAP Query InfoSet.
    * Concatenate IV number and fiscal year into the reference key from table RSEG;

    Get Ref Key

    * Using reference key to get the accounting document number of IV;

    Get Acc. Doc. No.

    * Check whether the AP is cleared, or not?

    Get Payment Status

  4. Get the report of PO payment status.

    Report of PO Payment Status

Hope it can help you! Good day!

You must be Logged on to comment or reply to a post.
  • Yes.. Even i find SAP query quite useful for generating reports quickly. But if the report requires several complex operations then it i find this difficult to use and go back to usual abap reports.
    • Hi Srivijaya:

      Firstly thanks for your comment, as to ABAP report, yes, ABAP report is very useful, but I can only say, not all of users have the authorization and experience to develop ABAP report. That’s reason why I would like to use query!

      Good day and best regards

  • Hi Tao,

    Thank you for the posting. I’ve a similar dilemma, I need to create a query for asset transactions using ANLA and ANLZ tables but I need to get the asset related data from BSEG because I need the financial coding associated with transaction. Any idea how I can achieve this?

    • Hi Cyrus:

      You can use the function of Extras to add one additional table with BSEG; hope it’s useful to you! But from my point of view, you had better create an ABAP report to do it!

      Good luck

      • Hi Is there is any way when you do coding for PAyment date comes in DDMMYYYY. Currently its comes as YYYYMMDD . Which we do not want.

        Many Thanks

        • Hi,

          Do you try to change the “Decimal Notation” in your user profile on tab page “Default”? Try it.

          Good luck


  • Great post Tao. I have a question though. I’m trying to pull gl texts into my sqp query(i got to bring 12 of them). It should be helpful if you can add that part to this weblog.


  • HI

    I created this query every thing is fine  BUt I couldn’t get Ccode extra . and when I create query I do not get any data where  I know we have some data .We are on ECC6 .

    many Thanks