Skip to Content
0
Former Member
Mar 30, 2015 at 11:14 AM

How to use cmd_ei_api=>maintain to update customer info in KNA1

3839 Views

Hi Experts!

I am trying to use the class cmd_ei_api in order to update information of customers in KNA1. I first tried with Function Module SD_CUSTOMER_MAINTAIN_ALL (but the SPRAS column is not updating correctly).

However, now i use method MAINTAIN of the class, it's working but there is nothing changed. Has somebody made already experiences with this class and probably can tell me where the mistake is?

The sample code looks like this:

REPORT zsd_upd_cust_info.

DATA: wa_master_data TYPE cmds_ei_main,
wa_customer TYPE cmds_ei_extern,

wa_address TYPE bapiad1vl,

wa_text TYPE cvis_ei_text,

wa_mes_error TYPE cvis_message,
mess TYPE bapiret2.

PARAMETERS: p_knnr TYPE kna1-kunnr,
p_task TYPE cmd_ei_object_task.

wa_customer-header-object_instance-kunnr = p_knnr.
wa_customer-header-object_task = p_task.

wa_address-langu = 'DE'.
wa_address-sort1 = 'NameSort1'.
wa_address-name = 'Name'.
wa_address-postl_cod1 = '9999'.
wa_address-country = 'DE'.
wa_address-street = 'TEST street'.
wa_address-city = 'cityXY'.
wa_address-region = 'Region'.
wa_address-district = 'Dist'.


wa_customer-central_data-address-postal-data = wa_address.
APPEND wa_customer TO wa_master_data-customers.

CALL METHOD cmd_ei_api=>maintain
EXPORTING
iv_test_run = 'X'
is_master_data = wa_master_data
IMPORTING
es_error = wa_mes_error.

IF wa_mes_error-is_error IS INITIAL.
COMMIT WORK.
Message 'UPdate durchgeführt' type 'I' DISPLAY LIKE 'I'.
ELSE.
LOOP AT wa_mes_error-messages INTO mess.
MESSAGE mess-message TYPE 'I' DISPLAY LIKE 'i'.
ENDLOOP.
ENDIF.

Thanks in advance

Regards Patrick