Skip to Content

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 sysubrc = 0.
  SELECT SINGLE maktx FROM makt
  CLIENT SPECIFIED INTO s_maktx
  WHERE mandt = symandt
  AND   maktx = wa_stextmaktx.
ENDIF.

IF s_maktx IS NOT INITIAL AND sytcode = ‘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

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. Venkata Giridhar

    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

    (0) 
    1. Debdutta Satpathy Post author

      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

      (0) 
      1. Олег Точенюк

        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.

        (0) 
      2. Олег Точенюк

        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_stextmaktx.

        ENDIF.

        (0) 
    2. Debdutta Satpathy Post author

      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

      (0) 
      1. Venkata Giridhar

        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


        (0) 
  2. Matthew Billingham

    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.

    (0) 
        1. Matthew Billingham

          Mine’s shorter: i_input and e_output are type string.

            data: l_output  type string,
                  l_len     type i,
                  l_letter  type c,
                  lt_letter like standard table of l_letter.
          
            l_output = i_input.
          
            translate l_output to upper case.
            condense l_output no-gaps.
          
            if strlen( i_input ) le 1.
              concatenate i_input '0000' into l_output.
              e_output = l_output(4).
              exit.
            endif.
          
            l_output = i_input+1.
            translate l_output using 'A E H I O U W Y B1F1P1V1C2G2J2K2Q2S2X2Z2D3T3L4M5N5R6'.
            condense l_output no-gaps.
          
          * Remove double letters
            l_len = strlen( l_output ).
            do l_len times.
              l_letter = l_output(1).
              insert l_letter into table lt_letter.
              if l_output is not initial.
                l_output = l_output+1.
              endif.
            enddo.
          
            delete adjacent duplicates from lt_letter.
          
            clear l_output.
            loop at lt_letter into l_letter.
              concatenate l_output l_letter into l_output.
            endloop.
          
            concatenate l_output '000' into l_output.
            condense l_output no-gaps.
          
            concatenate i_input(1) l_output(3) into e_output.
          
          (0) 

Leave a Reply