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 : BEGIN OF TY_XML ,

          RAW(2000) TYPE C,

         END OF TY_XML.

TYPES : BEGIN OF TY_FILE,

           FILE TYPE STRING,

         END OF TY_FILE.

TYPES : BEGIN OF TY_KUNNR,

           KUNNR TYPE KNA1-KUNNR,

         END OF TY_KUNNR.

DATA : IT_KUNNR TYPE TABLE OF 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 LIKE LINE OF KUNNR_CUST,

*      WA_KUN LIKE LINE OF CMDS_EI_EXTERN,

        WA_CUST TYPE CMDS_EI_EXTERN,

        WA_CUSTON LIKE LINE OF WA_CORRECT-CUSTOMERS,

        LV_KUNNR TYPE KUNNR.

DATA : LV_STRING TYPE STRING.                         “””DISPLAY IN ALV

DATA : GT_OUTTAB TYPE TABLE OF SFLIGHT.

DATA : GR_TABLE TYPE REF TO CL_SALV_TABLE.

CONSTANTS : C_UPDATE TYPE C VALUE ‘M’,

             C_INSERT TYPE C VALUE ‘I’.

DATA : V_FILE  TYPE STRING,

        G_STR   TYPE STRING,

        XSTRING TYPE XSTRING.

DATA : IT_XML_INFO TYPE TABLE OF SMUM_XMLTB WITH HEADER LINE,

        WA_XML_INFO LIKE LINE OF IT_XML_INFO,

        RETURN  TYPE STANDARD TABLE OF BAPIRET2 .

DATA : IT_XML_TAB TYPE TABLE OF TY_XML,

        WA_XML_TAB LIKE LINE OF IT_XML_TAB.

DATA : LT_TABLE TYPE STANDARD TABLE OF EPSFILI,“FILE_INFO,

        LS_TABLE TYPE EPSFILI,“FILE_INFO,

        LT_FINAL TYPE STANDARD TABLE OF TY_FILE,

        L_COUNT TYPE I,

        L_DIRNAME TYPE   EPSF-EPSDIRNAM,

        L_FILE_LIST TYPE TABLE OF 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’.

   CALL FUNCTION ‘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.

   CALL METHOD 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 IS INITIAL.

     CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’

      EXPORTING

        WAIT          = ‘X’

*     IMPORTING

*       RETURN        =

               .

“””””IF CUTOMER IS CREATED : DISPLAY CUSTOMER NUMBER  :: CUSTOMER RELATED

LOOP AT 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

    CALL METHOD 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

    CALL METHOD 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

CUSTIMG.png

Hope this helps.


Thanks & Regards


Shanthan Reddy

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Simone Milesi

    Sounds great!

    Just a question: you already checked how to maintain CUSTOM FIELDS (i.e. KNA1-ZZFIELD1 or KNVV-ZZFIELD2)?

    i’m checking the methods (quickly i admit) and i do not find how to manage them.

    (0) 
    1. Shanthan Reddy Post author

      Hii Simon,

      actually the requirement is based on below criteria

      I have used mainly 4 sections in class :  CMD_EI_API


        1. HEADER

        2. CENTRAL_DATA

        3. COMPANY_DATA

        4. SALES_DATA

      so, if we check with in the class, i think we can maintain those fields also

      in the current blog, I have not used CUSTOM FIELDS  like (i.e. KNA1-ZZFIELD1 or KNVV-ZZFIELD2)

      Thank  You..

      (0) 
  2. Narendra Patel

    Hi Shanthan Reddy ,


    I am using method MAINTAIN_BAPI with TASK = ‘I’ for creating new customer.But the problem is method is always generate new number even if error is there.


    Do you know solution for that?

    (0) 
  3. SATHVIK SINHA

    Hi guys i want to know some more details about this document .

    could u please can any1 help me???

    When i copy paste this document, the output is coming as shown in above screen shot.

    But what is the main advantage of using this method???

    plz explain indetail…

    (0) 
  4. Pratiksha Chhipa

    Hello all,

              I Copied and pasted code in program , but when i execute , below error display

         Kindly check ,

         and give solution of it.

    (0) 
    1. Simone Milesi

      Please, check the error log! It says clearly that some mandatory data is missing (Partner Role in this case).

      Just provide it to get rid of the error.

      What kind of solution you want?

      (0) 

Leave a Reply