BAPI For Vendor matchcode

Hello Dear folks, If you are looking for BAPI of Vendor matchcode | BAPI for Vendor matchcode | BAPI Vendor matchcode Tutorial Step by Step in SAP ABAP | List of BAPIs for Vendor matchcode | What is the BAPI to Vendor matchcode then you will get all the details here in this blog post.

BAPI_CREDITOR_FIND is a standard SAP Business Application Programming Interface (BAPI) used to search for vendors (creditors) based on various search criteria such as vendor number, name, tax number, or other key identifiers. This BAPI is particularly useful in scenarios where you need to dynamically retrieve vendor information without knowing the exact vendor number, making it ideal for lookup functionalities in custom SAP applications or interfaces.

Key Features of BAPI_CREDITOR_FIND

  1. Flexible Search Criteria – Allows searching by vendor number, name, tax ID, postal code, and more.
  2. Multiple Output Options – Returns a list of matching vendors with key details.
  3. Pagination Support – Can limit the number of results returned for performance optimization.
  4. Integration-Friendly – Works well in custom ABAP programs, Fiori apps, and middleware integrations.

Technical Details

Input Parameters

ParameterDescription
SEARCH_TERMGeneral search term (e.g., vendor name or partial number)
MAX_ROWSMaximum number of results to return (prevents excessive data retrieval)
COMPANYCODEFilters vendors by company code
POSTALCODESearches by postal code
CITYSearches by city
TAX_NUMBERSearches by tax identification number

Output Structure

The BAPI returns a table CREDITOR_LIST containing:

FieldDescription
CREDITORVendor account number
NAMEVendor name
CITYVendor city
POSTAL_CODEPostal code
STREETStreet address
COUNTRYCountry code
TAX_NUMBERTax identification number

Additionally, the RETURN parameter provides status messages (success/error).

Common Use Cases

  1. Vendor Search in Custom Transactions – Enables users to search for vendors in custom ABAP reports or dialog programs.
  2. Data Migration & Validation – Helps verify vendor data during migration projects.
  3. Integration with External Systems – Used in middleware (e.g., SAP PI/PO, CPI) to fetch vendor details.
  4. Fiori Apps & Web Services – Supports vendor lookups in SAPUI5 or REST APIs.

ABAP Code Example BAPI_CREDITOR_FIND

Below is a sample ABAP program demonstrating how to use BAPI_CREDITOR_FIND:

REPORT Z_VENDOR_SEARCH.

DATA:  
  lt_creditor_list TYPE TABLE OF BAPI_CREDITOR_FIND_LIST,  
  ls_creditor     TYPE BAPI_CREDITOR_FIND_LIST,  
  ls_return       TYPE BAPIRET2,  
  lv_max_rows     TYPE I VALUE 100.  

PARAMETERS: p_search TYPE STRING LOWER CASE DEFAULT '*'.  

START-OF-SELECTION.  

  CALL FUNCTION 'BAPI_CREDITOR_FIND'  
    EXPORTING  
      SEARCH_TERM = p_search  
      MAX_ROWS    = lv_max_rows  
    IMPORTING  
      RETURN      = ls_return  
    TABLES  
      CREDITOR_LIST = lt_creditor_list.  

  IF ls_return-type = 'E'.  
    WRITE: / 'Error:', ls_return-message.  
  ELSE.  
    IF lt_creditor_list IS INITIAL.  
      WRITE: / 'No vendors found matching the search criteria.'.
    ELSE.  
      LOOP AT lt_creditor_list INTO ls_creditor.  
        WRITE: /  
          'Vendor:', ls_creditor-CREDITOR,  
          'Name:', ls_creditor-NAME,  
          'City:', ls_creditor-CITY,  
          'Country:', ls_creditor-COUNTRY.  
      ENDLOOP.  
    ENDIF.  
  ENDIF.  

Explanation of the Code:

  1. Input Handling – The program accepts a search term (p_search) which can be a partial vendor name or number.
  2. BAPI Call – Executes BAPI_CREDITOR_FIND with the search term and a row limit.
  3. Output Handling – Displays vendor details if found, or an error message if no results are available.

BAPI_CREDITOR_FIND is a powerful tool for vendor lookups in SAP, enabling dynamic searches based on various criteria. By integrating it into custom ABAP programs or interfaces, businesses can enhance user experience and streamline vendor data retrieval.

Leave a Comment