Stored Procedure To Block if A/R Delivery Qty Qty in Sales Order

Hi Experts,
Can we Block to post the A/R Delivery Document if the quantity is greater than the quantity mentioned in the Sales order (Base Document).
If We can Please Help me with the procedure
With regards,
G.Eshvanth Singh

Hi,
Here is a store procedure to block delivery creation if its qty is exceeding SO qty:
IF @transaction_type IN (N'A', N'U') AND
(@Object_type = N'20')
begin
if exists (SELECT T0.BaseEntry, SUM(T0.Quantity)
FROM [dbo].[DLN1] T0 INNER
JOIN [dbo].[RDR1] T1 ON T1.DOCENTRY =
T0.BASEENTRY
WHERE T0.BaseType = 22 AND T0.ItemCode =
T1.ItemCode AND T0.BaseLine = T1.LineNum
and T0.DOCENTRY = @list_of_cols_val_tab_del
GROUP BY T0.BaseEntry
HAVING (SUM(T0.Quantity) > SUM(T1.Quantity)) or sum(t0.quantity) > sum(t0.BaseOpnQty))
begin
select @Error = 10, @error_message = 'GRPO
quantity is over PO quantity'
end
end
you place the SP_TN into your SQL server SBO company database programmability --> system store procedures --> dbo.SBO_SP_TransactionNotification --> right click this dbo --> select Script stored Procedure as select Alter to New query editor,
the result will be as follows:
@object_type nvarchar(20), -- SBO Object Type
@transaction_type nchar(1), -- [A]dd, <u>pdate, [D]elete, [C]ancel, C[L]ose
@num_of_cols_in_key int,
@list_of_key_cols_tab_del nvarchar(255),
@list_of_cols_val_tab_del nvarchar(255)
AS
begin
-- Return values
declare @error int -- Result (0 for no error)
declare @error_message nvarchar (200) -- Error string to be displayed
select @error = 0
select @error_message = N'Ok'
-- ADD YOUR CODE HERE
-- Select the return values
select @error, @error_message
end
GO
There are five out parameters:
Put the code I have given in the -- ADD YOUR CODE HERE part.
let me know your e-mail address if you want to have SP_TN pdf file from SAP
Rgds,

Similar Messages

  • Unable to block or throw credit limit message while posting Sales Order.

    Dear All,
    I hv created new customer and extended credit limit through FD32, assigned Risk Categeory and set the limit to 10,000/-.
    When i am posting Sale Order with 15,000 or more value, i am not getting any warning or error message while saving Sale Invoice. No block was set against delivery or billing in Sale Order.
    Kindly guide me, which step i am missing. FYI, customer dont hv any open item or credit exposure as of now becoz he was new customer.
    Regards,
    Venkat

    Option 1
    If your requirement is to go ahead with warning message and allow saving the sales document, maintain A in VOV8 for credit limit check.
    If you want to restrict creating sales order when credit limit exceeded maintain B in VOV8 for credit limit check.
    Option 2
    Now in OVA8 if you click on dynamic option. Make sure you satisfy these requirements
    The customer's credit exposure is split into a static part - open items, open billing, and delivery values - and a dynamic part, the open order value. The open order value includes all not yet or only partially delivered orders. The value is calculated based on the shipping date and the credit horizon you specify in the adjacent field. For the purposes of evaluating credit, you want the system to ignore all open orders that are due for delivery after the horizon date. The sum of the static and dynamic parts of the check may not exceed the credit limit.
    I would recommend with option 1, still if you want to go for option 2
    Then click on Static and make sure you also select open orders and open deliveries.
    This will happen if you select static
    The customer's credit exposure may not exceed the established credit limit. The credit exposure is the total combined value of the following:
    Open sales documents
    Open delivery documents
    Open billing documents
    Open items (accounts receivable)
    You can specify in the adjacent fields whether the system takes into account all open orders and all open deliveries.
    Regards
    Ravi.
    I am sorry i wont be able to add further input than this.
    Dont forget to reward points if you think it was successful

  • ATP Check at Delivery Level instead of Sales Order

    In Standard SAP, whenever a sales order is created the ATP check is done and a Goods movement 601 is done for it and gets blocked.
    I want that no movement to be carried out at Sales Order Level and should get blocked only at the Delivery level, instead of Sales order.
    Can i do this by not defining any movement type in the schedule line category attached to the Item category of the sales order.

    hi amit,
      u cannot remove MT assignment to SLCAT ,but what you can do is for your checking group and checking rule remove the ATP check relevancy in requirement class defination in spro customising >sd>availibility and TOR.
      so that in VOV4 transaction for your SLCAT atp will be deactivated.
    only while posting material doc at the time of PGI system would check for availibility and block the goods movement.
    reward if helps !!!!!

  • How to use order by in stored procedure base block?

    How to use order by in stored procedure base block? I need to change order by dynamically

    Use SET_BLOCK_PROPERTY('BLOCK_NAME',ORDER_BY,'COLUMN_NAME1, COLUMN_NAME2');

  • Block in delivery without ref to sales order

    Hi,
    I want to make a delivery without ref to sales order. But I want to block it after saving it. How to do that ?
    Can I assign a block at schedule line category level. Will that block the delivery ? Will this be an item block if this is  possible !
    regards
    Sachin

    Hello Sachin,
    I want to make a delivery without ref to sales order. But I want to block it after saving it. How to do that ?
    Use TCode VL02NO
    Can I assign a block at schedule line category level. Will that block the delivery ? Will this be an item block if this is possible !
    Delivery block at  schedule line category level will not block deliver doc, whereas, it will not allow you to create delivery doc with reference to that sales order with delivery block.
    Now for your requirement, to block a delivery doc for further processing. Maintain or select appropriate Reason for Rejection in Delivery Doc Item.
    Regards
    JP

  • Usage of delivery without reference to sales order

    Hi ,
    I want to know in which business scenarios we will create the delivery document without reference by usiing VL01NO followed by billing document.
    Anticipating a positive response
    Best Regards,
    Goutham

    Hello Sachin,
    I want to make a delivery without ref to sales order. But I want to block it after saving it. How to do that ?
    Use TCode VL02NO
    Can I assign a block at schedule line category level. Will that block the delivery ? Will this be an item block if this is possible !
    Delivery block at  schedule line category level will not block deliver doc, whereas, it will not allow you to create delivery doc with reference to that sales order with delivery block.
    Now for your requirement, to block a delivery doc for further processing. Maintain or select appropriate Reason for Rejection in Delivery Doc Item.
    Regards
    JP

  • Pricing in outbound delivery without ref to sales order

    Hello,
    I am creating a delivery without ref to sales order. I need to do pricing in the delivery for the material sold.
    1 ) I have never done the above. can someone tell  what are the config steps for  the same and what is the t code to create condition records (is it same as VK11 ).
    2 ) secondly I need to carry the pricing in the delivery to the proform invoice created with ref to delivery. How to do the same.
    regards
    Pamela

    Hi
    1 ) I have never done the above. can someone tell what are the config steps for the same and what is the t code to create
    condition records (is it same as VK11 ).
    Yes You need to maintain Condition Records Through VK11 only
    2 ) secondly I need to carry the pricing in the delivery to the proform invoice created with ref to delivery. How to do the same.
    But i am not why you required pricing procedure in delivery , but most the cases Delivery level we required Freight Charges
    At the time of Pro-forma Invoice system will pick the pricing procedure and you can check
    if you still want pricing procedure in Delivery level , assign Pricing procedure to Delivery Type
    Menu Path: SPRO> Logistics Execution>Shipping>Basic Shipping Functions>Pricing--->Define Pricing Procedures for Delivery
    Regards,
    Prasanna

  • Partial delivery per item in sales order and ATP - schedule lines

    Hi,
    I've problem regarding ATP- schedule lines and partial delivery flag.
    In sales order there is flag Partial delivery per item B / 1 . That means create only one delivery even with quant 0. That comes from customer master or customer info-record and it is OK.
    Please look at next example.
    Customer requires:
    10 PCS of materail A on date X. Only 5 PCS are available on date X.
    10 PCS of material B on date X 0 PCS are available on date X, 10 PCS are available on date Y.
    So if we create outbound delivery on date X it will contain only 5 PCS of material  A. No successive deliveries will be created for material A because of the flag B/1. That item is closed.
    Problem is with material B.
    The sales order will be open because of material B and on date Y we can easily create another delivery with 10 PCS of mat B.
    That is wrong. Agreement with customer is only one delivery for ALL items in sales order. If we create delivery on date X it should contain only materials which are available on date X and sales order should close.
    Do you know how to fix this problem?

    Hi,
    I've think you didn't understand my requirement. I allways get schedule lines but they are confirmed on different dates.
    Example in same sales order we have:
    Schedule line for item A:
    DATE X confirmed quantity 10
    Schedule line for an item B.
    DATE X confirmed quanitity 0 (zeroe)
    DATE Y confirmed quantity 10.
    I would like to create outbond delivery on date X with:
    item A quantity 10
    item B quantity 0.
    And if that hapens than B/0 rule will work or reference customzing that you suggested before. So order will be closed because all items are processed or referenced once.
    Do you know how to do that?
    Regards

  • I want to pick up Schedule line Delivery date based on Sales Order of Mater

    Hi Experts,
    I have one scenario like,
    I want to pick up Schedule line Delivery date based on Sales Order of Material.
    For example :
    Go to va03
    Give the order no
    Press the enter
    Double click on material.
    Go to Schedule line Tab
    Then we can find out the Delivery date .
    I want to pick up the that Delivery date. Could you please help on that.
    Thanks,
    Amjad.

    Hi,
    schedule line dates are available in VBEP.
    VBEP-VBELN = sales order number.
    VBEP-EDATU = schedule line date.
    REgards,
    Raghavendra

  • Sceduling as per the delivery confirmation date in sales order

    Hi,
    I am working with planning strategy 50 and using availabilty check as per ATP.
    When I create the sales order and check the availabilty, system confirms the delivery after TRLT(current date+TRLT).But when I run MRP,system creates a planned order on the req delivery date date.
    (Req date - GR Processing Time - In-House Production time) so that Planned Order is available on the req delivery date.
    As the system confirms the delivery after TRLT,I want my planned order's availabilty on the same date.
    to summarise,I don't want system to consider the Reqmt date as reqd delivery date of the sales order but the conformed delivery date of the sales order.
    I appreciate your help in letting me know if there is any way we can do this.
    Regards,
    Sastry
    Edited by: Sastry Krishna on Dec 13, 2008 4:45 PM

    Hi,
    Can you check what is the Variant (dates filed) specified by going to SM37 transaction.do as below,
    Goto SM37 transaction and give job name and then execute then select check box against date you scheduled job and then CtrlShiftF9,now place cursor on program/command and from the menu Goto-->Variant,here you check if any date range there.
    Regards,
    Chandra

  • Error when trying to create a delivery note from a sales order -  Internal error (-2010) occurred

    Hi
    I am trying to create a delivery note form a sales order in B1 V9 PL8 and I am getting the following error -
    Internal error (-2010) occurred
    The code has been working but we seem to be getting problems now
    Can anyone suggest anything please ?
    Copy of the code attached
    Thanks
    Andy

    Hi Andrew,
    Try replacing this line:
    odel.Lines.BaseLine = lineno - 1
    with this:
    odel.Lines.BaseLine = oorder.Lines.LineNum
    Beni.

  • Creation of Sales Delivery with reference to Sales Order

    Hi SAP Team,
    I tried making a Delivery with reference to Sales Order. Though in Item Category detemination of Delivery configuration, a separate
    Item Category has been configured, but still System picks up the one in Sales Order. Is there a way to get different Item Category at Delivery level.
    Also, for Subitems a different Item Category is proposed, but still it follows the same behaviour, which is at header level.
    Is there any way to change it.
    regards

    Hi,
    Maintain the required values in the T.Code "0184".
    Or follow the path:
    SPRO>Logistics Execution>Shipping>Deliveries>Define Item Category Determination in Deliveries.
    You have maintained the similar values for your delivery type same as sales order type that were maintained in "VOV4" T.Code.
    So that it getting the item category same as the sales order.
    Change the values here,so that new item categories will be appeared in delivery.
    Regards,
    Krishna.

  • Creation of Outbound delivery with respect to sales order

    Hi Gurus,
    I am an Abaper.
    I have a requirement to create outbound delivery with respect to sales order.
    Currently I have the purchase order details.  
    My coordinator has given me a logic.
    From the Purchase order, we have to get the Purchase requisition.
    From Purchase requisition, we have to get the sales order.
    From the sales order, we have to create the outbound delivery.
    Please explain me how to creaet the outbound delivery with respect to sales order.
    Also, how to get the PR from PO and SO from PR.
    Thanks in advance.
    Regards,
    Balaji. R

    Hi balaji,
    I will add the abap code since you are a ABAPER.
    1. To get the Pur. Req. from PO
    Note that PO_NO and PO_LINE_ITEM are variables.
           Select VEBLN VBELP  into (EBKN-VBELN,EBKN-VBELP)
           from EKPO inner join  EBKN on EKPOBANFN = EBKNBANFN
           where EKPOEBELN = PO_NO and EKPOEBELP = PO_LINE_ITEM
    2. And using VL01N you can create the relevant outbound delivery. Use above sales order for this. And record a BDC and write the code.
    Hope this will useful
    Thanks & BR
    sandun

  • Automatically creation of delivery group in the sales order

    Hi Can u please tell me how do i create automatically delivery group in the sales order.

    Hi,
    You can maintain the complete delivery indicator in your Customer Master(Ship to Party ) record shipping tab(Partial deliveries).
    As per SAP ,This indicator
    Indicates whether a sales order must be delivered completely in a single delivery or whether the order can be partially delivered and completed over a number of deliveries.
    There by it can form a Delivery group.
    Have a Nice Day.
    Regards,
    Ravi

  • Creation of Delivery with ref to Sales order

    Hello,
       I am trying to create the Delivery with reference to Sales Order using BAPI  -  BAPI_OUTB_DELIVERY_CREATE_SLS.
    At the of execution , i am getting the error No instance of object type OutboundDelivery has been created. External reference:.
    I have entered the sales order details in table parameter SALES_ORDER_ITEMS of BAPI. (Number range for Deliveries are internal)
    Can you please suggest me what could be the reason ?
    Regards
    Narayana

    Hi,
    Yes, copy controls are maintained for sales order type and delivery type in SPRO settings. The code as below.
    loop at t_vbap into ts_vbap.
          t_order-REF_DOC         = ts_vbap-vbeln.
          t_order-REF_ITEM        = ts_vbap-posnr.
          t_order-DLV_QTY         = ts_vbap-KWMENG.
          t_order-SALES_UNIT      = ts_vbap-VRKME.
          t_order-SALES_UNIT_ISO  = ts_vbap-VRKME.
          t_order-DELIV_NUMB = '0084000156'.
          append   t_order.
    endloop.
    call function 'BAPI_OUTB_DELIVERY_CREATE_SLS'
    *DESTINATION logsys
       EXPORTING
         SHIP_POINT              = '0010'
         DUE_DATE                = DUE_DATE
        DEBUG_FLG               = 'X'
      importing
         delivery                = lf_vbeln
         num_deliveries          = lf_num
      tables
         sales_order_items  = t_order
         deliveries                = lt_deli
         created_items         = lt_itm
         return                     = lt_return
    Can you suggest me.

Maybe you are looking for