This Blog will clearly Explains that, Creation of Customer Master Record Using this Class : CMD_EI_API.
Generally for Customer Master Creation, we use BAPI's like BAPI_CUSTOMER_CREATEFROMDATA1 or BAPI_CUSTOMER_CREATEFROMDATA
But in all these Bapi's we need Customer Reference Number from one of the structure..
Mainly this Document is to create customer record, Without using Customer Reference Number..
Please follow some below steps, here I have created in SE38 report program..
Program in SE38 :
*&---------------------------------------------------------------------*
*& REPORT ZCUST_CR
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZCUST_CR3.
*
TYPES : BEGINOF TY_XML ,
RAW(2000) TYPEC,
ENDOF TY_XML.
TYPES : BEGINOF TY_FILE,
FILE TYPE STRING,
ENDOF TY_FILE.
TYPES : BEGINOF TY_KUNNR,
KUNNR TYPE KNA1-KUNNR,
ENDOF TY_KUNNR.
DATA : IT_KUNNR TYPETABLEOF TY_KUNNR,
WA_KUNNR TYPE TY_KUNNR.
DATA : WA_VAT_NUMBER TYPE CVIS_EI_VAT_NUMBERS,
WA_VAT_T TYPE CVIS_EI_VAT_T,
WA_VAT TYPE CVIS_EI_VAT,
WA_PHONE TYPE CVIS_EI_CVI_PHONE,
WA_PH_T TYPE CVIS_EI_PHONE_T,
WA_PH_PH TYPE CVIS_EI_PHONE_STR,
WA_FAX TYPE CVIS_EI_CVI_FAX,
WA_FX_T TYPE CVIS_EI_FAX_T,
WA_FX_FX TYPE CVIS_EI_FAX_STR,
WA_SM_SMTP TYPE CVIS_EI_SMTP_STR,
WA_SMTP_T TYPE CVIS_EI_SMTP_T,
WA_SMTP TYPE CVIS_EI_CVI_SMTP.
DATA : WA_HEADER TYPE CMDS_EI_HEADER,
WA_CENTRAL_DATA TYPE CMDS_EI_VMD_CENTRAL_DATA,
WA_CENTRAL_DATAX TYPE CMDS_EI_VMD_CENTRAL_DATA_XFLAG,
WA_ADDRESS TYPE BAPIAD1VL,
WA_ADDRESSX TYPE BAPIAD1VLX,
WA_TAX_IND_ST TYPE CMDS_EI_TAX_IND,
WA_TAX_IND TYPE CMDS_EI_CMD_TAX_IND,
WA_BANKDETAIL_ST TYPE CVIS_EI_CVI_BANKDETAIL,
WA_BANKDETAIL TYPE CVIS_EI_BANKDETAIL,
WA_COMPANY_CODE_ST TYPE CMDS_EI_COMPANY,
WA_COMPANY_CODE TYPE CMDS_EI_CMD_COMPANY,
WA_CUSTOMER TYPE CMDS_EI_EXTERN,
WA_CUSTOMERS TYPE CMDS_EI_MAIN,
WA_CORRECT TYPE CMDS_EI_MAIN,
WA_DEFECTIVE TYPE CMDS_EI_MAIN,
WA_MES_CORRECT TYPE CVIS_MESSAGE,
WA_MES_ERROR TYPE CVIS_MESSAGE.
DATA : EMAIL_SMTP TYPE CVIS_EI_SMTP_T. """"EMAIL CONTACT ---
DATA : EMAIL TYPE CVIS_EI_SMTP_STR,
CONTACT TYPE CVIS_EI_SMTP.
DATA : IT_PHONE TYPE CVIS_EI_PHONE_T, """PHONE AND FAX
WAA_PHONE TYPE CVIS_EI_PHONE_STR,
PH_CONTACT TYPE CVIS_EI_PHONE.
DATA : IT_FAX TYPE CVIS_EI_FAX_T,
WAA_FAX TYPE CVIS_EI_FAX_STR,
FAX_CONTACT TYPE CVIS_EI_FAX.
DATA : IT_CONT_PERSON TYPE CMDS_EI_CONTACTS_T, """*WA_CUSTOMER - - DATA
WA_CONT TYPE CMDS_EI_CONTACTS.
DATA : IT_PHONE_CONT TYPE CVIS_EI_PHONE_T.
DATA: WA_FUNCTIONS_ST TYPE CMDS_EI_FUNCTIONS, """"""SALES MANDATORY FIELDS
WA_FUNCTIONS_T TYPE CMDS_EI_FUNCTIONS_T,
WA_FUNCTIONS TYPE CMDS_EI_FUNCTIONS_T,
WA_SALES_DATA_ST TYPE CMDS_EI_SALES,
WA_SALES_DATA TYPE CMDS_EI_CMD_SALES,
IT_SALES TYPE CMDS_EI_SALES_T,
WA_DATA TYPE CMDS_EI_SALES_DATA.
DATA : IT_MESSAGE TYPE BAPIRET2_T, """ERROR MESSAGES
WA_MESS TYPE BAPIRET2.
DATA : CUST TYPE CMDS_EI_MAIN, """CUSTOMER RELATED
KUNNR_CUST TYPE CMDS_EI_EXTERN_T,
WA_KUN LIKELINEOF KUNNR_CUST,
* WA_KUN LIKE LINE OF CMDS_EI_EXTERN,
WA_CUST TYPE CMDS_EI_EXTERN,
WA_CUSTON LIKELINEOF WA_CORRECT-CUSTOMERS,
LV_KUNNR TYPE KUNNR.
DATA : LV_STRING TYPE STRING. """DISPLAY IN ALV
DATA : GT_OUTTAB TYPETABLEOF SFLIGHT.
DATA : GR_TABLE TYPEREFTO CL_SALV_TABLE.
CONSTANTS : C_UPDATE TYPECVALUE'M',
C_INSERT TYPECVALUE'I'.
DATA : V_FILE TYPE STRING,
G_STR TYPE STRING,
XSTRING TYPE XSTRING.
DATA : IT_XML_INFO TYPETABLEOF SMUM_XMLTB WITHHEADERLINE,
WA_XML_INFO LIKELINEOF IT_XML_INFO,
RETURN TYPESTANDARDTABLEOF BAPIRET2 .
DATA : IT_XML_TAB TYPETABLEOF TY_XML,
WA_XML_TAB LIKELINEOF IT_XML_TAB.
DATA : LT_TABLE TYPESTANDARDTABLEOF EPSFILI,"FILE_INFO,
LS_TABLE TYPE EPSFILI,"FILE_INFO,
LT_FINAL TYPESTANDARDTABLEOF TY_FILE,
L_COUNT TYPEI,
L_DIRNAME TYPE EPSF-EPSDIRNAM,
L_FILE_LIST TYPETABLEOF EPSFILI."RSFILLST
CLEAR LS_TABLE.
START-OF-SELECTION.
*PARAMETERS: P_TEST TYPE C AS CHECKBOX DEFAULT 'X'.
* A "CUSTOMER" IS MADE UP OF 4 MAIN SECTIONS
* 1. HEADER
* 2. CENTRAL_DATA
* 3. COMPANY_DATA
* 4 SALES_DATA
FREE: WA_CUSTOMER, WA_COMPANY_CODE_ST, WA_CUSTOMER.
WA_ADDRESS-TITLE = '0002.'.
WA_ADDRESS-NAME = 'SHANTHAN'.
WA_ADDRESS-CITY = 'BANGALORE'.
* WA_ADDRESS-POSTL_COD1 = '505001'. ""COMNT
* WA_ADDRESS-STREET = 'SBM COLONY'. ""COMNT
WA_ADDRESS-COUNTRY = 'IN'.
WA_ADDRESS-LANGU = 'EN'.
* WA_ADDRESS-REGION = '05'. """COMNT
WA_ADDRESS-SORT1 = 'REDDY'.
* WA_ADDRESS-SORT2 = ''.
* WA_ADDRESS-TAXJURCODE = 'FL0000000'.
* WA_ADDRESS-TIME_ZONE = 'UTC-6'.
***
*WA_COMPANY_CODE_ST-DATA-AKONT = '23203110'.
CALLFUNCTION'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = '142000'
IMPORTING
OUTPUT = WA_COMPANY_CODE_ST-DATA-AKONT.
* WA_COMPANY_CODE_ST-DATA-ZTERM = '0001'.
WA_COMPANY_CODE_ST-DATA_KEY-BUKRS = '3000'.
WA_CUSTOMER-CENTRAL_DATA-ADDRESS-POSTAL-DATA = WA_ADDRESS.
WA_CUSTOMER-CENTRAL_DATA-ADDRESS-POSTAL-DATAX = WA_ADDRESSX.
WA_COMPANY_CODE_ST-TASK = C_INSERT.
APPEND WA_COMPANY_CODE_ST TO WA_COMPANY_CODE-COMPANY.
**********************************************************************************************SALES ORG AND DIST & DIVISION MANDATORY FIELDS
WA_CUSTOMER-SALES_DATA-CURRENT_STATE = 'X'.
WA_SALES_DATA_ST-DATA_KEY-VKORG = '3000'.
WA_SALES_DATA_ST-DATA_KEY-VTWEG = '12'.
WA_SALES_DATA_ST-DATA_KEY-SPART = '00'.
*WA_DATA-ZTERM = '0001'. """BELOW COMNT
WA_DATA-KALKS = '1'.
*WA_DATA-VERSG = '1'.
WA_DATA-VSBED = '02'.
*WA_DATA-INCO1 = 'AIR'.
*WA_DATA-INCO2 = 'INCOTERMS2'.
WA_DATA-WAERS = 'INR'.
*WA_DATA-AUFSD = '01'.
WA_SALES_DATA_ST-DATA = WA_DATA.
WA_FUNCTIONS_ST-DATA_KEY-PARVW = 'AG'.
WA_FUNCTIONS_ST-DATA-DEFPA = 'X'.
WA_FUNCTIONS_ST-DATA-PARTNER = WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR."'INTERNAL'.
APPEND WA_FUNCTIONS_ST TO WA_FUNCTIONS_T.
CLEAR: WA_FUNCTIONS_ST.
WA_FUNCTIONS_ST-DATA_KEY-PARVW = 'RE'.
WA_FUNCTIONS_ST-DATA-DEFPA = 'X'.
WA_FUNCTIONS_ST-DATA-PARTNER = WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR."'INTERNAL'.
APPEND WA_FUNCTIONS_ST TO WA_FUNCTIONS_T.
CLEAR: WA_FUNCTIONS_ST.
WA_FUNCTIONS_ST-DATA_KEY-PARVW = 'RG'.
WA_FUNCTIONS_ST-DATA-DEFPA = 'X'.
WA_FUNCTIONS_ST-DATA-PARTNER = WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR."'INTERNAL'.
APPEND WA_FUNCTIONS_ST TO WA_FUNCTIONS_T.
CLEAR: WA_FUNCTIONS_ST.
WA_FUNCTIONS_ST-DATA_KEY-PARVW = 'WE'.
WA_FUNCTIONS_ST-DATA-DEFPA = 'X'.
WA_FUNCTIONS_ST-DATA-PARTNER = WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR."'INTERNAL'.
APPEND WA_FUNCTIONS_ST TO WA_FUNCTIONS_T.
CLEAR: WA_FUNCTIONS_ST.
WA_SALES_DATA_ST-FUNCTIONS-CURRENT_STATE = 'X'.
WA_SALES_DATA_ST-FUNCTIONS-FUNCTIONS = WA_FUNCTIONS_T.
APPEND WA_SALES_DATA_ST TO IT_SALES.
WA_CUSTOMER-SALES_DATA-SALES = IT_SALES.
***********************************************************************************************************************************
** ACCOUNT ACCOUNT GROUP DIRECTLY
WA_CUSTOMER-CENTRAL_DATA-CENTRAL-DATA-KTOKD = 'ZARG'.
WA_CUSTOMER-HEADER-OBJECT_INSTANCE-KUNNR = ' '.
WA_CUSTOMER-HEADER-OBJECT_TASK = C_INSERT.
WA_CUSTOMER-COMPANY_DATA = WA_COMPANY_CODE.
APPEND WA_CUSTOMER TO WA_CUSTOMERS-CUSTOMERS.
CALLMETHOD CMD_EI_API=>MAINTAIN_BAPI
EXPORTING
IV_TEST_RUN = ''
IV_COLLECT_MESSAGES = 'X'
IS_MASTER_DATA = WA_CUSTOMERS
IMPORTING
ES_MASTER_DATA_CORRECT = WA_CORRECT
ES_MESSAGE_CORRECT = WA_MES_CORRECT
ES_MASTER_DATA_DEFECTIVE = WA_DEFECTIVE
ES_MESSAGE_DEFECTIVE = WA_MES_ERROR.
IF WA_MES_ERROR-IS_ERROR ISINITIAL.
CALLFUNCTION'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
.
"""""IF CUTOMER IS CREATED : DISPLAY CUSTOMER NUMBER :: CUSTOMER RELATED
LOOPAT WA_CORRECT-CUSTOMERS INTO WA_CUSTON.
WA_KUNNR-KUNNR = WA_CUSTON-HEADER-OBJECT_INSTANCE-KUNNR .
APPEND WA_KUNNR TO IT_KUNNR.
CLEAR : WA_KUNNR.
ENDLOOP.
*... CREATE INSTANCE
CALLMETHOD CL_SALV_TABLE=>FACTORY
IMPORTING
R_SALV_TABLE = GR_TABLE
CHANGING
T_TABLE = IT_KUNNR.
*... DISPLAY TABLE
GR_TABLE->DISPLAY( ).
ELSE. """"SHOW ERROR MESSAGES
*... CREATE INSTANCE
CALLMETHOD CL_SALV_TABLE=>FACTORY
IMPORTING
R_SALV_TABLE = GR_TABLE
CHANGING
T_TABLE = WA_MES_ERROR-MESSAGES.
*... DISPLAY TABLE
GR_TABLE->DISPLAY( ).
ENDIF.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''AFTER SUCCESSFUL EXECUTION THE OUT PUT SCREEN IS LIKE BELOW
Hope this helps.
Thanks & Regards
Shanthan Reddy