Skip to Content
0

How to maintain Customer Master Sales data through Class Method CMI_EI_API=>Maintain_bapi?

Feb 03 at 10:20 AM

71

avatar image
Former Member

I am required to upload customer master data through BP Tcode via bdc program.
I am using FM BAPI_BUPA_FS_CREATE_FROM_DATA2 to create customer and then adding Tax Information through BUPA_TAX_ADD.
However while entering sales data through

CMI_EI_API=>Maintain_bapi

iam getting error in es_error table that has Message :'field Task:value : '' ' not permitted. Kindly help


Also I just want to add sales data without changing any other data in earlier created data through FM, that is why I am not setting task value to either I/U or M.

*&---------------------------------------------------------------------*

*& Report ZBDC_BP

*&---------------------------------------------------------------------*

*&

*&---------------------------------------------------------------------*

REPORT ZBDC_BP.

types:begin of ty_file,

srno type char10,     "Serial Number

  role type char4,    "Customer Role

  old_no type char10, "Old Customer Number

  new type char6,     "New Customer Number

  name type char40,   "Name of Customer

  search type char20, "Serach Term for Customer-

  street type char80, "Street Address

  pcode type char6,    "Postal Code

  city type char10,   "City for Customer

  country type char2, "Country

  state type char2,   "State Code

  spras type char2,   "Language

  taxc type char3,    "Tax Category

  gst type char15,    "GST Number

  code type char4,    "Company Code

  recon type char4,   "Reconcilliation Account

  sorg type char4,    "SAles Org

  dist type char2,    "Distribution Channel

  div type char2,     "Division

  sdist type char6,   "Sales District

  soff type char4,    "Sales Office

  sgrp type char3,    "Sales Group

  pgrp type char2,    "Price Group

  pptoc type char1,   "Customer Pricing Procedure

  del type char12,     "Delvery Priority

  ship type char20,

  incoterm type char10,"Incoterms

  Incloc type char10,  "Incoterm Location

  pterm type char14,   "Payment Terms

  cca type char9,     "Credit Control Area

  acct type char9,    "Account Assignment Group



  end of ty_file.



  data:

        it_file type TABLE OF ty_file,

        wa_file type ty_file,

        it_fcat type SLIS_T_FIELDCAT_ALV,

        wa_fcat type SLIS_FIELDCAT_ALV,

        it_raw type TRUXS_T_TEXT_DATA,



        file type IBIPPARMS-PATH.



  SELECTION-SCREEN:BEGIN OF block a WITH FRAME .

    PARAMETERS p_file type rlgrap-FILENAME OBLIGATORY.

    SELECTION-SCREEN:end of block a.





    at SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.



      CALL FUNCTION 'F4_FILENAME'

*       EXPORTING

*         PROGRAM_NAME        = SYST-CPROG

*         DYNPRO_NUMBER       = SYST-DYNNR

*         FIELD_NAME          = ' '

       IMPORTING

         FILE_NAME           = file.

                .

p_file = file.

START-OF-SELECTION.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

  EXPORTING

*   I_FIELD_SEPERATOR          =

   I_LINE_HEADER              = 'X'

    I_TAB_RAW_DATA             = it_raw

    I_FILENAME                 = p_file

  TABLES

    I_TAB_CONVERTED_DATA       = it_file

* EXCEPTIONS

*   CONVERSION_FAILED          = 1

*   OTHERS                     = 2

          .

IF SY-SUBRC <> 0.

* Implement suitable error handling here

ENDIF.

*BREAK-POINT.

***************************Data Declaration for Bapi*************

data:"Importing

      wa_partner type bu_partner,

      wa_category type bapibus1006_head-PARTN_CAT,

      wa_group type bapibus1006_heAD-PARTN_GRP,

      wa_central type bapibus1006_central ,

      wa_cperson type BAPIBUS1006_CENTRAL_PERSON,

      wa_cgroup type bapibus1006_central_group,

      wa_corgan type bapibus1006_central_organ,

     wa_data type  BAPIBUS1006_CENTRAL,

*     it_organ type bapibus1006_

 wa_address type bapibus1006_address,

      "Tables exporting

      gv_partner type bu_partner,



      gv_bukrs type T001-BUKRS,

      gv_vkorg type vkorg,

      gv_vtweg type vtweg,

      gv_spart type spart,

      gv_role type TABLE OF BAPIBUSISB990_BPROLES WITH HEADER LINE,

      gv_rule type BU_PARTNERROLE,



      gv_cat type BAPIBUS1006TAX-TAXTYPE,

      gv_number type BAPIBUS1006TAX-TAXNUMBER,

      gv_group type BAPIBUS1006_HEAD-PARTN_GRP,

      ls_sales type CMDS_EI_SALES_DATA,

      ls_sales_key type CMDS_EI_SALES_KEY,

      ls_sales_ext type cmds_ei_extern,



      ls_gv_partner type CMDS_EI_INSTANCE,

      ls_gv_task type CMD_EI_OBJECT_TASK,



      ls_Sales_data type CMDS_EI_SALES,



it_msg_correct type CVIS_MESSAGE,

ls_company type CMDS_EI_COMPANY,

      it_sales type CMDS_EI_SALES_T,

      it_sales_cmd type CMDS_EI_CMD_SALES,

      it_sales_ext type CMDS_EI_EXTERN_T,

      it_sales_main type CMDS_EI_MAIN,



      it_msg_def type cvis_message,



      it_correct type cmds_ei_main,

      it_defect type cmds_ei_main,



wa_kna1 type KNA1_APP_DI,

wa_knb1 type KNB1_APP_DI,

wa_knvv type KNvv_APP_DI,



*gv_iden type BAPIBUS1006_IDENTIFICATION,

      "REturn

      it_return_g type TABLE OF bapiret2,

      it_return_i type TABLE OF bapiret2,

      it_return_s type BUS000FLDS-CHAR1,

      return type TABLE OF bapiret2.





loop at it_file into wa_file.

*  wa_partner = wa_file-OLD_NO.

  wa_category = '2'.

  wa_data-SEARCHTERM1 = wa_file-SEARCH.

*  wa_data-PARTNERLANGUAGE = wa_file-SPRAS+0(1).

*  wa_data-PARTNERTYPE = wa_file-

  wa_corgan-NAME1 = wa_file-NAME.

*  wa_corgan-

  wa_address-STREET = wa_file-STREET.

  wa_address-POSTL_COD1 = wa_file-PCODE.

  wa_address-CITY = wa_file-CITY.

  wa_address-COUNTRY = wa_file-COUNTRY.

  wa_address-REGION = wa_file-STATE.

gv_group = wa_file-ROLE.

gv_role-PARTNERROLE = 'FLCU01'.

append gv_role.

*BREAK-POINT.

CALL FUNCTION 'BAPI_BUPA_FS_CREATE_FROM_DATA2'

  EXPORTING

*   BUSINESSPARTNEREXTERN              =

    PARTNERCATEGORY                    = '2'

   PARTNERGROUP                       = gv_group

    CENTRALDATA                        = wa_data

*   CENTRALDATAPERSON                  =

   CENTRALDATAORGANIZATION            = wa_corgan

*   CENTRALDATAGROUP                   =

   ADDRESSDATA                        = wa_address

*   DUPLICATE_MESSAGE_TYPE             =

*   ACCEPT_ERROR                       = ' '

*   TESTRUN                            =

*   CHANGEDOCU                         =

 IMPORTING

   BUSINESSPARTNER                    = gv_partner

 TABLES

*   TELEFONDATA                        =

*   FAXDATA                            =

*   TELETEXDATA                        =

*   TELEXDATA                          =

*   E_MAILDATA                         =

*   RMLADDRESSDATA                     =

*   X400ADDRESSDATA                    =

*   RFCADDRESSDATA                     =

*   PRTADDRESSDATA                     =

*   SSFADDRESSDATA                     =

*   URIADDRESSDATA                     =

*   PAGADDRESSDATA                     =

*   ADDRESSNOTES                       =

*   COMMUNICATIONNOTES                 =

*   TELEFONDATANONADDRESS              =

*   FAXDATANONADDRESS                  =

*   TELETEXDATANONADDRESS              =

*   TELEXDATANONADDRESS                =

*   *E_MAILDATANONADDRESS               =

*   RMLADDRESSDATANONADDRESS           =

*   X400ADDRESSDATANONADDRESS          =

*   RFCADDRESSDATANONADDRESS           =

*   PRTADDRESSDATANONADDRESS           =

*   SSFADDRESSDATANONADDRESS           =

*   URIADDRESSDATANONADDRESS           =

*   PAGADDRESSDATANONADDRESS           =

*   COMMUNICATIONNOTESNONADDRESS       =

   RETURN                             = it_return_g

*   ADDRESSDUPLICATES                  =

   ROLES                              = gv_role

          .



*wa_data_organ-

*      CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA'

*        EXPORTING

**         BUSINESSPARTNEREXTERN              = wa_partner

*          PARTNERCATEGORY                    = wa_category

**         PARTNERGROUP                       =

*          CENTRALDATA                        = wa_data

**         CENTRALDATAPERSON                  =

*         CENTRALDATAORGANIZATION             = wa_corgan

**         CENTRALDATAGROUP                   =

*         ADDRESSDATA                         = wa_address

**         DUPLICATE_MESSAGE_TYPE             =

**         ACCEPT_ERROR                       = ' '

*       IMPORTING

*         BUSINESSPARTNER                    = gv_partner

*

*       TABLES

**         TELEFONDATA                        =

**         FAXDATA                            =

**         TELETEXDATA                        =

**         TELEXDATA                          =

**         E_MAILDATA                         =

**         RMLADDRESSDATA                     =

**         X400ADDRESSDATA                    =

**         RFCADDRESSDATA                     =

**         PRTADDRESSDATA                     =

**         SSFADDRESSDATA                     =

**         URIADDRESSDATA                     =

**         PAGADDRESSDATA                     =

**         ADDRESSNOTES                       =

**         COMMUNICATIONNOTES                 =

**         COMMUNICATIONUSAGE                 =

**         TELEFONDATANONADDRESS              =

**         FAXDATANONADDRESS                  =

**         TELETEXDATANONADDRESS              =

**         TELEXDATANONADDRESS                =

**         E_MAILDATANONADDRESS               =

**         RMLADDRESSDATANONADDRESS           =

**         X400ADDRESSDATANONADDRESS          =

**         RFCADDRESSDATANONADDRESS           =

**         PRTADDRESSDATANONADDRESS           =

**         SSFADDRESSDATANONADDRESS           =

**         URIADDRESSDATANONADDRESS           =

**         PAGADDRESSDATANONADDRESS           =

**         COMMUNICATIONNOTESNONADDRESS       =

**         COMMUNICATIONUSAGENONADDRESS       =

*         RETURN                             = it_return_g

**         ADDRESSDUPLICATES                  =

*                .



CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

* EXPORTING

*   WAIT          = '5'

* IMPORTING

*   RETURN        = it_return_c

          .



gv_cat = wa_file-TAXC.

gv_number = wa_file-GST.



CALL FUNCTION 'BAPI_BUPA_TAX_ADD'

  EXPORTING

    BUSINESSPARTNER       = gv_paRTNER

    TAXTYPE               = gv_cat

    TAXNUMBER             = gv_number

* TABLES

*   RETURN                =

          .





CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

* EXPORTING

*   WAIT          = '5'

* IMPORTING

*   RETURN        = it_return

          .

*BREAK-POINT.

*if it_return-TYPE = 'S'.

**  write : wa_partner.

*  ENDIF.

*if ev_partner

*gv_bukrs = wa_file-CODE.

*gv_vkorg = wa_file-SORG.

*GV_VTWEG = wa_file-DIST.

*gV_spart = wa_file-DIV.

*

*wa_knb1-AKONT = wa_file-RECON.

*wa_knvv-INCO1 = wa_file-INCOTERM.

*wa_knvv-LPRIO = wa_file-DEL.

*wa_knvv-VKGRP = wa_file-SGRP.

*wa_knvv-VKBUR = wa_file-SOFF.

*wa_knvv-KKBER = wa_file-CCA.

*wa_knvv-VSBED = wa_file-SHIP.

*wa_knvv-KONDA = wa_file-PGRP.

**

*gv_rule = gv_role-PARTNERROLE.

**ls_sales-KONDA = wa_file-pgrp.

**ls_sales-INCO1 = wa_file-INCOTERM.

**ls_sales-LPRIO = wa_file-DEL.

**ls_sales-VKGRP = wa_file-sgrp.

**ls_sales-VKBUR = wa_file-soff.

**-*ls_sales-KKBER = wa_file-CCA.

**ls_sales-VSBED = wa_file-ship.

**ls_sales-KONDA = wa_file-PGRP.

*BREAK-POINT.

*      CALL FUNCTION 'FICU_BUPA_DARK_MAINTAIN_INTERN'

*        EXPORTING

*          I_AKTYP                    = '04'

*         I_XUPDTASK                 = ' '

*         I_XCOMMIT                  = 'X'

*         I_PARTNER                  = gv_partner

**         I_BPEXT                    =

**         I_TYPE                     =

**         I_BPKIND                   =

**         I_GROUP                    =

**         I_RLTYP                    =

**         I_RLTYP2                   =

**         I_RLTYP3                   =

**         I_RLTYP4                   =

**         I_RLTYP5                   =

**         I_RLTYP6                   =

**         I_RLTYP7                   =

**         I_RLTYP8                   =

**         I_RLTYP9                   =

*         I_ROLE1                    = gv_rule

**         I_ROLE2                    =

**         I_ROLE3                    =

**         I_ROLE4                    =

**         I_ROLE5                    =

**         I_ROLE6                    =

**         I_ROLE7                    =

**         I_ROLE8                    =

**         I_ROLE9                    =

**         I_VALID_FROM_1             =

**         I_VALID_TO_1               =

**         I_CHIND_1                  =

**         I_VALID_FROM_2             =

**         I_VALID_TO_2               =

**         I_CHIND_2                  =

**         I_VALID_FROM_3             =

**         I_VALID_TO_3               =

**         I_CHIND_3                  =

**         I_VALID_FROM_4             =

**         I_VALID_TO_4               =

**         I_CHIND_4                  =

**         I_VALID_FROM_5             =

**         I_VALID_TO_5               =

**         I_CHIND_5                  =

**         I_VALID_FROM_6             =

**         I_VALID_TO_6               =

**         I_CHIND_6                  =

**         I_VALID_FROM_7             =

**         I_VALID_TO_7               =

**         I_CHIND_7                  =

**         I_VALID_FROM_8             =

**         I_VALID_TO_8               =

**         I_CHIND_8                  =

**         I_VALID_FROM_9             =

**         I_VALID_TO_9               =

**         I_CHIND_9                  =

**         I_VALDT                    =

*         I_NODATA                   = '/'

*         I_BUKRS                    = gv_bukrs

*         I_VKORG                    = gv_vkorg

*         I_VTWEG                    = gv_vtweg

*         I_SPART                    = gv_spart

**         I_BUT000                   =

**         I_BUT001                   =

**         I_BP001                    =

**         I_BP1010                   =

**         I_BP1030                   =

*         I_KNA1                     = wa_kna1

*         I_KNB1                     = wa_knb1

*         I_KNVV                     = wa_knvv

**         I_KUNNR_EXT                =

**         I_XTEST                    = ' '

**         I_XDLVE2_ON_COMMIT         = ' '

**         I_XDLVE2_ON_ROLLBACK       = ' '

*       IMPORTING

*         E_XERROR                   = it_return_s

**       TABLES

**         T_BUT0BK                   =

**         T_BUT020                   =

**         T_BUT0CC                   =

**         T_BUT021                   =

*-**         T_KNB5                     =

**         T_KNVI                     =

**         T_DATA                     =

**         T_MESSAGE                  =

**         T_KEYVALUE                 =

**         T_BUT021_FS                =

**         T_BP011                    =

**         T_BP021                    =

**         T_BUT0ID                   =

**         T_BUT0IS                   =

**         T_BP1012                   =

*                .

*CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

*** EXPORTING

***   WAIT          = '5'

*** IMPORTING

***   RETURN        = it_return

*          .

**ls_sales_key-VKORG = wa_file-SORG.

*ls_sales_key-VTWEG = wa_file-DIST.

*ls_sales_key-SPART = wa_file-DIV.

BREAK-POINT.

*MOVE-CORRESPONDING ls_sales_key to it_sales.

ls_sales_ext-HEADER-OBJECT_INSTANCE-KUNNR = gv_partner.

ls_sales_ext-HEADER-OBJECT_TASK = 'M'.

*ls_Sales_ext-SALES_DATA-SALES-

ls_Sales_data-DATA_KEY-VTWEG = wa_file-dist.

ls_sales_data-DATA_KEY-VKORG = wa_file-sorg.

ls_sales_data-DATA_KEY-spart = wa_file-div.

ls_sales_data-DATA-KONDA = wa_file-pgrp.

ls_sales_data-DATA-INCO1 = wa_file-incoterm.

ls_sales_data-DATA-INCO2_L = wa_file-INCLOC.

ls_sales_data-DATA-LPRIO = wa_file-DEL.

ls_sales_data-DATA-VKGRP = wA_file-sgrp.

ls_sales_data-DATA-VKBUR = wA_file-soff.

ls_sales_data-DATA-KKBER = wA_file-cca.

ls_sales_data-DATA-VSBED = wa_file-SHIP.

ls_sales_ext-SALES_DATA-CURRENT_STATE = space.

ls_sales_ext-COMPANY_DATa-CURRENT_STATE = space.

*ls_Sales_ext-HEADER-

*ls_sales_ext-COMPANY_DATA-COMPANY-

*ls_company-TASK = 'M'.

*ls_sales_data-DATA-

append ls_company to ls_sales_ext-COMPANY_DATA-COMPANY.

append ls_sales_data to ls_sales_ext-SALES_DATA-SALES.

append ls_sales_ext to it_sales_ext.

it_sales_main-CUSTOMERS[] = it_sales_ext[].



CALL METHOD CMD_EI_API=>INITIALIZE

*  EXPORTING

*    IV_MANUAL_MEMORY_INIT =

    .



CALL METHOD CMD_EI_API=>MAINTAIN_BAPI

  EXPORTING

*    IV_TEST_RUN              = SPACE

    IV_COLLECT_MESSAGES      = 'X'

    IS_MASTER_DATA           = it_sales_main

  IMPORTING

    ES_MASTER_DATA_CORRECT   = it_correct

    ES_MESSAGE_CORRECT       = it_msg_correct

    ES_MASTER_DATA_DEFECTIVE = it_defect

    ES_MESSAGE_DEFECTIVE     = it_msg_def

    .
 endloop.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers