Skip to Content
0

Update Customer Telephone & Fax with CMD_EI_API_required help

Jan 25, 2017 at 11:45 AM

144

avatar image
Former Member

Hi,

How could the update of Customer Telephone & Fax with CMD_EI_API be coded.

Please correct me in the below code , this is not working.

* Read Customer data
CALL METHOD cmd_ei_api_extract=>get_data

*Reading into a structure to make changes in the fields
READ TABLE lstr_customers_in-customers INDEX 1 INTO
lstr_customer_in_ad.

*Header structute to Update the ADDRESS using MAINTAIN_BAPI method
CLEAR: lstr_customer_in_ad-header.
lstr_header_in_ad-object_instance-kunnr = wa_final_tmp-kunnr.
lstr_header_in_ad-object_task = 'U'.
lstr_customer_in_ad-header = lstr_header_in_ad.

*Passing the data to COMMUNICATION - PHONE & FAX
IF <fstr_addcom> IS ASSIGNED.
UNASSIGN <fstr_addcom>.
ENDIF.
*
ASSIGN lstr_customer_in_ad-central_data-address TO <fstr_addcom>.
******** Telephone****************************************************
IF <fstr_addcom> IS ASSIGNED.
* lstr_comm = <fstr_addcom>-communication.
READ TABLE <fstr_addcom>-communication-phone-phone
ASSIGNING <fstr_phone_t> INDEX 1.
IF sy-subrc EQ 0 AND <fstr_phone_t> IS ASSIGNED.
<fstr_phone_t>-contact-task = 'U'.
<fstr_phone_t>-contact-data-std_no = ''.
<fstr_phone_t>-contact-data-telephone = wa_final_tmp-tel_number.
<fstr_phone_t>-contact-datax-telephone = 'X'.
<fstr_phone_t>-contact-datax-country = 'X'.
<fstr_phone_t>-contact-datax-countryiso = 'X'.
<fstr_phone_t>-contact-datax-std_no = 'X'.
<fstr_phone_t>-contact-datax-consnumber = 'X'.
<fstr_phone_t>-contact-datax-updateflag = 'U'.
lstr_remark_t-task = 'U'.
lstr_remark_t-data-langu = <fstr_addcom>-postal-data-langu.
lstr_remark_t-datax-langu = 'X'.
lstr_remark_t-data-langu_iso
= <fstr_addcom>-postal-data-langu_iso.
lstr_remark_t-datax-langu_iso = 'X'.
lstr_remark_t-data-comm_type = 'TEL'.
lstr_remark_t-datax-comm_type = 'X'.
lstr_remark_t-data-consnumber =
<fstr_phone_t>-contact-data-consnumber.
lstr_remark_t-datax-consnumber = 'X'.
lstr_remark_t-datax-updateflag = 'U'.
APPEND lstr_remark_t TO <fstr_phone_t>-remark-remarks.
<fstr_phone_t>-remark-current_state = space.
<fstr_addcom>-communication-phone-current_state = space.

ENDIF.
*********FAX***********************************************************
READ TABLE <fstr_addcom>-communication-fax-fax
ASSIGNING <fstr_fax_t> INDEX 1.

IF sy-subrc EQ 0 AND <fstr_fax_t> IS ASSIGNED.
<fstr_fax_t>-contact-task = 'U'.
<fstr_fax_t>-contact-data-std_no = ''.
<fstr_fax_t>-contact-data-fax_no = wa_final_tmp-fax_number.
<fstr_fax_t>-contact-datax-fax_no = 'X'.
<fstr_fax_t>-contact-datax-country = 'X'.
<fstr_fax_t>-contact-datax-countryiso = 'X'.
<fstr_fax_t>-contact-datax-std_no = 'X'.
<fstr_fax_t>-contact-datax-consnumber = 'X'.
<fstr_fax_t>-contact-datax-updateflag = 'U'.
CLEAR:lstr_remark_t.
lstr_remark_t-task = 'U'.
lstr_remark_t-data-langu = <fstr_addcom>-postal-data-langu.
lstr_remark_t-datax-langu = 'X'.
lstr_remark_t-data-langu_iso
= <fstr_addcom>-postal-data-langu_iso.
lstr_remark_t-datax-langu_iso = 'X'.
lstr_remark_t-data-comm_type = 'FAX'.
lstr_remark_t-datax-comm_type = 'X'.
lstr_remark_t-data-consnumber =
<fstr_fax_t>-contact-data-consnumber.
lstr_remark_t-datax-consnumber = 'X'.
lstr_remark_t-datax-updateflag = 'U'.
APPEND lstr_remark_t TO <fstr_fax_t>-remark-remarks.
<fstr_fax_t>-remark-current_state = space.
<fstr_addcom>-communication-fax-current_state = space.
Endif.
***************************************************
CLEAR lstr_masterdata-customers.
lstr_customer_in_ad-central_data-address-task = 'U'.
APPEND lstr_customer_in_ad TO lstr_masterdata-customers.

CALL METHOD cmd_ei_api=>maintain_bapi
EXPORTING
iv_test_run = space
iv_collect_messages = 'X'
is_master_data = lstr_masterdata
IMPORTING
es_master_data_correct = lstr_master_data_correct
es_message_correct = lstr_message_correct
es_master_data_defective = lstr_master_data_defective
es_message_defective = lstr_message_defective.

IF lstr_master_data_defective is initial.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.
ENDIF.
ENDIF.

Thank you

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

1 Answer

Raymond Giuseppi
Jan 26, 2017 at 12:23 PM
0

First add some check of errors returned by the extract API, else manage the case of update or insert if no data found during the LOOP.

Regards,
Raymond

Share
10 |10000 characters needed characters left characters exceeded