Example: Creating a Customer Master Record 

A model VB project ( CALLBAPI.VBP ) for calling the BAPI_Customer_CreateFromData BAPI of the object type Customer ( KNA1 ) is stored in the ...\SAPforms\Samples directory. This method is used to create a customer master record in the R/3 System.

Process Flow

To use this example, you need to carry out the following steps:

  1. Start Visual Basic and load the CALLBAPI.VBP project from the SAPforms directory.
  2. Start the SAPforms Designer as a Visual Basic add-in.

The BAPI structure is displayed in the top control. The form controls are shown in the table displayed in the bottom control. The binding is already defined and generated. The steps for Maintaining Plug-Ins and Opening a Structure and Defining and Generating a Binding, therefore, have been completed.

All of the parameters required to execute the BAPI are listed in the table below:

Name

Parameter

Values

Name

PI_ADDRESS.Name

Any

First name

PI_ADDRESS.First_Name

Any

Street

PI_ADDRESS.Street

Any

Postal code

PI_ADDRESS.Postl_Code

5-digit number

City

PI_ADDRESS.City

Any

Reference customer

PI_COPYREFERENCE.Ref_Custmr

"*"

Country

PI_ADDRESS.Country

US"*"

Language

PI_ADDRESS.Langu

US

Sales organization

PI_COPYREFERENCE.Salesorg

"*"

Division

PI_COPYREFERENCE.Division

"*"

Distribution channel

PI_COPYREFERENCE.Distr_Chan

"*"

Not all attributes are filled by the form. Instead, they are filled with initial values in the background by an import routine in VB code. These values are stored in the CUSTOMER.TXT file in the directories ..\SAPforms\Samples or ...\SAPforms\Forms. It is important that the file is in the same directory as the EXE file read for this purpose.

It concerns the data for state, reference customer sales organization, division and distribution channel ("*"). Except for state this data is system-specific and must be determined separately. In order for the example to work, you must maintain the appropriate data for your system in the file CUSTOMER.TXT . See also: Determining a Reference Customer.

  1. Test your form by choosing Run in Visual Basic or generate and start an EXE file.
  2. Enter meaningful data (see above) and choose Start. You are then logged on to your R/3 System automatically. After a short period of time, the message callbapi "The BAPI has been called successfully" is displayed.

This means that a customer master record has been successfully created in your R/3 System.