Skip to Content
Author's profile photo Former Member

User exit for Vendor Name Validation in XK01 Transaction.

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.

/wp-content/uploads/2013/08/01_268519.png

Define Short Text and Package.

/wp-content/uploads/2013/08/03_268523.png

Enter Name of an SAP enhancement – SAPMF02K.

/wp-content/uploads/2013/08/04_268524.png

Click on Components –

/wp-content/uploads/2013/08/05_268525.png

Double Click On – EXIT_SAPMF02K_001

/wp-content/uploads/2013/08/06_268526.png

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 lfa1name1.
tables : lfa1, lfb1.

types : begin of ty_lfa1,
name1
type lfa1name1,
end of ty_lfa1,

begin of ty_lfb1,
lifnr
type lfb1lifnr,
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 sytcode = ‘XK01’. “ tcode
if i_lfb1bukrs = .” 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_lfb1lifnr.
endif.

sort it_lfa1[].

if i_lfa1name1 is not initial.
loop at it_lfa1 into wa_lfa1.
if wa_lfa1name1 = i_lfa1name1.
message e899(f2) with wa_lfa1name1 ‘Vendor Name Already Exist With Another Vendor Code’.
endif.
clear wa_lfa1.
endloop.
endif.
endif.
endif.

Activate the code and exit.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jürgen Lins
      Jürgen Lins

      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.