Dear all,
we were facing problem regarding duplicate material creation since our MM end user were not co-ordinating with each other and
moreover there was no check and measures to stop creating duplicate material since Material number is a auto generated number.
We solved this problem by using an exit in SAP where you can check the material by its Description before posting data.
Please note that this is useful if the current material description is same to the previously created material Description.
Step 1: create a project using CMOD
Step 2: Use enhancement MGA00001
Step 3: Use exit EXIT_SAPLMGMU_001
Step 4: Double click on the include and write the below code in INCLUDE ZXMG0U02.
Step 5:
DATA: wa_stext TYPE short_desc,
s_maktx TYPE maktx.
CLEAR: s_maktx,wa_stext.
READ TABLE stext INTO wa_stext INDEX 1.
IF sy–subrc = 0.
SELECT SINGLE maktx FROM makt
CLIENT SPECIFIED INTO s_maktx
WHERE mandt = sy–mandt
AND maktx = wa_stext–maktx.
ENDIF.
IF s_maktx IS NOT INITIAL AND sy–tcode = ‘MM01’.
MESSAGE ‘ERROR: Material already exists …’ TYPE ‘E’ .
ENDIF.
**************
** Note: you can use CONDENSE if you want to compress spaces and then check.
**************
Thanks
Debdutta Satpathy
Dear Debdutta Satpathy,
Thanks for your effort , can you tell me is your shot text enter by user or it is automatically generate ?
Suppose if it is enter by user :
Case # 1 : User A type Shot text “ADAPTOR_IRN75K-CC”
User B type Shot text : “ADAPTOR _IRN75K-CC”
by mistake one space is press by user “B” between “ADAPTOR” and “_” .
then is your code find this two material or material shot text is duplicate .
Regard’s
Smruti
Dear Smruti Ranjan
1) shot text is enter by end user who creates the material
2) ADAPTOR_IRN75K-CC and ADAPTOR _IRN75K-CC are two different material description and it cannot be checked.
This exit will help you to know whether a material with same description is allready created or not. This will definitely minimize duplication of material.
What you can do , take a monthly audit to check whether any duplicate material is created within that month sorted by Description and UserID. You will find the reality and take necessory action upon it.
Note: 1) This exit will only help you to know whether a material was created earlier with the same Description or not.
2) Any user can by pass this exit by putting a dot or a space in between or by changing the description.
Thanks
D.Satpathy
I think you need to remove all spaces and special characters are possible between words, to bring all the letters to uppercase and have compared such texts. Probability of finding duplicate will be much higher.
And a few more comments. No need to use the extension CLIENT SPECIFIED, а mandant and it will be used. Then primary key for table MAKT includes the language of registration, so I think it would be correct to write:
READ TABLE stext INTO wa_stext WITH KEY SPRAS = sy-langu.
IF sy-SUBRC = 0.
SELECT SINGLE maktx FROM makt
INTO s_maktx
WHERE SPRAS = sy-langu AND
maktx = wa_stext–maktx.
ENDIF.
We can solve the SPACE problem by using CONDENSE
CONDENSE both the user’s input removing spaces and then match the inputs.
This is the way how space can be eliminated.
But still special character’s are considered.
Hope your query is solved.
Thanks
D. Satpathy
for Removing Special character use “REPLACE ALL OCCURRENCES OF REGEX” .
like :
PARAMETERS: I_INPUT TYPE STRING.
REPLACE ALL OCCURRENCES OF REGEX ‘[^ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 / – .] ‘ IN I_INPUT WITH SPACE IGNORING CASE.
CONDENSE I_INPUT NO-GAPS .
WRITE:/ I_INPUT .
Regard’s
Smruti
You could use soundex to block even similar sounding descriptions. But in that case, you’d want to prompt the user ( “hey look – there’s this material with a similar description. Are you sure?”), rather than straight out block.
Dear Sir,
Could you please tell me the syntax of soundex
I could not find it in abapdocu.
Thanks
D.Satpathy
Try wikipedia. It’s not an ABAP specific thing.
And there’s metaphone as well. To be honest, I’ve not found them that useful for identifying closely matching descriptions.
Use this Sample Code …
http://sample-code-abap.blogspot.in/2010/01/soundex-function-module-for-abap.html
Mine’s shorter: i_input and e_output are type string.
I’ve been recently involved in a development which attacks this very same problem. Thanks! your post just fell down from heaven 😛
thank you for information
need more correction in this program.
Material not extending to other plant because of this program.