
Example: Creating a Customer Master Record Using an IDoc
A model Microsoft Visual Basic project
SENDIDOC.VBP for calling the BAPI_Customer_CreateFromData BAPI of the object type Customer (KNA1) using IDoc is stored in the ...\SAPforms\Samples directory. This method is used to create a customer master record in the SAP System.Process Flow
Enter
KNA1 as the object and the method Createfromdata.Enter your message type:
CustomercreateEnter
Createcust in the Partner number field.Name your port
Portcucr.Enter
$TMP (local object) as the package.The IDoc structure is displayed in the top screen area. The form controls are shown in the table displayed in the bottom screen area. The binding is already defined and generated. The steps for
Maintaining Plug-Ins and Opening a Structure and Defining and Generating a Binding have been completed.All of the segment attributes required to execute the BAPI are listed in the table below:
|
Name |
Segment Attribute |
Values |
|
Name |
E1BPKNA101000.NAME |
Any |
|
First name |
E1BPKNA101000.FIRST_NAME |
Any |
|
Street |
E1BPKNA101000.STREET |
Any |
|
Postal code |
E1BPKNA101000.POSTL_CODE |
5 digit numeric |
|
City |
E1BPKNA101000.CITY |
Any |
|
Reference customer |
E1BPKNA102000.REF_CUSTMR |
"*" |
|
Country |
E1BPKNA101000.COUNTRY |
US"*" |
|
Language |
E1BPKNA101000.LANGU |
US |
|
Sales organization |
E1BPKNA102000.SALESORG |
"*" |
|
Division |
E1BPKNA102000.DIVISION |
"*" |
|
Distribution channel |
E1BPKNA102000.DISTR_CHAN |
"*" |

Not all attributes are filled by the SAPforms form. Instead, they are filled with initial values in the background by an import routine in the source text of Microsoft Visual Basic. 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. For the example to work, you must maintain the appropriate data for your system in the file
CUSTOMER.TXT. For more information, see Determining a Reference Customer.This has already been done in our example.
This means that the IDoc generated by the SAPforms form was successfully sent to the SAP System.