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
- 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)
- 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.
- 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.
- 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
- 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.
- 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
- To execute the function module, enter values for the fields Account Type (I_KOART) and bank details to be added (I_BANKDATA.
- For the Mode (I_MODE), enter ADD.
Example
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.
- To execute the function module, enter values for the fields Bank Country (I_BANKS) and Bank Key (I_BANKL).
- For the Mode (I_MODE), enter EXIST.
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
- 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.
- 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
- 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).
- For the Mode (I_MODE), enter CHANGE.
Example
Execution of our FM with the following data will change bank details for Vendor Number 15 by using IBAN.
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
Examples