Function Module for vendor-payment transactions

This function module provides features that are similar to the transaction codes XK01/XK02 for maintaining payment transactions for a vendor. The user can input either the bank details or IBAN. The user can also check whether the bank (for which the transaction is to be entered) exists or not. If the bank does not exist, the user also can create it.

Description: Create, change, or delete the details of payment transactions that are defined for a vendor.

Function module name: /WINSHTLQ/TRN_VENDOR_BANK

Interface

  1. Import parameters:
    • I_CREATE_NEW_BANK Flag to check whether new Bank needs to be created in Bank Master. Allowed values are: N = No, Y = Yes, F = Force
    • I_IBAN International Bank Account Number (For Details creation or deletion)
    • I_IBAN_OLD Existing IBAN that is to be overwritten. Based on this, the row will be picked for Vendor (relevant only for Bank modification scenario for vendor)
    • I_CREATE_IBAN Flag if IBAN needs to be created in the SAP database. Allowed values are: N = No, Y = Yes. This parameter is meaningful only when the bank details are provided in the parameter I_BANKDATA (I_IBAN is not provided). If the parameter I_CREATE_IBAN is set as Y, the SAP-proposed IBAN is saved to database (if it does not exist already in SAP database).
    • I_BANKS Country for which the new bank is to be created or the existing bank is to be checked
    • I_BANKL Bank Key of which existence is to be checked, or key for new bank creation
    • I_ADDRESS Basic Address data of the bank that is mandatory to be provided (relevant only for new bank creation)
    • I_ADDRESS1 Other Address-related details of the bank (relevant only for new bank creation)
    • I_MODE Mode of FM execution as per required functionality (mandatory for all use cases)
    • I_KOART Account Type to identify vendor (to be provided as K for Vendor)
    • I_BANKDATA Bank details to be added or changed for payment transactions to an existing vendor
    • I_BANKDATA_OLD Bank details that are to be overwritten; based on this, the row will be picked for Vendor (relevant only for Bank modification scenario for vendor)
    • I_CONFIRM_CHANGES Vendor Flag (to be set as X)
    • I_CHECKMODUS Check mode for master data changes (to be passed as space)
  2. Export parameter
    • E_RETURNCODE Contains the return value after the function module is executed (relevant only for Bank addition or modification scenario for vendor). On successful execution, it is set as 0. Otherwise it is set as 4.
  3. Table parameter
    • T_MESSAGES Contains the messages (along with their types) that are returned after function module execution. Table is filled in both the cases of success or failure to provide relevant information to the user.
  4. Exceptions
    • INVALID_MODE Occurs if the user has provided the wrong entry as input for Mode of Operation
    • MANDATORY_PARAM Occurs if the user has not provided one or more parameters that are required for that particular Mode of Operation

Use cases

The following use cases are defined for this WFM. All the use cases will run independently of each other.

Case 1: Add new bank details for a vendor

This is the primary use case for this function module.

You can add new bank details for payment transactions to an existing vendor. If the bank is added successfully, the success message is returned in the interface table T_MESSAGES. If the bank could not be added, that message is returned.

If the bank does not exist, you can create it.

Create the bank

  1. To create the bank, set the parameter I_CREATE_NEW_BANK to F (Force create) or Y (Yes). The default value for this parameter is N (No). If the parameter I_CREATE_NEW_BANK is passed as Y, SAP checks whether the bank already exists. If the Bank already exists, SAP does not create it and returns a message to the user. If the Bank does not exist, it is created in Bank Master Data. If the parameter I_CREATE_NEW_BANK is passed as F, the bank is created in Bank Master without any checks being performed. If the bank already exists, SAP returns a standard error message.
  2. Enter values for the fields Bank Country (I_BANKS), Bank Key (I_BANKL) and Bank Address (I_ADDRESS). Bank Address (I_ADDRESS) must contain a valid address number.

Bank creation can also be done by populating IBAN.

Add new bank details

  1. To execute the function module, enter values for the fields Account Type (I_KOART) and bank details to be added (I_BANKDATA.
  2. For the Mode (I_MODE), enter ADD.

Example

In this example, we use the function module to add bank details for Vendor Number 15, which is displayed below by using the transaction code XK03.
For this vendor, six bank entries are maintained; the sixth entry appears further down in the grid.
Now, we execute the function module, using the data in the screen shot below, to add a new bank entry for Vendor Number 15. The bank already exists in the SAP system.
After we execute the function module, the table T_MESSAGES displays a message that indicates success.
When ;we use XK03 to view the details for Vendor Number 15, we now see seven bank entries; two of them appear further down in the grid. In the screen shot below, the second entry is the entry that we added.
Next, we create use a new bank with Number 23984899 for country DE, if the bank does not exist already (I_CREATE_NEW_BANK = Y), and we will use IBAN to add those bank details to Vendor Number 9001.

Case 2: Confirm an existing bank

You can confirm whether the bank exists in SAP by providing Bank Key and Country. If the bank exists, the relevant bank details (Bank Name, City etc.) are returned in the interface table T_MESSAGES. If the bank does not already exist, that message is returned.

  1. To execute the function module, enter values for the fields Bank Country (I_BANKS) and Bank Key (I_BANKL).
  2. For the Mode (I_MODE), enter EXIST.
When the function module is executed successfully, SAP returns the Bank Name, Number, and City in the table T_MESSAGES.

Case 3: Modify existing bank details for a vendor

You can also modify existing Bank Details for a the payment transactions of a vendor. If the details are changed successfully, the success message is returned in the interface table T_MESSAGES. If the details could not be changed, that message is returned.

If the bank does not exist, you can create it.

Create the bank

  1. To create the bank, set the parameter I_CREATE_NEW_BANK to F (Force create) or Y (Yes). The default value for this parameter is N (No). If the parameter I_CREATE_NEW_BANK is passed as Y, SAP checks whether the bank already exists. If the bank already exists, SAP does not create it and returns a message to the user. If the bank does not exist, it is created in Bank Master Data. If the parameter I_CREATE_NEW_BANK is passed as F, the bank is created in Bank Master without any checks being performed. If the bank already exists, SAP returns a standard error message.
  2. Enter values for the fields Bank Country (I_BANKS), Bank Key (I_BANKL) and Bank Address (I_ADDRESS). Bank Address (I_ADDRESS) must contain a valid address number.

Bank creation can also be done by populating IBAN.

Modify the details

  1. To execute the function module, enter values for the fields Account Type (I_KOART), Current Details (I_BANKDATA_OLD), and New Bank details (I_BANKDATA).
  2. For the Mode (I_MODE), enter CHANGE.

Example

Continuing the example from Use Case 1, we will change the Bank Account from 123456 to 123458.
Now, we execute the function module, using the data in the screen shot below, to change the Bank Account from 123456 to 123458.
After we execute the function module, the table T_MESSAGES displays a message that indicates success.
When we use XK03 to view details for Vendor Number 15, we can see that the Bank Account has been changed from 123456 to 123458.

Execution of our FM with the following data will change bank details for Vendor Number 15 by using IBAN.

A new bank with Number 23452345 will also be created for country DE, if the bank does not exist already (as I_CREATE_NEW_BANK = 'Y').

Case 4: Deletion of Existing Bank Details for Vendor

You can delete any existing Bank Details for Payment transactions by using this option. If the entry is deleted successfully, then the relevant success message is returned to user in interface table T_MESSAGES. The appropriate message is returned in case the bank entry could not be deleted because of any issue.

Mode should be entered as DELETE for this scenario.

We can execute the FM by providing fields Account Type (I_KOART), Bank details to be deleted (I_BANKDATA) & Mode (I_MODE) as input.

Example

Now, we will delete the fourth entry (with account number '123456') for Vendor Number 15.
Now, we execute our FM with the data provided below. It will delete the Bank Account 123456 for Vendor 15.
After we execute the function module, the table T_MESSAGES displays the following message.
Now, we go back to see the details for Vendor 15. We can see that the fourth entry for Country IN for Vendor no longer exists (the entry that fifth in the list is now at the fourth place).
We execute our FM with the following data to delete existing bank details from Vendor 9001 by using IBAN. The bank with Number 23984899 for country DE will be deleted for the vendor.

Examples

RFM Examples.zip