Application Development 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: 

Delete contact person for customer

Former Member
0 Kudos

Hi All,

I am using BDC for transaction XD02 to change the customer account. For addition/deletion/modification of contact person (under general data->contact person tab), I do not want to use BDC for table control because of some problems. To overcome such problems, I can use transaction VAP1 to create and VAP2 for change. But I am not able to find out the functionality for deletion of contact person. I have also tried standard BAPI option but could not get much. Please help me to find the soultion to delete contact person for given customer, other than BDC for XD02 transaction.

-Tejal

12 REPLIES 12

Former Member
0 Kudos

Dear Tejal,

You can use SCAT tool for recording the transaction XD02 for deleting the contact person information.

Its just like recording the sequence like we do it in SHDB.

Go to transaction SCAT, create a test case and save it. The same test case once recorded properly can be used for no.of customers in a single shot.

Lakshminarayanan

0 Kudos

Hi,

Thanks, If I have understood rightly,I can not go for transaction recording as table control can contain multiple records with the same name and on the screen, I do not have an option to uniquely identify the record. Because of this, some other record with the same name gets deleted/modified.

-Tejal

0 Kudos

Hi,

so try to number your contact persons - i use the fields Kunnr and KNVK-PAFKT (01-99) as "key-fields" to identify the contact-persons for modifying and deleting with Batch Input to XD02.

Andreas

0 Kudos

Hi,

Imagine there is a customer code: 103069.

If we go to XD02, then on the contact person tab, for this customer if there is only one contact person or multiple contact persons you can use the option of SCAT for deleting the person. But the thing is you must know and identfy the contact person which you are going to delete before running this SCAT.

Other than this you can go to KNVK table against the field KNVK-PARNR same contact person can be updated. So from this table you can also identify which contact person you are going to delete.

Lakshminarayanan

0 Kudos

Hi Andreas,

Right now I am using the same logic. But for this positioning logic, data which I am getting in form of internal table and records displayed on the screen should be in the same order. So based on order in my internal table, I delete the record from the same position from my screen. But I am not able to find out exactly on what basis, table control screen is sorted. Normally, it is in ascending order of name1, but say, if there are multiple records with the same name, I am not able to find the second field for sorting criteria.

So if I have indicator in my internal table to delete a record and order of the same record is different on screen, some another record will get deleted.

-Tejal

Message was edited by: Tejal

0 Kudos

Hi Tejal,

Say imagine in your internal table you are having the customer code, parnr(contact person no) and name1(contact person).

You can sort the internal table by:

sort itab by kunnr parnr.

so after this sort if you look into your internal table it will contain customer codes sorted in the ascending order and against it you can get the contact person no as well as name. Once this is done, it might help you to identify which sy-tabix you need to delete.

Hope this will be useful to you.

Lakshminarayanan

0 Kudos

Hi Lakshminarayanan,

I tried your suggestion. But sorting based on PARNR for given KUNNR does not bring the records in the same order as that of table control on screen. i.e. records fetched from KNVK table by providing KUNNR and sorted in ascending/descending order of PARNR is different from sequence maintained on screen in XD03 transaction.

-Tejal

0 Kudos

Hi Tejal,

For eg. there is a customer code 'HONEY' and against this customer code i update three contact persons

say in the order 1. TEJAL

2. LAKSHMI

3. SAP

After saving XD02, if you go to KNVK table and see, the entries are arranged as:

itab-PARNR itab-KUNNR itab-sy-tabix itab-NAME1

0000000035 HONEY 1 TEJAL

0000000036 HONEY 2 LAKSHMI

0000000037 HONEY 3 SAP

So, this same sequence is maintained in XD02, while you delete the entry sy-tabix = 2 from the internal table,

automatically the entry from XD02 with the same sequence gets deleted. You need to arrange and sort your internal table accordingly as mentioned above.

Lakshminarayanan

0 Kudos

Hi Lakshminarayanan,

Thanks, I have tried this and sequence on screen is sorted first on name1 and then on PARNR.

-Tejal

0 Kudos

You can try the FM "ISAI_CONTACT_DELETE" to delete the contact person of a customer.

S0004562014
Explorer
0 Kudos

Hi all, late but never too late and for all future queries regarding this issue.

Depending on your release you can use class/method cmd_ei_api=>maintain( ),

maybe this coding example helps you:

...

method delete_contact_relation using p_parnr type char10
p_kunnr type kunnr
changing p_s_error type cvis_message.

data: lv_contact type line of cmds_ei_contacts_t,
ls_cmds_ei_extern type cmds_ei_extern,
ls_cmds_ei_main type cmds_ei_main,
lt_knvp type table of knvp,
ls_cmds_sales type cmds_ei_sales,
ls_cmds_func type cmds_ei_functions.

*-read existing relation
select single kunnr from knvk into @data(lf_kunnr)
where parnr = @p_parnr
and kunnr ne @p_kunnr.
if sy-subrc ne 0.
return.

endif.


lv_contact-task = 'D'.
lv_contact-data_key-parnr = p_parnr.
ls_cmds_ei_extern-header-object_instance-kunnr = lf_kunnr.
ls_cmds_ei_extern-header-object_task = 'U'.
*-keep this entry in BP object
insert lv_contact into table ls_cmds_ei_extern-central_data-contact-contacts.
*-delete all relationships as a contact person in sales orgs
select * from knvp into table @lt_knvp where kunnr eq @lf_kunnr
and parnr eq @p_parnr.
loop at lt_knvp into data(la_knvp).
clear ls_cmds_sales.
ls_cmds_func-task = 'D'.
ls_cmds_func-data_key-parvw = la_knvp-parvw.
ls_cmds_func-data_key-parza = la_knvp-parza.
append ls_cmds_func to ls_cmds_sales-functions-functions.
ls_cmds_sales-task = 'U'.
ls_cmds_sales-data_key-vkorg = la_knvp-vkorg.
ls_cmds_sales-data_key-vtweg = la_knvp-vtweg.
ls_cmds_sales-data_key-spart = la_knvp-spart.
append ls_cmds_sales to ls_cmds_ei_extern-sales_data-sales.
endloop.
*-insert customer object
append ls_cmds_ei_extern to ls_cmds_ei_main-customers.

*-call delete function
if ls_cmds_ei_main is not initial.
call method cmd_ei_api=>initialize.
call method cmd_ei_api=>lock(
exporting
iv_kunnr = ls_cmds_ei_extern-header-object_instance-kunnr
importing
es_error = data(la_error) ).
try.
*-do appropriate action: wait, retry later ...
endtry.
call method cmd_ei_api=>maintain
exporting
is_master_data = ls_cmds_ei_main " pass all customer data
importing
es_error = p_s_error. " Error Indicator & System Messages
call method cmd_ei_api=>unlock( iv_kunnr = ls_cmds_ei_extern-header-object_instance-kunnr ).
* COMMIT WORK AND WAIT.
endif.
endmethod.

...


0 Kudos

Hi all,

I tried this code, but when contact is in de sales area, the program doesn´t delete the contact because it is active in roles.

Anyone have tried delete a contact with data in the sales area? .

Thanks a lot of for your help!!

Mª del Mar.