Locking in ABAP - Sales & Delivery

Hi all,
Our application is based on reading stocks tables(MCHB/MARD/MSKU/MSKA etc... ) and then do some calculations and finally update these tables back.
During the calculation phase we have acquired a exclusive(E) MARC lock.
Now we are getting into a problem :
If 2 users want to use the same stock (highly likely in sales scenarios) then untill calculation phase of user1 is complete the lock is not released and for user2 even though enough stock exists we cannot do the calculations because lock could not be acquired.
How can this problem be solved? Any hints will be of great help
Thanks
Maq

If you mean , Is the caculation time required? Ofcousre it is. Thats the heart of the application.
However what would happen if i lock individual tables like MCHA,MARD,MSKU,MSKA etc... that would atlesast allow posting goods for batch which is not currently locked for example..
Regards,
Maq

Similar Messages

  • Crystal Report for Sales, Delivery and Payment.

    Hi Guys,
    Need some expert advice over here. Currently, our sales team are using 3 separate report, one report on sales per month for each specific customers, one report on delivered amount per month for specific customers again and the last one report on payment received per month for specific customers as well.
    We have the idea of joining this 3 report so that I can report on sales, delivery and payment all at once so that they can see the trend better. However, after trying for quite a few times, we fail to create a common joining between ORDR, ODLN and ORCT. Is there any possible way to work something out ?
    I have thought of using subreport, but I just cant find the way to plug in the figure correctly.
    Need some advice over there.
    Thank you.
    Best Regards,
    Alex

    Based on what you have told me, then you should then join Sales Order, Delivery, Invoice and Incoming Payments into one.
    The reason I say Invoice table also is because, you cannot directly link Delivery and Incoming Payments window.
    Also you it is not enough that you link the ORDR, ODLN and ORCT, you will need to get the details from RDR1 and DLN1.
    In SAP Business One, each line in SAP Business One can have a different Delivery documnet.
    The TrgetEntry, TargetType will give you this information. For example, if a line for Sales Order has TargetType 15, then TrgetEntry will be the DocEntry in the ODLN. But if it TargetType is 13 it means the Sales order was converted directly to and Invoice and bypassed the creation of Delivery step, which is possible in SAP.
    So here is how I think you will need to link Sales order and Delivery
    RDR1.TrgetEntry INNER JOIN DLN1.DocEntry AND
    RDR1.TargetType INNER JOIN DLN1.ObjType AND
    RDR1.LineNum INNER JOIN DLN1.BaseLine
    Now this could get a little more complicated if you do partial deliveries. For example if a line in your Sales Order has say 10 items and 6 of them are delivered using Delivery Note 123 and the remaining are delivered using Delivery Note 124, then the join will give you 2 different lines.
    So basically you will need to link the tables in this fashion
    ORDR <-> RDR1 <-> DLN1 <-> INV1 <-> RCT2 <-> ORCT
    Unfortunately, this linking process can get complicated if you do not follow certain steps, like for example if you do not create a Delivery Note and converted your Sales order to Invoice. Then the link would be
    ORDR <-> RDR1 <-> INV1 <-> RCT2 <-> ORCT
    I hope I didn't confuse you.
    Krishnan

  • Creating Excise Invoice from Sales Delivery using DI API.

    Hi Experts,
    I have been searching a lot for any Business Object for creating Excise Invoice base on Sales Delivery using DI API.. But have not yet found any one.
    I want to create Invoice for excisable items from Sales Delivery using DI API.,for Excisable items we cannot create standalone A/R Invoice . We need to create Excise Invoice also . But How to create Excise Invoice based on Sales Delivery using DI API. Is there any Business Object for that.
    Please suggest me.
    Thanks and Regards,
    Pooja Singh.

    Hi all,
    I have not received any reply for this thread. Does this mean that there is no provision for creating Excise Invoice from Sales Delivery ? Actually I was asked to create sales delivery and then Outgoing Excise Invoice and then Sales Invoice using DI API.
    But I don't find any Business Object for this in SDK ? Is it really not possible to create Outgoing Excise Invoice from Sales Delivery using DI API.? If possible then how?
    Please reply me if anyone has got any idea in this regard.
    Thanks and Regards,
    Pooja Singh.

  • Correct procedure to transfers Sales Delivery to Sales A/R Invoice

    Hi,
    Is there someone who can white some code to explain the best way to transfers a Sales Delivery to A/R Invoice with the SDK the same way as Copy To (A/R Invoice) from the Delivery window in SAP ?
    I've been successful at transfering one by hand saving every properties of the document source to the document destination for a simple document
    but now I'm faced with documents that have BP's with Credit Limit exceeded etc..etc and I'm getting (XXXX) Internal Error (-5002) occured
    Which XXXX is different from one document to another

    Hi Marc,
    I don't think there is a simple procedure as such because there are quite a few ways to code this, depending on your requirements. It obviously gets more complex where you are copying multiple deliveries to a single invoice or splitting a delivery in to multiple invoices based on the originating orders. If you use additional expenses (eg freight) then you also need to copy this across otherwise it will be left on the delivery and never invoiced.
    It makes sense to check for available credit before you add an invoice. In this way you can give a much more user-friendly error message than the one that SBO gives (ie the 5002 error). You'd still need to trap any errors returned by the Add method.
    Kind Regards,
    Owen

  • Block the Quantity in Sales Delivery

    Hi,
    I want to block the Quantity in Sales Delivery if it is Exceeding the Quantity in Sales Order.
    The scenario is..............
    I m creating a sales order for one or more line items with Quantity as 100.
    based on this sales order i m creating a Sales delivery (it can b partial too)
    if the Deliver Quantity exceeds the Order Quantity,
    either it shoudn't allow the Document to b added
    or show a error msg
    Thanks in advance

    Hi,
    Please select this and paste in "SBO_SP_TransactionNotification"- Stored Procedure
    IF @transaction_type IN (N'A', N'U') AND (@Object_type = N'15')
    BEGIN
    declare @numlinii int
    SELECT @numlinii = (LineNum + 1) FROM DLN1
    WHERE DLN1.DocEntry = @list_of_cols_val_tab_del AND
    ((Quantity > BaseOpnQty))
    ORDER BY LineNum ASC
    IF (not ISNULL(@numlinii, 0) = 0)
    BEGIN
    SET @error = 10
    SET @error_message = N'Quantity is invalid in Line ' + CONVERT(nvarchar(4), @numlinii) + N' !'
    end
    END
    SAGAR

  • Lock the ABAP Workbench in EHP installation

    I'm installing the EHP5 for ERP, and in pre-processing phase witn EHPI installer, therefore i lock the ABAP workbench
    The installation guide say this:
    The installation program asks you in this phase to confirm the lock of the ABAP Workbench on all SAP instances. This lock is needed to prevent development objects (for example, ABAP reports, table definitions, and so on) from being changed during the installation process, since these modifications would be lost.
    You can continue to use your SAP system in production operation, even if you confirm that the ABAP Workbench can be locked. However, after you have confirmed the ABAP Workbench lock, no more transports can be made into or out of the SAP system.
    The installation program waits until the time you entered as the maximum synchronization time for all the instances has expired.
    I have some questions about that.
    1. I know that I can´t do transport from development system. But can I open the client and do manual modifications?(Urg3nt corrections). WilI I lost  these modifications after downtime?
    2. After finish the pre-processing phase, the installation ask for a full backup, but also give an option:
    Go productive Again
    What's the meaning of this option???  If I select Go productive Again, can I do transports again?
    If yes, I lost the installation process? and Must I restart the installation from beggining or the installation can be resumed re-starting the ehpi installer.
    I don't have very clear f I select Go productive Again what really happen and how to do urg3nt changes while the installation is running.

    Dear Manfred, Please find the reply to your queries
    1. I know that I can´t do transport from development system. But can I open the client and do manual modifications?(Urg3nt corrections). WilI I lost these modifications after downtime?
    Answer : You will loose modifications if you perform manual modifications after locking and the changes wont be available after downtime phase.
    2. After finish the pre-processing phase, the installation ask for a full backup, but also give an option:
    Go productive Again -
    Answer : This option is provided as a backout solution - this means this is the last stage/screen from where you can return to your current system(system before upgrade) - After passing this stage/screen system can be reverted back to previous stage from SAP level.
    What's the meaning of this option??? If I select Go productive Again, can I do transports again? -
    Answer : If you select go productiive again you system will be back to normal state as you started before EHPi.
    If yes, I lost the installation process? - Installation process as in you would need to build the shadow instance again with the pramaters provided.
    and Must I restart the installation from beggining or the installation can be resumed re-starting the ehpi installer. - Answer :  I would suggest re-set the installation process and remove EHPi instalaltion directories before starting the instalaltion again.
    Hope it helps.
    Regards, Amber S | AO

  • Locking in ABAP

    hi folks,
    Can anyone explain what is Locking in ABAP? How do you do it? Any examples would help me to understand this process.
    Thanks in advance
    Vinu

    Hi vinu,
    You can use these functional modules....
    <b>BAL_DB_ENQUEUE</b>----
    >Lock log
    <b>ENQUEUE_ESFUNCTION</b>---->Lock an abap program so that it
                           cannot be executed.
    <b>1. Example code for Database Locking...</b>
    http://www.sapdevelopment.co.uk/dictionary/lock_enqueue.htm
    <b>2. Help.Sap.Com</b>
    http://help.sap.com/saphelp_nw04/helpdata/en/7b/f9813712f7434be10000009b38f8cf/content.htm
    Hope it helps.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • Multiple printing option of Sales, Delivery and Billing

    Hi All,
    How to take multiple print of sales, Delivery and Billing from Standard transactions.

    Hi
    You have to handle in the driver program by writing the function modules
    START_FORM....WRITE FORM...END_FORM in the loop of documents
    example for sales orders:
    Sort ITAB by vbeln.
    loop at ITAb.
    at new VBELN.
       call function  START_FORM....
       endat.
       call function  WRITE FORM.
    at end of vbeln.
       call function  END_FORM..
    endat.
    endloop.
    Reward points if useful
    Regards
    Anji

  • Creation of Sales Delivery via SDK

    Hi,
    I'm using SAP B1 2004A(6.70.190) PL32.
    Can anyone tell me definitively, if it is possible to create a Sales Delivery based on MULTIPLE Orders for the same BP, via the SDK?
    Thanks for any help,
    Robin

    If anyone is wondering, you can...

  • Exit to block Sales Delivery and Invoice?

    Hi Experts,
    Does there exist any exit to block the sales delivery and invoice?

    badi LE_SHP_DELIVERY_PROC
    Regards.

  • Linking column for sales,delivery  and invoices

    I just have a question regarding database schema in SAP B1.
    I would like to know   how SAP b1 links
    Sales Delivery and invoices
    In other words
    i want to know all invoices based on Sales and delivery
    all invoices based on  just delivery etc
    What is the linking field or column between these three tables
    rdr1, dln1,inv1
    How does Sap keep track of whether a invoice is based on sales or delivery or
    both.? I appreciate your help.
    Thanks,
    Josh

    Hi Joshua,
    What you need to look at are the BaseEntry, BaseType and BaseLine fields in the item row (ie INV1 or DLN1). It works as follows:
    BaseType = The originating document type where 17 is a sales order and 15 a delivery
    BaseEntry = The DocEntry of the originating document
    BaseLine = The LineNum of the originating document
    A simple example is as follows:
    1) I create an order (DocEntry 10) with 2 rows (LineNum 0 and 1)
    2) I create a delivery (DocEntry 5) based on this order with both rows. In the DLN1 table my rows will have BaseEntry 10, BaseType 17 and BaseLine 0 and 1.
    3) I create an invoice for the second row from the delivery. In the INV1 table I will see BaseEntry 5, BaseType 15 and BaseLine 1.
    You also have TargetType and TargetEntry which show the target document details but these are not that useful as they only show the last target number and type and cannot be used where you have multiple target documents.
    Kind Regards,
    Owen

  • Shippment, sales delivery tables

    Hi Friends,
    Can any one help me on..
    How MKPF table is linked with the Delivery, LIKP LIPS or the Shipment VTTK, VTTP or with the sales tables VBAK VBAP.
    I have data in my Internal table which is a pull from Sales, Delivery and the Shipment table. I need to add MKPF-MBLNR to this internal table.
    Any suggestions.
    Ster.

    Hi,
    Please check table MSEG.
    MSEG-KDAUF = VBAP-VBELN
    MSEG-KDPOS = VBAP-POSNR
    Regards,
    Ferry Lianto

  • Approval Query  for Sale Delivery Problem

    Hello,
    I have to set approval procedure of Sale Delivery in following condition
    If i add sale order for Specific item for 10 Qty for example C01 customer & after that i add sale order for same item qty 10 for another customer ie C02 & i have stock for that item 50 but user give delivery first to C02 in staid of C01 but C01 give me first order
    on this condition i have to set approval user can't deliver second sale order first he have to take approval from manager to do this & he deliver first order first then then don't have to need approval.
    Can any one help me?

    Hi,
    Row level approval is not possible in SBO.
    You may check this for your reference: http://www.beonesolutions.com/ip/Solutions/ap.html
    Thanks,
    Joseph

  • Sales Delivery Reports. Fields

    Dear All Experts.
    I making a Sales Order Reports. Using Following Tables.
    VBEP , VBAP ,  VBPA , VBKD , VBAK , LIKP , LIPS , KNA1
    I successfully Search Other Fields.
    But i cant Find exact field for PENDING QTY, PENDING WEIGHT, ORDER QTY, PENDING VALUE, SCHEDULE OR PLANNED delivery & Next Schedule.
    Please Give me help for this Field with table name.
    Bhavesh Panchal
    SAP ABAP.
    Baroda.

    Dear All experts.
    How to Initialization of Field Calculatio in ABAP code Syntax. Please Guide me for setting UP in ALV Grid
    Report.
    Also Decleration of Global variable. it can be Used Any where via code.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'NTGEW'.
      wa_fieldcat-seltext_m = 'Net Weight'.
      wa_fieldcat-outputlen = '10'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Please Give Me Syntax of the following calculation in ALV Grid programs :
    *WEIGHT = WEIGHT + ( ( VBAP-NTGEW / VBAP-KWMENG ) * VBAP-KBMENG ).*
    Thnks in Advance :
    Bhavesh Panchal.

  • How to implement locking in ABAP

    Hello everyone,
        I am doing dialog programming and I have a screen that creates some template. When the user opens up the screen it defualts to next available template number to be created (for example if template No 1 exists then it will default to template no 2 so template 2 will be created). But if multiple users open up the screen then it will show template 2 for both of them and I want to avoid this, i.e. I like to implement some locking mechanism so one user opens up the screen that template is locked and the other cannot create the same template. Please share any ideas and suggestions, how I can imeplement this!
    Thanks.
    Mithun

    Hai  Mithun Dha
    Lock Objects
    The R/3 System synchronizes simultaneous access of several users to the same data records with a lock mechanism. When interactive transactions are programmed, locks are set and released by calling function modules (see Function Modules for Lock Requests). These function modules are automatically generated from the definition of lock objects in the ABAP Dictionary.
    Structure of a Lock Object
    The tables in which data records should be locked with a lock request are defined in a lock object together with their key fields. When tables are selected, one table (the primary table) is first selected. Further tables (secondary tables) can also be added using foreign key relationships (see also Conditions for Foreign Keys).
    Lock Arguments
    The lock argument of a table in the lock object consists of the key fields of the table.
    The lock argument fields of a lock object are used as input parameters in the function modules for setting and removing locks generated from the lock object definition. When these function modules are called, the table rows to be locked or unlocked are specified by defining certain values in these fields. These values can also be generic. The lock argument fields therefore define which subset of the table rows should be locked.
    The simplest case of a lock object consists of exactly one table and the lock argument of the table is the primary key of this table. Several tables can also be included in a lock object. A lock request therefore can lock an entire logical object, and not only a record of a table. Such a logical object can be for example a document comprising an entry in a header table and N entries in a position table.
    Locks can also be set from programs in other systems with the corresponding interfaces if the lock object was defined with RFC authorization.
    A lock mode can be assigned for each table in the lock object. This mode defines how other users can access a locked record of the table.
    Table SFLIGHT in the  flight model contains all the scheduled flights of a carrier. Field SEATSMAX contains the number of seats available. Field SEATSOCC contains the number of seats already booked. If a booking is made for a customer (by a travel agency or sales desk), you must check whether there are enough seats available. The number of seats booked is incremented when the booking is made.
    This mechanism must ensure that two sales desks do not make the same booking at the same time and that the flight is not overbooked.
    This can be done by creating lock object ESFLIGHT. Only the table SFLIGHT must be included in this lock object. The flight can then be locked (with the function modules generated from the lock object) when booking. If another sales desk also wants to book seats for this flight, the lock will prevent the flight from being overbooked.
    Activating a lock object in the ABAP Dictionary automatically creates function modules for setting (ENQUEUE_<lock object name>) and releasing (DEQUEUE_<lock object name>) locks.
    The generated function modules are automatically assigned to function groups. You should not change these function modules and their assignment to function groups since the function modules are generated again each time the lock object is activated.
    Never transport the function groups, which contain the automatically generated function modules. The generated function modules of a lock object could reside in a different function group in the target system. Always transport the lock objects. When a lock object is activated in the target system, the function modules are generated again and correctly assigned to function groups.
    Parameters of the Function Modules
    Field Names of the Lock Object
    The keys to be locked must be passed here.
    A further parameter X_<field> that defines the lock behavior when the initial value is passed exists for every lock field <field>. If the initial value is assigned to <field> and X_<field>, then a generic lock is initialized with respect to <field>. If <field> is assigned the initial value and X_<field> is defined as X, the lock is set with exactly the initial value of <field>.
    Parameters for Passing Locks to the Update Program
    A lock is generally removed at the end of the transaction or when the corresponding DEQUEUE function module is called. However, this is not the case if the transaction has called update routines. In this case a parameter must check that the lock has been removed.
    Parameter _SCOPE controls how the lock or lock release is passed to the update program (see The Owner Concept for Locks). You have the following options:
    _SCOPE = 1: Locks and lock releases are not passed to the update program. The lock is removed when the transaction is ended.
    _SCOPE = 2: The lock or lock release is passed to the update program. The update program is responsible for removing the lock. The interactive program with which the lock was requested no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
    _SCOPE = 3: The lock or lock release is also passed to the update program. The lock must be removed in both the interactive program and in the update program. This is the standard setting for the DEQUEUE function module.
    Parameters for Lock Mode
    A parameter MODE_<TAB> exists for each base table TAB of the lock object. The lock mode for this base table can be set dynamically with this parameter. Valid values for this parameter are S (shared), E (exclusive) and X (exclusive but not cumulative).
    The lock mode specified when the lock object for the table is created is the default value for this parameter. This default value can however be overridden as required when the function module is called.
    If a lock set with a lock mode is to be removed by calling the DEQUEUE function module, this call must have the same value for the parameter MODE_<TAB>.
    Controlling Lock Transmission
    Parameter _COLLECT controls whether the lock request or lock release should be performed directly or whether it should first be written to the local lock container. This parameter can have the following values:
    Initial value: The lock request or lock release is sent directly to the lock server.
    X : The lock request or lock release is placed in the local lock container. The lock requests and lock releases collected in this lock container can then be sent to the lock server at a later time as a group by calling the function module FLUSH_ENQUEUE.
    Behavior for Lock Conflicts (ENQUEUE only)
    The ENQUEUE function module also has the parameter _WAIT. This parameter determines the lock behavior when there is a lock conflict.
    You have the following options:
    Initial value: If a lock attempt fails because there is a competing lock, the exception FOREIGN_LOCK is triggered.
    X : If a lock attempt fails because there is a competing lock, the lock attempt is repeated after waiting for a certain time. The exception FOREIGN_LOCK is triggered only if a certain time limit has elapsed since the first lock attempt. The waiting time and the time limit are defined by profile parameters.
    Controlling Deletion of the Lock Entry (DEQUEUE only)
    The DEQUEUE function module also has the parameter _SYNCHRON.
    If X is passed, the DEQUEUE function waits until the entry has been removed from the lock table. Otherwise it is deleted asynchronously, that is, if the lock table of the system is read directly after the lock is removed, the entry in the lock table may still exist.
    Exceptions of the ENQUEUE Function Module
    FOREIGN_LOCK: A competing lock already exists. You can find out the name of the user holding the lock by looking at system variable SY-MSGV1.
    SYSTEM_FAILURE: This exception is triggered when the lock server reports that a problem occurred while setting the lock. In this case, the lock could not be set.
    If the exceptions are not processed by the calling program itself, appropriate messages are issued for all exceptions.
    Reference Fields for RFC-Enabled Lock Objects
    The type of an RFC-enabled function module must be completely defined. The parameters of the generated function module therefore have the following reference fields for RFC-enabled lock objects:
    Parameters
    Reference fields
    X_<field name>
    DDENQ_LIKE-XPARFLAG
    _WAIT
    DDENQ_LIKE-WAITFLAG
    _SCOPE
    DDENQ_LIKE-SCOPE
    _SYNCHRON
    DDENQ_LIKE-SYNCHRON
    All the tables that can be included in a lock object must be linked with  foreign keys. There are a number of restrictions to the valid relationships.
    The foreign key relationships of the tables of the lock object must form a tree. The tables are the nodes of the tree. The links of the tree mean is the check table of.
    The foreign key fields must be key fields of the foreign key table.
    The foreign key relationships defined between the base tables of the lock objects may not have any field that is checked against more than one other field. A field therefore may not occur twice as foreign key field in a relationship and may not be checked against two different fields in two different foreign key relationships.
    You must keep one restriction in mind for  multi-structured foreign keys. If a field is assigned to a field that is outside the check table, the table containing this field must be in a sub-tree that contains the check table of this foreign key relationship as a root.
    These conditions are always satisfied if the key of the foreign key table is an extension of the key of the check table.
    Conditions 2, 3 and 4 are meaningless if the particular foreign key field was excluded from the assignment to the key fields of the check table by  marking it as generic or setting it to a constant. This is also true for multi-structured foreign keys if the foreign key field refers to a table that is not contained in the lock object.
    Regards.
    Eshwar.

Maybe you are looking for

  • New Adobe CS6 continuously crashing on Mac 10.6.8

    Why might this be happening? All that the crash report says is "Adobe could not find any solutions or workarounds for the recent crash in Adobe Audition CS6." Has this happened to anyone else?

  • Auto run CD menu from Flash

    Hi, I want to create an auto run menu for One of the installers.The requirement is that swf gets launched as soon as I insert the first CD ,but under certain conditions it'll ask for another cd(say 2nd CD) ...so when I take away the First CD and inse

  • SGE2000 slow forwarding as accessswitch with LACP to SG500X stack

    Hello everyone, Question: Does any body know why  ports on my SGE2000 take so long (>60s) before forwarding packets to  the end user systems (desktop computers). I got two SG500X switches stacked in 10G mode and got two SGE2000 switches connected in

  • Hlep in deleting Componantes using Key event listeners.

    Hi All, I am tring to write a GUI program. I am dragging componets from the left side of the panel to the right side of the panel. Everything works well as of now. But i am tring to delete the componets which i placed on the right side of the paenl u

  • Windows 7 failure to reload after recent hard disk replacement

    I have just had my hard disk replaced under the recent Apple program.  It was partitioned running Mac one side and Windows 7 through Bootcamp Windows on the other. Time machine restored my Mac partition but I am unable to load Windows 7 on the Bootca