Modifying Payment Block in SAP MIRO transaction using code?

Hi everyone,

I’m working on a project where we need to update the payment block in the MIRO transaction. I was wondering if there’s a way to do this programmatically.

Does anyone know if SAP provides any BAPIs or function modules that can handle this? Or maybe there’s a way to write custom ABAP code to achieve this?

I’ve been looking through the SAP documentation, but I’m not finding anything specific to this use case. Any tips or examples would be really helpful!

Thanks in advance for your help!

As someone who’s worked extensively with SAP MIRO, I can tell you that modifying the payment block programmatically is definitely possible. In my experience, the most reliable method is using the BAPI_INCOMINGINVOICE_CHANGE function module.

This BAPI allows you to update various fields in an existing invoice, including the payment block. You’ll need to pass the invoice document number, fiscal year, and the new payment block code as parameters.

Here’s a basic structure I’ve used:

CALL FUNCTION 'BAPI_INCOMINGINVOICE_CHANGE'
  EXPORTING
    invoicedocnumber = l_invoice_doc
    fiscalyear       = l_fiscal_year
    paymentblock     = l_new_block
  TABLES
    return           = lt_return.

Remember to handle the return table for any error messages. Also, don’t forget to call BAPI_TRANSACTION_COMMIT after successful execution.

This approach has worked well for me in several projects. Just make sure you have the necessary authorization to modify invoices in your SAP system.