Example: Creating a Customer Master Record via an IDoc 
A model VB project
SENDIDOC.VBP for calling the BAPI_Customer_CreateFromData BAPI of the object type Customer ( KNA1 ) via an IDoc 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:
Enter
KNA1 as the BOR obejct 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 development class.The IDoc 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
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 number |
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 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.Modify the VB code. Define and generate binding
This has already been done in our example.
This means that the IDoc generated by the form was successfully sent to the R/3 System.