How to avoid duplicate customers creation?

1. Using LSMW , XD01
want to test data, before loading with a RADIO button option to user.
a) 'Radio button' TEST -- To test for errors in data file
b) Display Error records in excel file

c) 'Radio button' Create customer
d) Display created records in excel file

2. How to avoid duplicate customers creation -- Internal number range.
e)Say if customer with "ex: check if KNA1-legacy number is existing, then don't commit the data, go to next record.

How to code these requirements in LSMW

Thanks

Nik

Duration: 
1 month

Comments

1
Jimbo's picture

Hi Nik,

The option to turn off testing for errors is a novel idea, but can be done easily enough with the snippet from this article.
https://www.saplsmw.com/Add_parameters_to_an_LSMW_object_and_describe_them

A simple query and an if statement will suffice to prevent the creation of duplicate records based on the ALTKN field in KNA1. If your source structure is called XD01S and the parameter is p_check then the code would look like this:

select single KUNNR from KNA1 into BKN00-KUNNR
 where ALTKN eq XD01S-ALTKN. 
if sy-subrc eq 0 and p_check eq 'X'. 
  write: / XD01S-ALTKN, "Customer already loaded.".
  skip_transaction. 
endif.