Skip to Content

cmd_ei_api=>maintain_bapi with sales_data - Partner Roles Problem

Hi there,

I'm having error while creating customer using cmd_ei_api=> maintain_bapi. Here's my code block;

  DATA : lt_students TYPE TABLE OF znetth_demostudent
                     WITH HEADER LINE.
  DATA : line TYPE znetth_demopayment_transaction.
  DATA : ls_kna1 LIKE kna1.
  DATA : i_insert TYPE cmd_ei_object_task VALUE 'I'.
  DATA : ls_customers             TYPE cmds_ei_extern,
         lt_company               TYPE cmds_ei_company_t,
         ls_sales_data            TYPE cmds_ei_sales,
         ls_company               TYPE cmds_ei_company,
         ls_masterdata            TYPE cmds_ei_main,
         lt_sales_data            TYPE cmds_ei_sales_t,
         lt_customers             TYPE cmds_ei_extern_t,
         ls_master_data_correct   TYPE cmds_ei_main,
         ls_message_correct       TYPE cvis_message,
         ls_master_data_defective TYPE cmds_ei_main,
         ls_message_defective     TYPE cvis_message,
         ls_mail                  TYPE cvis_ei_smtp_str,
         lt_mail                  TYPE cvis_ei_smtp_t,
         ls_mail_main             TYPE cvis_ei_cvi_smtp,
         ls_phone_main            TYPE cvis_ei_cvi_phone,
         ls_phone                 TYPE cvis_ei_phone_str,
         lt_phone                 TYPE cvis_ei_phone_t,
         ls_fax_main              TYPE cvis_ei_cvi_fax,
         ls_fax                   TYPE cvis_ei_fax_str,
         lt_fax                   TYPE cvis_ei_fax_t,
         lt_contacts              TYPE cmds_ei_contacts_t,
         ls_contacts              TYPE cmds_ei_contacts,
         lt_message               TYPE bapiret2_t,
         ls_functions             TYPE cmds_ei_functions,
         lt_functions             TYPE cmds_ei_functions_t,
         lt_functionsmuh          TYPE cmds_ei_functions_t,
         lt_vergi                 TYPE cmds_ei_tax_ind_t,
         ls_vergi                 TYPE cmds_ei_tax_ind.
  DATA error TYPE cvis_message.
*  CONSTANTS: c_update TYPE c VALUE 'M', c_insert TYPE c VALUE 'I'.

  REFRESH lt_students.
  LOOP AT lt_payment_transaction INTO line.
    SELECT SINGLE * FROM kna1
                    INTO ls_kna1
                    WHERE stcd2 = line-student-tckn.
    IF sy-subrc <> 0.
      lt_students = line-student.
      APPEND lt_students.
    ENDIF.
  ENDLOOP.
  SORT lt_students ASCENDING BY tckn.
  DELETE ADJACENT DUPLICATES FROM lt_students COMPARING tckn.

  LOOP AT lt_students.
    ls_customers-header-object_task = i_insert.
    ls_customers-header-object_instance-kunnr = ' '.
    ls_customers-central_data-central-data-ktokd = 'YOGR'.
    ls_customers-central_data-central-datax-ktokd = 'X'.
    ls_customers-central_data-address-task = i_insert.
    ls_customers-central_data-address-postal-data-from_date = sy-datum.
    ls_customers-central_data-address-postal-data-to_date = '99991231'.
    ls_customers-central_data-address-postal-data-country = 'TR'.
    ls_customers-central_data-address-postal-data-langu = 'T'.
    ls_customers-central_data-address-postal-data-region =
                                       lt_students-city_code.
    ls_customers-central_data-address-postal-data-district =
                                       lt_students-district.
    ls_customers-central_data-address-postal-data-name =
                                lt_students-full_name.
    ls_customers-central_data-address-postal-data-name_3 =
                                              lt_students-address.


    ls_customers-central_data-address-postal-datax-from_date = 'X'.
    ls_customers-central_data-address-postal-datax-to_date = 'X'.
    ls_customers-central_data-address-postal-datax-country = 'X'.
    ls_customers-central_data-address-postal-datax-langu = 'X'.
    ls_customers-central_data-address-postal-datax-region = 'X'.
    ls_customers-central_data-address-postal-datax-district = 'X'.
    ls_customers-central_data-address-postal-datax-name = 'X'.
    ls_customers-central_data-address-postal-datax-name_3 = 'X'.

    IF lt_students-parent1 IS NOT INITIAL.
      ls_contacts-task = i_insert.
      ls_contacts-address_type_3-postal-data-firstname =
                                lt_students-parent1-name.
      ls_contacts-address_type_3-postal-data-lastname =
                                      lt_students-parent1-surname.
      ls_contacts-address_type_3-postal-datax-firstname = 'X'.
      ls_contacts-address_type_3-postal-datax-lastname  = 'X'.
      APPEND ls_contacts TO lt_contacts.
    ENDIF.



    IF lt_students-parent2 IS NOT INITIAL.
      ls_contacts-task = i_insert.
      ls_contacts-address_type_3-postal-data-firstname =
                                lt_students-parent2-name.
      ls_contacts-address_type_3-postal-data-lastname =
                               lt_students-parent2-surname.
      ls_contacts-address_type_3-postal-datax-firstname = 'X'.
      ls_contacts-address_type_3-postal-datax-lastname  = 'X'.
      APPEND ls_contacts TO lt_contacts.
    ENDIF.



    ls_vergi-task = i_insert.
    ls_vergi-data_key-aland = 'TR'.
    ls_vergi-data_key-tatyp = 'MWST'.
    ls_vergi-data-taxkd = '1'.
    ls_vergi-datax-taxkd = 'X'.
    APPEND ls_vergi TO lt_vergi.

    ls_sales_data-task = i_insert.
    ls_sales_data-data_key-vkorg = '1000'.
    ls_sales_data-data_key-vtweg = '10'.
    ls_sales_data-data_key-spart = '10'.
    ls_sales_data-data-waers = 'TRY'.
    ls_sales_data-data-vkbur = '9999'.
    ls_sales_data-data-kvgr1 = lt_students-school_code.
    ls_sales_data-data-kvgr2 = lt_students-class.
    ls_sales_data-data-kalks = '2'.
    ls_sales_data-data-versg = '1'.
    ls_sales_data-data-zterm = '0000'.
    ls_sales_data-data-ktgrd = '01'.
    ls_sales_data-data-vwerk = '1000'.
    ls_sales_data-data-mrnkz = 'X'.
    ls_sales_data-data-bokre = 'X'.
    ls_sales_data-data-prfre = 'X'.

    ls_sales_data-datax-waers = 'X'.
    ls_sales_data-datax-vkbur = 'X'.
    ls_sales_data-datax-kvgr1 = 'X'.
    ls_sales_data-datax-kvgr2 = 'X'.
    ls_sales_data-datax-kalks = 'X'.
    ls_sales_data-datax-versg = 'X'.
    ls_sales_data-datax-zterm = 'X'.
    ls_sales_data-datax-ktgrd = 'X'.
    ls_sales_data-datax-vwerk = 'X'.
    ls_sales_data-datax-mrnkz = 'X'.
    ls_sales_data-datax-bokre = 'X'.
    ls_sales_data-datax-prfre = 'X'.


    ls_functions-task = i_insert.
    ls_functions-data_key-parvw = 'AG'.
    ls_functions-data-partner = ls_customers-header-object_instance-kunnr. "INTERNAL"
    APPEND ls_functions TO lt_functions.

    ls_functions-task = i_insert.
    ls_functions-data_key-parvw = 'RE'.
    ls_functions-data-partner = ls_customers-header-object_instance-kunnr. "INTERNAL"
    APPEND ls_functions TO lt_functions.

    ls_functions-task = i_insert.
    ls_functions-data_key-parvw = 'RG'.
    ls_functions-data-partner = ls_customers-header-object_instance-kunnr. "INTERNAL"
    APPEND ls_functions TO lt_functions.

    ls_functions-task = i_insert.
    ls_functions-data_key-parvw = 'WE'.
    ls_functions-data-partner = ls_customers-header-object_instance-kunnr. "INTERNAL"
    APPEND ls_functions TO lt_functions.

    lt_functionsmuh[] = lt_functions[].
    ls_sales_data-functions-functions = lt_functionsmuh.


    ls_company-task = i_insert.
    ls_company-data_key-bukrs = '1000'.
    ls_company-data-akont = '0012010200'.
    ls_company-data-fdgrv = 'MYOGR'.
    ls_company-data-zterm = '0000'.
    ls_company-datax-akont = 'X'.
    ls_company-datax-zterm = 'X'.
    ls_company-datax-fdgrv = 'X'.

    ls_customers-central_data-address-communication-smtp = ls_mail_main.
    ls_customers-central_data-address-communication-phone = ls_phone_main.
    ls_customers-central_data-address-communication-fax = ls_fax_main.
    ls_customers-central_data-tax_ind-tax_ind = lt_vergi .
    APPEND ls_company TO lt_company.
    APPEND ls_sales_data TO lt_sales_data.


    ls_customers-sales_data-sales = lt_sales_data.
    ls_customers-central_data-contact-contacts = lt_contacts.
    ls_customers-company_data-company = lt_company.
    APPEND ls_customers TO lt_customers.

    ls_masterdata-customers = lt_customers.
    break xuser-abap.

    cmd_ei_api=>maintain_bapi(
        EXPORTING
        iv_collect_messages      = 'X'
        is_master_data           = ls_masterdata
        IMPORTING
        es_master_data_correct   = ls_master_data_correct
        es_message_correct       = ls_message_correct
        es_master_data_defective = ls_master_data_defective
        es_message_defective     = ls_message_defective  ).


    IF ls_message_defective-is_error IS INITIAL.
      COMMIT WORK AND WAIT.
    ENDIF.
  ENDLOOP.

I'm getting theese errors;

error means in english => cmd_ei_api maintain method error knvp-kunn2 -lifnr -pernr -parnr plausibility.

Have anyone have any idea for this issue? Please let me where i'm wrong.

api-error.png (32.0 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Apr 24, 2020 at 03:50 PM

    Good afternoon,

    How did you manage to solve the problem?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.