Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Regarding update of partner function using class CMD_EI_API=>MAINTAIN_BAPI

Former Member
0 Likes
1,586

Dear All,

I have a requiremnet where i have to update partner functions like DEFPA ie default checkbox in sales area data.

I am using CMD_EI_API=>MAINTAIN_BAPI to do this.But i am getting Errors.Please post some code example if anyone has done the

updation of partner functions in sales area.

Regards,

Prathima Talari.

3 REPLIES 3
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,119

Hi Prathima

What errors are you getting?

Nabheet

Read only

0 Likes
1,119

   *&---------------------------------------------------------------------*
*& Report  ZTEST_CUST_XD02
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZTEST_CUST_XD02.

datawa_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_s_company_code  type cmds_ei_company,
       wa_t_company_code  type cmds_ei_company_t,
       wa_s_functions     type cmds_ei_functions,
       wa_t_functions     type CMDS_EI_FUNCTIONS_T,
       wa_functions       type cmds_ei_cmd_functions,
       wa_s_sales_data    type cmds_ei_sales,
       wa_t_sales_data    type cmds_ei_sales_t,
       wa_sales_data      type cmds_ei_cmd_sales,
       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,
       wa_t_corr_cust     type CMDS_EI_EXTERN_T,
       wa_s_corr_cust     like line of wa_t_corr_cust.

data: return_t           type bapiret2_t,
       return_s           type bapiret2,
       g_kunnr            type kunnr.
data: wa_t_phone         type CVIS_EI_PHONE_T,
       wa_s_phone         like line of wa_t_phone,
       wa_t_fax           type CVIS_EI_FAX_T,
       wa_s_fax           like line of wa_t_fax,
       wa_t_email         type CVIS_EI_SMTP_T,
       wa_s_email         like line of wa_t_email,
       wa_comm            type CVIS_EI_CVI_COMMUNICATION.





constants: c_update type c value 'M',

            c_insert type c value 'I'.



start-of-selection.

  clear: wa_customer, wa_s_company_code.

  wa_customer-header-object_instance-kunnr = 'A-00267106'.   "'A-00108268' .
  wa_customer-header-object_task = c_update.

******************Begin of Populating the Address******************

  wa_address-name       = 'Parnon Trading'.
  wa_address-city       = 'Tulsa'.
  wa_address-postl_cod1 = '74119'.
  wa_address-street     = '1437 S. Boulder, Ste 355'.
  wa_address-country    = 'US'.
  wa_address-langu      = 'E'.
  wa_address-sort1      = 'SORT1'.
  wa_address-sort2      = 'Sort2'.
  wa_address-TRANSPZONE = '0000000001'.
*  Assign address data directly

  wa_customer-central_data-address-postal-data = wa_address.
  wa_addressx-name       = 'X'.
  wa_addressx-city       = 'X'.
  wa_addressx-postl_cod1 = 'X'.
  wa_addressx-street     = 'X'.
  wa_addressx-country    = 'X'.
  wa_addressx-langu      = 'X'.
  wa_addressx-sort1      = 'X'.
  wa_addressx-sort2      = 'X'.
  wa_addressx-TRANSPZONE = 'X'.

*  Assign address data directly

  wa_customer-central_data-address-postal-datax = wa_addressx.
*******************End of Populating the Address*******************
** Assign account group directly
  wa_customer-central_data-central-data-ktokd = 'ZPAY'.   "'OKRA'. "commented by prathima
  wa_customer-central_data-central-datax-ktokd = 'X'"commented by prathima
  wa_customer-central_data-central-data-STCD1 = ' '.
  wa_customer-central_data-central-datax-stcd1 = 'X'.
*******************Begin of Communication details******************
*if i_meth_id = 'Phone'.
  wa_s_phone-contact-task = c_update.
  wa_s_phone-contact-data-telephone  = '080-1234567'.
  wa_s_phone-contact-datax-telephone = 'X'.
  append wa_s_phone to wa_t_phone.
*  wa_comm-PHONE-current_state = 'X'.
  wa_comm-PHONE-PHONE = wa_t_phone[].
*elseif i_meth_id = 'Fax'.
  wa_s_fax-contact-task = c_update.
  wa_s_fax-contact-data-fax = '1234567891'.
  wa_s_fax-contact-datax-fax = 'X'.
  append wa_s_fax to wa_t_fax.
*  wa_comm-FAX-current_state = 'X'.
  wa_comm-FAX-FAX = wa_t_fax[].
*elseif i_meth_id = 'Email'.
  wa_s_email-contact-task = c_update.
  wa_s_email-contact-data-e_mail = 'kmrjynth@gmail.com'.
  wa_s_email-contact-datax-e_mail = 'X'.
  append wa_s_email to wa_t_email.
*  wa_comm-SMTP-current_state = 'X'.
  wa_comm-SMTP-SMTP = wa_t_email[].
*endif.
* Assign contact mediums data directly
  wa_customer-central_data-address-communication = wa_comm.
********************End of Communication details*******************
***************Begin of Customer Company code details*************  prathima
  wa_s_company_code-task           = c_update.
  wa_s_company_code-data_key-bukrs = '0150'.
  wa_s_company_code-data-zuawa     = ' '.
  wa_s_company_code-data-akont     = '0012100125'.
  wa_s_company_code-data-zterm = 'TR45'.
  wa_s_company_code-data-xzver = 'X'.
  append wa_s_company_code to wa_t_company_code.
  wa_customer-company_data-current_state = 'X'.

  wa_customer-company_data-company = wa_t_company_code[].
*****************End of Customer Company code details*************
******************Begin of Customer Sales details*****************

  wa_s_sales_data-task = c_update.
  wa_s_sales_data-data_key-vkorg = '0150'."i_sales_org.
  wa_s_sales_data-data_key-vtweg = '00'.
  wa_s_sales_data-data_key-spart = '00'.
  wa_s_sales_data-data-versg = '1'.
  wa_s_sales_data-datax-versg = 'X'.
  wa_s_sales_data-data-kalks = '3'.
  wa_s_sales_data-datax-kalks = 'X'.
*  wa_s_sales_data-data-kdgrp = 'MC'.
*  wa_s_sales_data-datax-kdgrp = 'MC'.
*  wa_s_sales_data-data-vsbed = '02'.
  wa_s_sales_data-datax-vsbed = 'X'.
  wa_s_sales_data-data-waers = 'EUR'.
  wa_s_sales_data-datax-waers = 'X'.
  wa_s_sales_data-data-ktgrd = '01'.
  wa_s_sales_data-datax-ktgrd = 'X'.
wa_s_sales_data-data-zterm = 'TR45'."i_pay_term.
wa_s_sales_data-datax-zterm = 'X'.
******Begin of Partner roles details*****

  wa_s_sales_data-functions-current_state = 'X'.
  wa_s_functions-task = c_update.
  wa_s_functions-data_key-parvw = 'RE'.
  wa_s_functions-data_key-parza = '000'.
  wa_s_functions-data-knref = 'Bill-to party'.
  wa_s_functions-datax-knref = 'X'.
  wa_s_functions-data-defpa = 'X'.
  wa_s_functions-datax-defpa = 'X'"added by prathima
*wa_s_functions-data-partner = ' '.
*wa_s_functions-datax-partner = 'X'.
  append wa_s_functions to wa_t_functions.
  clear wa_s_functions.
  wa_s_functions-task = c_update.
  wa_s_functions-data_key-parvw = 'RG'.
  wa_s_functions-data_key-parza = '000'.
  wa_s_functions-data-knref = 'Payer'.
  wa_s_functions-datax-knref = 'X'.
  wa_s_functions-data-defpa = 'X'.
  wa_s_functions-datax-defpa = 'X'"added by prathima
*wa_s_functions-data-partner = ' '.
*wa_s_functions-datax-partner = 'X'.
  append wa_s_functions to wa_t_functions.
*  clear wa_s_functions.
  wa_s_sales_data-functions-functions = wa_t_functions[].
******End of Partner roles details******

append wa_s_sales_data to wa_t_sales_data.
  wa_sales_data-current_state = 'X'.
  wa_sales_data-sales = wa_t_sales_data[].
*Assign Sales data directly
  wa_customer-sales_data = wa_sales_data.
*******************End of Customer Sales details******************
  append wa_customer to wa_customers-customers.

  CALL METHOD cmd_ei_api=>maintain_bapi
    EXPORTING
*     iv_test_run              = p_test
*     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.
    COMMIT WORK.
    wa_t_corr_cust[] = wa_correct-customers[].
    read table wa_t_corr_cust into wa_s_corr_cust index 1.
    if sy-subrc eq 0.
      g_kunnr = wa_s_corr_cust-header-object_instance-kunnr.
    endif.
    write:/'Customer Created:',g_kunnr.
  else.
    return_t = wa_mes_error-messages.
    loop at return_t into return_s where type = 'E'.
      write:/'Error:',return_s-message.
    endloop.
  endif.

Read only

0 Likes
1,119

hi nabheet thanks for the reply.

I have posted the error and code which i have written by seeing scn blogs.

my main intention is to update partner functions, ie one default field DEFPA.

Please let me know if you have any solution for this.