Additional check in Delete Transaction

I'd like to add 2 if statements to the this delete transaction and check the @rowcount value before the COMMIT, is this the correct way to do it:
DECLARE @APP_ID uniqueidentifier
SET @APP_ID = '1234'
BEGIN TRY
BEGIN TRANSACTION;
--There could be more than 1 record deleted from this Table
DELETE
FROM dbo.SERVERS_APPS
WHERE SA_APP_ID = @APP_ID
IF @@ROWCOUNT >= 1
--There should only be than 1 record deleted from this Table
DELETE
FROM dbo.ENVIRONMENTS_APPS
WHERE ENVA_APP_ID = @APP_ID
IF @@ROWCOUNT = 1
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH

Instead of the way you have written, I would suggest that you write only one IF statement checking the count of the records as required.
DECLARE @APP_ID UNIQUEIDENTIFIER
SET @APP_ID = '1234'
BEGIN TRY
BEGIN TRANSACTION;
IF (SELECT COUNT(1) FROM dbo.SERVERS_APPS
WHERE SA_APP_ID = @APP_ID)>=1
AND
(SELECT COUNT(1) FROM dbo.ENVIRONMENTS_APPS
WHERE ENVA_APP_ID = @APP_ID)=1
BEGIN
DELETE
FROM dbo.SERVERS_APPS
WHERE SA_APP_ID = @APP_ID
DELETE
FROM dbo.ENVIRONMENTS_APPS
WHERE ENVA_APP_ID = @APP_ID
END
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
The climb is all there is.

Similar Messages

  • How to enforce a check before deleting a transaction

    Hi,
    We want to restrict the deletion of order based on status . Eg: When the status of the order is Inprocess , deletion should be aborted with error message.
    Is there a BAdi to achieve this?
    Thanks,
    Shaik

    Hi Shaik,
    As of you cannot directly delete any Business Transaction. You can use the SAP Archiving to Achive and then delete the Transactions. You can have a look at the following link for the SAP Archiving for CRM
    http://help.sap.com/saphelp_crm70/helpdata/en/e1/f5fc37a0ca3144e10000009b38f8cf/frameset.htm
    For Archiving and then Deletion of Orders, have a look at the following link:
    http://help.sap.com/saphelp_crm70/helpdata/en/e1/f5fc37a0ca3144e10000009b38f8cf/frameset.htm
    This will give you a detailed information about the Activity of Carrying out the Data Archiving
    http://help.sap.com/saphelp_crm70/helpdata/en/09/72f63ad65c3b5ce10000000a11402f/content.htm
    For the Check and Delete Archiving Object,
    http://help.sap.com/saphelp_crm70/helpdata/en/85/1cc041e01e6624e10000000a1550b0/frameset.htm
    Hope this will help.
    Thanks,
    Samantak

  • Condition type check in va01 transaction

    Hi friends,
    I have a requirment.
    in va01 transaction , at the line item level iam entering a  material number and order quantity and  when i press enter i get the corresponding values for that particular line item.
    now iam double clicking on that particluar line item(matnr) and clicking on the conditions tab.
    there in the condtion type i will get what all the condition types are maintianed for that particular line item.
    now my requirment is i need to add another concdtion type manully
    say 'ZABC' and hit enter. the pricing for that particlular contion type 'ZABC' will be Determined.
    Now  can any one tell me in which internal table will i get all the condition type,
    coz i need to do some additional check for the  the manual entry'ZABC'  (condition type ) which i have given .
    which user exit should i use it.
    remember i need user exit for condition type check but not for pricing bsaed on the contion type
    Regards
    Priyanka.

    Hi priyanka
    If you want to Check  then check in the  KOMK and KOMP tables
    As you want to go for user exit use any one of the user exits as per your requirement  USEREXIT_PRICING_PREPARE_TKOMK  or USEREXIT_PRICING_PREPARE_TKOMP
    But can you tell what exactly you want to change and why you want to go for user exits
    Regards
    Srinath

  • Additional fields in MIGO transaction

    Hi Everybody,
      We have a requirement where we need to have additional fields in MIGO transaction when the user chooses 'distribute qty' option to split the quantity, the normal screen shows the following fields,
    1. Qty in UnE
    2. Stock type
    3. Movement type
    4.Stor location, we need Serial number, Drum number in Screen number 1000 of SAPLMIGO program,  Can any one tell me how do I achieve this functionality,
    Rgds,

    The only option I see is design your own custom screen with the required fields and call it as popup ( Modal Dialog Box ) from user exit ZXMBCU02 .
    This user exit will be triggered when you click on "CHECK" or "SAVE" button.
    There is no way to modify MIGO screen itself , so maybe you will have to pass the item number etc from MIGO and have a table control on your custom screen for data entry.
    For saving data into database donot use this exit as a user may just check and go out and you will unnecssarily push the data into z table . In this exit do an export to memory for your custom fields.
    In another exit ZXMBCU01 , do an import from memory and update the required Z table . This exit is called while updating material document in update task.
    However to goto popup screen for displaying chnaging custom fields you will have to press "CHECK" button , maybe a user training issue.
    Cheers

  • Delete transaction in SNP and data inconsistency in product view

    Hi,
    After i run the  SNP heuristics,system is creating PurRequisition say in DC 1500 sourcing from 1510. But in the product view of 1510 location,there is no PurReqRel is visible.This is happening for some products. And also when i use Delete transaction, /SAPAPO/RLCDEL - Delete Transaction Data , i am getting the messages orders are deleted. But when i look in product view,orders are not deleted. This issue is for all the products. we are using SCM5.0. I have run all the consistency checks like OM17,time series check etc. Any one got the same issue?
    Any suggestions?
    Thanks & Regards
    Akthar
    Edited by: Aktar Ahmed Shaik on Nov 17, 2009 3:51 PM

    Hi Akthar,
    Please raise this question in SCM-APO Forum as i hope there is no problm in R/3.
    Regards
    Suri

  • On my email, my delete boxes that I check to delete old emails have become doted lines and I can no longer check so many at one time to delete

    I have a local internet provider and when I log onto my account thru Firefox there use to be a square box to the left side of the email that I could check to delete how ever many I wanted to on that page at the same time. Now those boxes have become little dots and you can't check them to delete them. The boxes are still there when I log on thru Google chrome. Please let me know what to do. Thanks, Daryl

    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Troubleshooting extensions and themes]]
    Check and tell if its working.
    Some of your Firefox Plugins are out-dated
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

  • Best Practice for Mass Deleting Transactions

    Hi Gurus
    Can you please guide on this - We need to mass delete Leads from the system. I can use Crm_Order_Delete FM. But want to know if there are any best practices to follow, or anything else that i should consider before deleting these transactions from the system.
    We have our archiving policy under discussion which may take some time, but due to large volume of reduntatn data we have some performance issues. For example when searching for leads and using ACE, the system goes through all the lead data.
    That is the reason we are plannign to delete those old records. My concerns is that using CRM_ORDER_DELETE, would it clear all the tables for those deleted transactions and if there are any best practices to follow.
    Thanks in Advance.
    Regards.
    -MP
    Edited by: Mohanpreet Singh on Apr 15, 2010 5:18 PM

    Hi,
    Please go through the AppModel application which is available at: http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
    The OnePage Table Based example shows exactly how to use deleting multiple rows from a datatable...
    Hope this helps.
    Thanks,
    RK.

  • TS3899 After updating to ISO6, my email sending get extremely slow or dispeard. on the botton line of mail page always indicate "sending # of 9", however I do not know where to check or delete these unsent items. Please help! It has consumed lots of data.

    After updating to ISO6, my email sending get extremely slow or dispeard. on the botton line of mail page always indicate "sending # of 9", however I do not know where to check or delete these unsent items. Please help! It has consumed lots of data.
    I use @me.com and @hotmail.com

    Hi,
    >>A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
    Ok, but on the other hands:
    SGMS@ORACLE10> create table x (name char(10), name2 varchar2(10));
    Table created.
    SGMS@ORACLE10> insert into  x values ('hello','hello');
    1 row created.
    SGMS@ORACLE10> commit;
    Commit complete.
    SGMS@ORACLE10> select vsize(name),vsize(name2) from x;
    VSIZE(NAME) VSIZE(NAME2)
             10            5
    SGMS@ORACLE10> select dump(name),dump(name2) from x;
    DUMP(NAME)                                         DUMP(NAME2)
    Typ=96 Len=10: 104,101,108,108,111,32,32,32,32,32  Typ=1 Len=5: 104,101,108,108,111Cheers

  • CRM - Process Flow of Authorization Check in Business Transactions

    Hello Folks:
    I have implemented CRM security using Process Flow of Authorization Check in Business Transactions.
    What I have in place:
    CRM_ORD_OP (inactive, don't want access to own documents)
    CRM_ORD_LP (inactive, not using standard org level values Distribution Channel, Sales Group, Sales Office, Sales Organization, and Service Organization.)
    CRM_ACT (active)
    CRM_CMP (active)
    CRM_ORD_OE (active, restricted to display with dummy value ' ' for Distribution Channel
    Sales Group, Sales Office, Sales Organization and Service Organization, as we are not restricting on them)
    CRM_ORD_PR (active and restricted to display)
    Issue:
    Restrictions to display for documents works fine when using CRM backend system and the system throws out a message that you are not authorized to change. But, when i come in through Portals (PCUI), i dont get the display at all and it throws out a message insufficient access authorizations.
    Traces on backend CRM reveal failing on change access for CRM_ORD_LP and CRM_ORD_PR, which we dont want to give out b/c we dont want to provide change for documents.
    OSS notes to SAP have resulted in no results....please advise what is wrong here.
    Thanks
    KT

    Thanks for the Priyanka for the reply, but what you mention is not correct.
    BSP errors are different from what I am refering to.
    The issue is still open...and looks like a SAP bug, which even they havent been able to fix so far.
    Regards,
    KT

  • Authorization Check in Business Transactions

    Hi All,
    i need to create Authorization Check for Business Transactions ( create/display/change ).
    The standart sap Authorization  object CRM_ORD_OP  or CRM_ORD_LP is no good for me .
    does  anyone know  a BADI or something else i can use ?
    Thanks
    Lilach.

    I would suggest to give the authorization with CRM_ORD_OE if he isn' t in the document may be he is the organization which is selected on the activity..
    For details, please have a look at this link :
    http://help.sap.com/saphelp_crm70/helpdata/EN/48/a44236ceb873e8e10000000a42189b/content.htm
    BR,
    Cenk Sezgin

  • Delete Transaction Data from date to date

    Hi All,
    we want to delete transactional data from date to to date
    is there any way to delete data from date to todate?
    We are aware of following tcodes
    OBR1- Reset transaction data
    CXDL - Delete transaction data from ledger
    But there is no period/from date to date option available
    Example:
    we are in 2010 now we want to delete data from 2005- 2007 and we don't want to archive
    Thanks in advance
    Regards,
    MS

    Hi Eli,
    Thanks for the reply,
    Yes, you are right its not right to delete data based on the period... but we have such kind of typical scenario
    Let me get some other opinion
    Regards,
    MS

  • Additional Tab in Billing Transaction

    Hi,
    I have a requirement of adding an additional tab in the billing transaction VF01 / 02 / 03. Please can you help me suggesting any BADI or EXIT avaialable.
    I found BADI_SD_TAB_CUST_H and it is for internal use only.
    Thanks in advance.

    Hi
    SAP Note Number 302497 Additional cust. fields not displayed in 'Additional data B' and related notes tells you how to do it.
    Other useful notes:
    SAP Note 386694 - Additional data not displayed in screen 8459 and 8309
    SAP Note 420546 - Additional data B and transaction variants in sales order
    SAP Note 209278 - Display of customer-specific fields in sales doc
    Regards
    Eduardo
    Edited by: E_Hinojosa on Feb 17, 2011 3:48 PM

  • Check in Billing Transaction

    Dear All,
    I want to place a Check in Billing Transaction that the Billing Date must be equal to the ACTUAL GI DATE of the Delivery Document. There are chances that sometimes User changes the Billing date while generating the Billing Document.
    So please tell whether it can be possible through Customization or not. If possible then how?
    If not possible, then please tell me the best UserExit in which I should write the code for it.
    Regards,
    Vishal

    Hi Lakshmi,
    But this userexit i.e. USEREXIT_NUMBER_RANGE_INV_DATE has one condition that if this exit is activated then USEREXIT_NUMBER_RANGE will be DEACTIVATED.
    And already in USEREXIT_NUMBER_RANGE, a code has been written to get the Billing Number.
    Now the question is: Should I put the same code in this USEREXIT_NUMBER_RANGE_INV_DATE also?
    Regards,
    Vishal

  • [svn] 2644: First pass at unifying layout APIs between UIComponent and GraphicElement, more to come with additional check-ins.

    Revision: 2644
    Author: [email protected]
    Date: 2008-07-28 16:58:09 -0700 (Mon, 28 Jul 2008)
    Log Message:
    First pass at unifying layout APIs between UIComponent and GraphicElement, more to come with additional check-ins.
    reviewed by Ryan, Glenn, Gordon, Chet
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/core/Group.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/BitmapGraphic.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Ellipse.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/FilledElement.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/IGraphicElement.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Line.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Path.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Rect.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/StrokedElement.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/TextBox.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/TextGraphic.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/graphicsClasses/GraphicElement .as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/graphicsClasses/TextGraphicEle ment.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • Check whether a transaction is running

    I need to know if there is a function I can use to check whether a transaction is being run by a specific user.

    hi,
    there is some stand teransaction called STAT(not sure abt the name ) which gives u the details abt the last reun transaction run pls chekc that out... or go to table TSTC and give STA* it will disply u some transaction just read the help info to find out the transaction..
    check also the transaction STAD..
    Thanks
    Ashu

Maybe you are looking for

  • What do I do when my Firefox profile is missing or inaccessible?

    HP support helped me resolve an overheating issue with my Notebook laptop by remotely connecting to my laptop. Now I can't start Firefox. It says it is already running but it's not and I keep getting the missing profile error. I am using my cell phon

  • MySQL database overflow??

    I am using a MySQL database which contains data on bankaccounts. For example, person X has 4 accounts. These accounts are listed in a selectbox. By clicking on one of the accounts, the page is refreshed with the account ID. When an ID is set, more de

  • IPad & music videos.

    I have about a dozen music videos I bought from the iTunes store but I can't get them into my iPad. I have tried the help file and it told me to Create iPad version, no help, tried it with QuickTime too. What gives?

  • Define column width in standard transactions

    Hi all I'd like to have wolmn width optimized to the content of cell in standard transactions like ME23N, ME53N ... i'd like ti customize this optimisation for all system users at once. Heve you any idea??? Thanks in advance. Regards

  • Rates Configuration Question

    Hi Gurus To configure the Rates it is necessary to update under these 2 Config Option: SPRO -> IMG -> Collaboration Projects -> Connection to External Systems -> Accounting Integration -> Define Cost/Revenue Rates (Replicate to ERP) SPRO -> IMG -> In