cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP Create Customers and vendors

ILIAN_Grigorov
Contributor
0 Kudos
1,004

Hello, 

I am looking for a way to create customers and vendors from ABAP code, and assign to Company Code, in a legacy EPR system (not S4), and BP concept is not activated.

I guess inserting records in LFA1/LFB1 and KNA1/KNB1 is not a good approach.

Is there an ABAP function to do that? I cannot find anything in Google.

Thanks, ILIAN

Accepted Solutions (1)

Accepted Solutions (1)

RaymondGiuseppi
Active Contributor

Are the VMD_EI_API and CMD_EI_API classes already available in your version (?)

Else look at LSMW

  • objects 0040 and 0050 (report to create BDC)
  • Reorded Batch input
  • IDOC CREMAS, DEBMAS (+ADRMAS)
ILIAN_Grigorov
Contributor

Thanks for the reply. It seems the proper way to do it. It seems you have to ask for the next available number (lifnr/kunnr) - https://community.sap.com/t5/enterprise-resource-planning-q-a/problem-creating-vendor-with-vmd-ei-ap... - the functionality does not get it for you.

I also found this approach - https://gist.github.com/weiserman/8414651 - seems nice.

RaymondGiuseppi
Active Contributor
0 Kudos
There is a metho to get next number: e.g. CMD_EI_API=>GET_NUMBER (once no error in test mode)

Answers (2)

Answers (2)

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert

Have you tried API classes?

  • VMD_EI_API - for Vendors
  • CMD_EI_API - for Customers
0 Kudos

You’re absolutely right — directly inserting records into tables like LFA1, LFB1, KNA1, and KNB1 is strongly discouraged because SAP enforces a variety of validations and dependencies that ensure data consistency and integrity. Instead, you should use standard BAPIs or FMs that handle this process while maintaining the necessary checks.

Creating Vendors

Use the following BAPIs to create or update vendors:

  • BAPI_VENDOR_CREATE: Create a new vendor.
  • BAPI_VENDOR_EDIT: Update an existing vendor.

Creating Customers

Use the following BAPIs to create or update customers:

  • BAPI_CUSTOMER_CREATE: Create a new customer.
  • BAPI_CUSTOMER_CHANGE: Update an existing customer.

Alternatives in Legacy Systems

For legacy systems without the BP concept, this method is unavailable. Instead, you must rely on:

  1. Standard BAPIs like:
    • BAPI_VENDOR_CREATE
    • BAPI_VENDOR_CHANGE
    • BAPI_VENDOR_GETDETAIL
  2. Batch Input Sessions using BDC programs for mass updates.
  3. Custom Programs built around database updates with extreme caution.

The VMD_EI_API=>MAINTAIN_BAPI method is a class-based API introduced to simplify vendor master data handling. However, it’s part of the Vendor Master Data (VMD) API framework and primarily used in S/4HANA environments. Since your system doesn't support the BP concept and you’re working in a legacy system, this might not be applicable.

 

RaymondGiuseppi
Active Contributor
0 Kudos
Warning: Those "BAPI" : BAPI_VENDOR_CREATE, BAPI_CUSTOMER_CREATE are just wrapper of transactions