User exit for Vendor Name Validation in XK01 Transaction.
.
By Sagar dev
PURPOSE:
In case we vendor creation enter the vendor name in the same vendor name all ready exits should get error/warning message. In XK01 (vendor name already exist with another vendor code).
Step by step Solution:
Go to transaction “CMOD”.
Click On Create Button.
Define Short Text and Package.
Enter Name of an SAP enhancement – SAPMF02K.
Click on Components –
Double Click On – EXIT_SAPMF02K_001
Double Click On include zxf05u01.
We have to implement the code and it will looks like this.
*&———————————————————————*
*& Include ZXF05U01
*&———————————————————————*
***************************************Data Declaration
data : v_name1 type lfa1–name1.
tables : lfa1, lfb1.
types : begin of ty_lfa1,
name1 type lfa1–name1,
end of ty_lfa1,
begin of ty_lfb1,
lifnr type lfb1–lifnr,
end of ty_lfb1.
data : it_lfa1 type standard table of ty_lfa1,
wa_lfa1 type ty_lfa1.
data : it_lfb1 type standard table of ty_lfb1,
wa_lfb1 type ty_lfb1.
**********************************************************
if sy–tcode = ‘XK01’. “ tcode
if i_lfb1–bukrs = ”.” company code
select lifnr
into table it_lfb1
from lfb1
where bukrs = ”. ” company code
if it_lfb1[] is not initial.
select name1
into table it_lfa1
from lfa1
for all entries in it_lfb1
where lifnr = it_lfb1–lifnr.
endif.
sort it_lfa1[].
if i_lfa1–name1 is not initial.
loop at it_lfa1 into wa_lfa1.
if wa_lfa1–name1 = i_lfa1–name1.
message e899(f2) with wa_lfa1–name1 ‘Vendor Name Already Exist With Another Vendor Code’.
endif.
clear wa_lfa1.
endloop.
endif.
endif.
endif.
Activate the code and exit.
you published a document.
The purpose of a document is to explain.
you just mentioned the goal and posted some unexplained coding lines
so it is a bit cumbersome why you are selecting from table LFB1 company code data if you want check a redundand name.
From my point of view it is to late to check for redundand names when you create company code data views, this should already happen when the address data is maintained.
Further you get only an error if the name matches 100%, a space more, a different entered abbreviation, a dot to less and you get no hit at all.