Automatic Check of Duplicate Cust. Ref. No.'s in a Sales Order

Hi Everybody,
Does anybody know how to enable SAP B1 to automatically check if a Cust. Ref. No. has already been assigned to another sales order?  This seems like a basic function, but I can't seem to find it.  I checked under Document Settings, General Settings and Company Settings.
Thank you in advance,
Amanda

Hi
Use query below it will block all sales documents with duplicate references
Hope it helps
declare @cur_ref nvarchar(200)
declare @cur_code nvarchar(200)
declare @var nvarchar(10)
declare @table nvarchar (10)
declare @sqlstr nvarchar(2000)
declare @var1 nvarchar(10)
select @table = 0
--  CHECK FOR DUPLICATED REF NUMBERS
if((@transaction_type = 'A' or @transaction_type = 'U')and(@object_type = '13' or @object_type = '14' or @object_type = '15' or @object_type = '16' or @object_type = '17'))
BEGIN
     select @table = case @object_type
          when '17' then 'ORDR'
          when '15' then 'ODLN'
          when '16' then 'ORDN'
          when '13' then 'OINV'
          when '14' then 'ORIN'
     end
     select numatcard, cardcode into #temptable1 from OINV WHERE 1=0
     set @sqlstr='insert into #temptable1 select numatcard, cardcode from ['+ @table '] where docentry =' @list_of_cols_val_tab_del
     Execute(@sqlstr)
     select @cur_ref = numatCard from #temptable1
     select @cur_code = cardcode from #temptable1
     drop table #temptable1
     if @cur_ref = 'Duplicate Ref!!'
     Begin
          set  @var = 'true'
     end
     else
     Begin
          select numatcard, cardcode, docentry into #temptable2 from OINV WHERE 1=0
          set @sqlstr='insert into #temptable2 select numatcard, cardcode, docentry from ['+ @table +']'
          Execute(@sqlstr)
          set @var = (select distinct 'true' from #temptable2 where numatcard = @cur_ref and cardcode = @cur_code and docentry <> @list_of_cols_val_tab_del)
          drop table #temptable2
     end     
End     
if(@var = 'true')
begin
     select @error = 1
     select @error_message = N'Duplicate Customer Ref No. - Please Check Ref No. Because the ref that was enter, already exists in the system for this client'
end

Similar Messages

  • How to check whether MRP run has been executed for a sales order or not

    Dear Experts,
    In Strategy:20, Make to Order scenario, I have run MRP for sales order in T Code:MD50,
    then how can I check whether MRP run has been executed for a sales order or not.  Is there any report where I can find some indication?
    Thanks and regards,
    Vikas

    Dear,
    In MTO scenario with Planning strategy group 20 in material master .
    After sales order is created, Run MRP , then planned order will be created then go to planned order details in MD04 or MD12 you will get sales order number in assigment tab.
    or check the Table PLAF field  PALTR ,and field name KDAUF its sales order, for all created planned order.
    Regards,
    R.Brahmankar

  • How to avoid duplicated customer ref. no when create new sales order?

    Hi,
    In my company, we need input customer ref. no when create a new sales order, but I found there was no any validation to avoid input a existed number.
    Can somebody show me how to add some check function on this filed?
    thanks.

    Hi,
    This can be handled in standard system.
    Go to Administration> System Initialization> Document Settings>Per Document (Tab)> Select Sales Order-->Tick Block release (When duplicated  customer reference no. occurs).
    Thanks,
    Joseph

  • Duplicate purchase oredr number message need in sale order creation

    Hi,
    My requirement is for a user exit for sales order creation.
    When user create a sales order and put customer purchase order number based on purchase order number
    user entered it will check data base table and if its duplicate entry then throw the error.
    So, Requirement is :
    1: Give error for duplicate purchase order number.
    I need user exit name.
    Please help.
    Regards,
    Moderator Message: Please search before posting basic questions. Thread locked.
    Edited by: Neil Gardiner on Apr 29, 2011 9:31 AM

    Whether to allow duplicate PO numbers from a customer is a configuration setting....  However, what you're asking seems strange.... what has company code got to do with it, unless you want to allow PO numbers to dupllicate across SAP company codes...e.g., customer orders on PO #1 from company code 001 and PO #1 from company code 002....
    Usually, we would want to apply duplicate PO code checking at the customer number level, wouldn't we?  If customer 1 sends me PO #1 and customer 100 sends me PO #1, I certainly would want to accept both orders.
    Consult your SD functional specialist about configuring this option.

  • Automate Outbnd Delivry, pickng, packng & PGI at line level of Sales order

    Hi,
    We have a Sales Order having 2 line items,
    1] Article code as  "300845754" ,  Qty as " 2"  and  Plant as " 0607 "
    2] Article code as "300477532" ,  Qty as "4" and Plant as  "8330"
    Now when we save the sales order what we want is that for the first line item an automatic
    outbound delivery  as well as the Picking, Packing and Post Goods Issue must get generated.
    At the same time for the second line item only the outbound delivery must get generated automatically
    but picking, Packing and Post goods issue must not happen automatically.
    How can we do this, can any one pls help us ???
    Waiting for an immediate response

    Hi,
    It is possible through user-exit/Badi.
    To update PGI Status you can use user-exit "MB_CF001-Customer Function Exit in the Case of Updating a Mat. Doc." Or you can use BAdi "MB_DOCUMENT_UPDATE".
    To update Shipment document status you can use BAdi "BADI_LE_SHIPMENT-BadI: Shipment Processing".
    But how will you handle the partial delivery cases?

  • Automatic determination of Delivery type and Billing type in a sales order

    Hi,
    I want to know that in a sales order cycle, how does automatic assignment of delivery type and billing type takes place after we create a sales order?
    For example,when I create an outbound delivery for a sales order of type normal (OR) then in that case how does the system knows that it has to create an outbound delivery of type LF.How does the system propses it automatically and same is the case of billing document.

    Hi
    In customising the sales document type (Tcode VOV8) -
    specify the default Delivery type in the field DELIVERY TYPE in the 'Shipping' area of the sales document type customisation.
    Similarly you can specify the billing type in the BILLING area for both Delivery related billing and Order related billing.
    Thanks,
    Ravi

  • Query to check item no in all the rows in a sales order

    Dear All,
    Please assist me with a query which would be able to check the rows in a sales order to see if a particular item no is present. We are using SAP B1 2005 PL50
    Kind Regards,
    Monil.

    Hi !
    Try this !
    if @object_type = '17' and @transaction_type IN ('A', 'U')
    BEGIN
    if not exists (select t0.docentry from ORDR T0,RDR1 T1 where
    t0.Docentry = @list_of_cols_val_tab_del and
    t0.Docentry=T1.Docentry and
    T1.Itemcode in (select o1.itemcode from oitm o1) and T1.Itemcode = 'XXXXX'
    begin
    select @error = 1, @error_message = 'Add the item'
    end
    end
    Replace XXXXXX with your itemcode !

  • How to check for duplicates - with a twist?

    As I'm importing music from my CD collection, is there a way to automatically check for duplicates - with an unusual twist?
    I already imported about 70 CDs using AAC format.
    I just bought a huge external drive specifically for storing my entire collection of CDs and LPs. Now that I have lots of space, I want to import everything in Apple Lossless format.
    Is there an automatic (or at least painless) way to check for duplicates as I'm importing CDs, and to have the old AAC music files over written by the new Apple Lossless files?

    Hi Clinto,
    Do you see the column headers above in itunes? They say Title, Album, Artist, etc. I don't know if it's the same for MAC but in Windows, Right Click on the column headers and click "Kind". This will display the format each song is in. If your column headers already take up all of your screen, you're gonna have to uncheck one to make room for "kind".
    Oh! and to overwrite existing files, make sure the ID3 tags are filled exactly to the old ones prior to ripping, though you don't need to fill all of them. I think you just fill the Artist, Album Artist, Album, and Title. A window will appear as you start to rip. It will ask if you want to overwrite the existing files, click "Yes". Again, don't know about Mac but it works this way in Windows.
    Message was edited by: fullcream

  • How to ATP check when sold to party in sales order is changed?..

    Dear SD Gurus,
       I have one issue with ATP check in my current project where I need to change the the Sold to party of the sales order for a valid business case. We are using production allocation method for ATP check which reduces the Open PA qty once the sales order is saved.
    In the above scenario, once the Sold to party in sales order is changed, it redetermines everything and also goes through a ATP check which is cusing as an issue as it would again reduce the open PA qty for the same items in sales order for which are already taken into account. It would either reduce the open qty or propose the next date if it is no more available on that day.
    This is a big issue for us. Also it deleted the texts that are maintained.
    Does anyone know how to stop the ATP check in this (main issue) and also if possilble stop the deleteion of texts?
    Thank you very much for your help in advance..
    BR/
    Ashutosh

    Hello SAJU,
      The ATP check is done automatically when sold to party is changed..the issue is how to stop it? beacause of production allocation , it would be incorrect to reduce the open PA qty once more for the sales order when sold to party is changed. So I would like to stop it. Is there any exit or paramater by which we can stop ATP check?
    Thanks for your reply..
    BR/
    Ashutosh

  • Automatic credit release of blocked Sales orders with pre payment

    Hi ,
    We have a requirement as given below.Please suggest a better solution for this.
    The customers have the 'prepayment ' payment terms with different percentages of the sales order
    value to be paid before the delivery creation.
    When the sales orders are created, they are blocked for delivery by some credit block.
    The business use VKM1 transaction to view these blocked orders and release them manually for
    delivery creation after checking if the customer has made the prepayment.This is a tedious work
    (since there are too many sales orders )for the credit manager who dont have the complete
    visibility of how much prepayment the customer has made and need to manually check if the
    payment made covers the sales order prepayment amount to be paid.
    1. How can we do a automatic release of these blocked sales orders?
    2. Is there any program(which can be setup as batch job) to do a credit recheck and release the order
        automatically?
    3. Will Milestone billing plan functionality satisfy this requirement?If so how?
    We are using SAP version 4.7 without Project System.
    Thanks in advance.
    Regards,
    Ragesh

    Hello,
    This is not possible because when you created the sales order it has checked the credit limit for that credit limit and if you increase also now that block cant go automatically.
    Go to VA02 i.e change mode of sales order and change something and enter may be if you created a order for 2 quantity then go to VA02 and remove the quantity 2 and again type 2 then system will again check for credit and now that is increased so the order will not block..
    If this is for many order then you can run changes sales order  BAPI for mass update. Take help from ABAP guys.
    Cheers
    Say

  • Availability check run requirement in the Sales order Save user Exit.

    Hi Gurus,
    As per the requirment we are using a user exit SAVE SALE ORDER PREPARE for BOM purpose to reconfirm the confirmation qty.
    Now we need to add one more logic in the same user exit, which will run the availabilty check run for each of the line items of the BOM and consider latest confirmation qty from it. So my concern is it possible that we can call the availabilty check run event with in the user exit SAVE SALE ORDER PREPARE or this not advisable?
    Please let me know..
      Regards,
      Babs

    HI Venkat,
    Thanks for your reply.Yes you are right availability check runs automatically at sub item level.
    But please note the customer requirment iteself is is little different from std BOM configuration.
    Currently the availabilty check is activated both at header and sub item level. They are maintaining the stock for header and sub item level.Also the these sub items are some time being sold as invidual materials. hence there exist a mismatch in the stock value between header and sub items.
    when a sales order is created both header and sub items will have confirmation with different value between each and the same mismatched values are being passed in to delivery. But the deliveries can not be processed for PGI because of the mismatched confirmation qty between header and item level.
    I guess now you the rrequirment.
    So we are using the SAVE SALE ORDER exit which will re check the confirmed qty between header and item and takes lowest confirmed qty and change the confirmed quantities from all the line items to lowest one, so that confirmation qty among all the line items are same. This is the first logic we are planning.
    Further there is one more additional process BOP need to be run for this header and sub items, which will change the confirmed qty based on the latest stock for individual line item. even in this case also the user exit SAVE Sale order is being called but we need to run the availability check run additionally because of which our requirment will be taken care.
    Regards,
    Babs

  • How To Automatically Create Planned Orders When Sales Order Is Saved

    I have a MTO sceanrio where we need to create planned orders when sales orders are saved without running MRP.
    I have the Planning Strategy Group set to 81 in the material master, but it didnt create the planned orders.
    Could you tell me other settings I should review to make the planned orders create automatically?

    Tony,
    At the "Requir. Classes" (OVZG) customizing screen, field "Automatic start of make-to-order in background mode" affects the automatic planning. See fields help doc. below.
        If you select this indicator, the system automatically carries out
        single-item, multi-level planning for a sales order if a sales order
        item is either created or changed.
        This function can only be used for make-to-order production.
    So check out the Req. Cl that yr Req. type (req. type is part of a strategy).
    BR,
    Elly

  • Check if the Sales Order is credit block.

    Hello Everyone,
    I have a requirement related to third party sales order and delivery. In the first system, a sales is created and then the PO gets created. Upon the creation of the PO a IDOC gets generated. The inbound IDOC in the other system triggers and a sales order gets created. The requirement is that if sales order in the first system is on credit block then automatically the sales order in the second system should go on delivery block.
    The solution that I have thought is that when the IDOC gets created after PO generation there itself add a flag to IDOC in case of credit block in sales order. BUT HOW TO CHECK CREDIT BLOCK of the SALES ORDER IN THE CUSTOMER EXIT?
    Any help is appreciable.

    Hi Rahul,
    Need some more clarification on why sales order is created in the second system, if it is a third party process ?
    are you creating delivery from the corresponding sales order of second system to replenish sales order of first system ?
    are you using standard IDOC type for creating Sales order from PO ?, if so check the Corresponding Function module which may have user exists
    check Function module : IDOC_OUTPUT_ORDRSP
    At first system, if the sales order is credit block you can restrict creation of PR-->PO in the first system itself, this is a standard Functionality
    This would be easier than looking for user and coding in IDOC function module
    try and revert
    thanks
    santosh

  • PO no check in a Sales Order

    Hello All,
    I've a Sales Order, for the doc type, I've activated the PO check/duplicate PO check in VOV8. However, does the sys check this PO no we enter in the SO, against something?
    Does it have to do anything about the Sold to Party we use while creating the SO? 'My client wants to check, if the PO check can be set at SH level rather than SP level.' This confuses me, as I never knew that the PO is checked against a SP or something.. plz share..
    Fast response will be highly appreciated....
    Regards,
    Rags.

    Hi there,
    That PO check, is checking your sales order field "PO Number" - this is the sold-to party PO number because it is the SP that is purchasing from the company - the SH is just a destination.
    SO how does this check work? At the time of creating the sales order the system will look for the combination of sold-to party and PO number and if the same already exists it returns a message to inform the user accordingly and prompt for action.

  • Sales order with material having environmentally rlavant flag checked

    Hi All,
    I have a requirement where i have to develop a ALV for sales order details with material having environmentally rlavant flag checked during material creation.
    Problem: The details of sales orders are picked, whic dont have material.
    So I have used the following logic:
    1) data retrieval:
    select vbeln
           erdat
           auart
           kunnr
      from vbak
      into table it_vbak
      where erdat in s_erdat
        and auart in s_auart.
      if it_vbak is not initial.
        select vbeln
               matnr
          from vbap
          into table it_vbap
          FOR ALL ENTRIES IN it_vbak
          where vbeln = it_vbak-vbeln.
          if it_vbap is not initial.
            select matnr
                   kzumw
              from mara
              into table it_mara
              FOR ALL ENTRIES IN it_vbap
              WHERE matnr = it_vbap-matnr
                and kzumw = 'X'.
            endif.
        select vbeln
               bstkd
          from vbkd
          into table it_vbkd
          FOR ALL ENTRIES IN it_vbak
          where vbeln = it_vbak-vbeln.
         select vbeln
                parvw
                kunnr
           from vbpa
           into table it_vbpa
           FOR ALL ENTRIES IN it_vbak
           where parvw = 'WE'
             and vbeln = it_vbak-vbeln.
      endif.
            if it_vbpa is not initial.
            SELECT kunnr
                   adrnr
              from kna1
              into table it_kna1
              FOR ALL ENTRIES IN it_vbpa
              where kunnr = it_vbpa-kunnr.
              if sy-subrc eq 0.
                select addrnumber
                       name1
                       name2
                       street
                       city1
                       region
                       post_code1
                  from adrc
                  into TABLE it_adrc
                  FOR ALL ENTRIES IN it_kna1
                  where addrnumber = it_kna1-adrnr.
                   if it_adrc is NOT INITIAL.
                     select addrnumber
                            smtp_addr
                       from adr6
                       into TABLE it_adr6
                       FOR ALL ENTRIES IN it_kna1
                       where addrnumber = it_kna1-adrnr.
                  endif.
                    endif.
              endif.
    2) Reading the data:
    loop at it_vbak into wa_vbak.
    clear wa_final.
      read table it_vbap into wa_vbap with key vbeln = wa_vbak-vbeln.
      read table it_mara into wa_mara with key matnr = wa_vbap-matnr.
      read table it_vbkd into wa_vbkd with key vbeln = wa_vbak-vbeln.
      read table it_vbpa into wa_vbpa with key vbeln = wa_vbak-vbeln.
      read table it_kna1 into wa_kna1 with key kunnr = wa_vbpa-kunnr.
      read table it_adrc into wa_adrc with key addrnumber = wa_kna1-adrnr.
      read table it_adr6 into wa_adr6 with key addrnumber = wa_kna1-adrnr.
        wa_final-matnr = wa_mara-matnr.
        wa_final-bstkd = wa_vbkd-bstkd.
        wa_final-erdat = wa_vbak-erdat.
        wa_final-kunnr = wa_vbpa-kunnr.
        wa_final-name1 = wa_adrc-name1.
        wa_final-name2 = wa_adrc-name2.
        wa_final-street = wa_adrc-street.
        wa_final-city1 = wa_adrc-city1.
        wa_final-region = wa_adrc-region.
        wa_final-post_code1 = wa_adrc-post_code1.
        wa_final-smtp_addr = wa_adr6-smtp_addr.
        append wa_final to it_final.
        clear wa_final.
    endloop.
    Problem: The details of sales orders are picked, whic dont have material.
    So please suggest me the solution for this problem.
    With Regards,
    S.Asha.

    You are not filtering your VBAK records, after getting data from MARA table, Moreover I can see your consolidation logic is also wrong ..you can refer following pseudo code .
    LOOP at IT_VBAP.
    READ TABLE IT_MARA ..... based on material no in line item
    if sy-subrc = 0 .
    ...get the data from other internal table and pass it to WA_FINAL..
    APPEND WA_FINAL TO IT_FINAL..
    else .
       CONTINUE..
    endif .
    ENDLOOP .

Maybe you are looking for

  • MacBook Pro keeps crashing ever since upgrading to Mountain Lion

    My MacBook Pro keeps crashing randomly ever since I upgraded to Mountain Lion. Another user suggested that it was bug with the graphic card and suggested that I use gfxCardStatus to control it. However it is only a temporary fix and my computer still

  • Trying to understand oci8 refcursor bits

    Hi I have been using ADOdb for a while and sort of not thinking too much about it, but sort of trying to get some of the stuff. Perhaps I think too much like my old C programming daze and wonder about things that I should not. With that in mind I was

  • Can we please modify the Discussion Forums layout, especially the sidebars?

    I'd find the sidebars on the forums much more useful if I could modify them by doing one or more of the following: Remove particular boxes (close button in the top-right corner?) Reorder boxes (drag and drop?) Set box height (slider beneath each box?

  • Calling a DLL in soundrecord.vi

    In the example soundrecord.vi, is calling 5 functions using Call Library function, all of them within the same DLL. When is DLL loaded, everytime one of the functions is called (through Call Library Function) or just once when the soundrecord.VI is e

  • Photoshop cc très lent malgré une mise à jours des drivers

    Voici ma configuration : Adobe Photoshop Version : 2014.0.0 20140508.r.58 2014/05/08:23:59:59  x64 Système d'exploitation : Windows 8.1 64 bits Version : 6.3 Architecture système : UC Intel Famille :6, modèle :10, niveau :7 avec MMX, SSE Entier, SSE