MV45AFZZ extra validations

Hi all,
I'm trying to set some more validations on USEREXIT_SAVE_DOCUMENT_PREPARE.
If some of these validations are not true, is it possible to not allow to save?
Thanks,
Luis Cruz

Dude... You got to be kidding me. Have you at least tried it? The error message will be displayed, then the users can go back and change anything they want and then do Save again. In the worst case add
fcode = 'ENT1'.
before the error message.

Similar Messages

  • Authentication & Extra Validation (JAAS)

    I'm trying to figure out how to implement a couple of extra authentication checks into my site, without having to write a custom realm.
    So far the options I have come up with are below.
    The first one, which would be the preferred method, but I'm not sure if its feasable is bind the action parameter of a commandButton to a method, have that method check the additional items, if it passes that validation it sends the data to j_security_check, if it doesn't it redirects to the login failed page.
    The second option, is to just use custom validators on the form to do the additional checks and if they fail it'll show the error in a message or message bundle. I'm a little concerned about this though because a real smart user could figure out that a user account doesn't exists or not based upon this if not coded perfectly.
    Suggestions?

    Hi,
    For sample code of the badi,refre this link:
    https://wiki.sdn.sap.com/wiki/display/SRM/BBP_DOC_CHECK_BADI-CheckPurchasingDocument.
    Also pls explain data you need to fetch from R/3.You can always use META function modules to fetch data from any external system.
    See these related threadS:
    Re: ECC Purchase Order Replication to SRM SC
    RFC Call to R/3 from EBP during creation of SC from CCM
    BR,
    Disha.

  • Need Extra Validation for Attachments in Leave Requests

    Hi All,
    We intend to validate whether a user requesting for leave (ex.: Sick Leave) using SSHR has attached any documents or not (in case the request is for more than 5 days).
    Can someone please help me out with this? I tried to do this by using 'User Hooks' but the hooks that I have used so far (create_absence_entry BP, per_absence_attendances RH) validate the data on the absence entry page itself (i.e. even before the review page where files are attached is reached).
    Is there any user hook available on the review page in SSHR? Or, is there any alternative to this method?
    - Vikram

    Hi,
    If so your Message Flow is -
    RFC->XI->Http->RFC(R/3)->File
    After getting the response you need to send the Response back to the R/3 and same time the response should be sent to File system. Now you can go for BPM here.
    This blog will give you some idea-
    /people/arpit.seth/blog/2005/06/27/rfc-scenario-using-bpm--starter-kit
    So your BPM will contain these steps-
    1) Receive the RFC Request
    2) Send the RFC request Synchronoulsy
    3) Recieved Response will be mapped to the file system structure
    4) send the Mapped file structure
    Asumption is Mapping i.e Request to Http Request and Http Response to RFC response is done outside the BPM.
    Hope this helps,
    regards,
    Moorthy

  • FI-REFX Add additional validation to monthly posting

    Dear,
    We would like to add extra validations to the standard posting programs RERAOP/RERAPP (and their reversal programs RERAOPRV/RERAPPRV). These are standard SAP transactions within Real Estate to make (monthly) postings on the contract. Each contract contains a rental object (= the building or part of the building).
    An additional validation should be made on the profit center used in the posting (which is derived from the rental object) if the profit center is active for the company code used.
    If not active, it should not generate any posting for the contract in which the rental object/profit center is used and generate a standard error log - as done by the default program & give a detailed error message.
    The problem is that there is no user exit available/found to add an additional validation or to add an error message to the error hierarchy + to prevent the posting.
    We can add the error message to the error hierarchy in display (transaction SLG1), but not in the execution (update mode) of the program.
    Can anyone please advice on how to proceed to have this additional validation added please?
    Many thanks!
    Steps to reconst
    RERAPP or RERAOP with contract which contains a rental object that is linked to a profit center which is not active for a certain company code.
    Error message should be given: For contract X, profit center Y is not active for company code Z.
    Indicator should be red (error) and no posting should be made.
    Many thanks!

    Dear Pk,
    Thank you for your idea. Eventually this would be the way to go as the validation I need is indeed based on data in gl_je_lines in status other than 'P' - Posted.
    There are several posting programs that are called in several ways.
    The posting programs are:
    - Posting -- Executable: GLPPOS
    - Posting: Single Ledger -- Executable: Posting: GLPPOS
    - Program - Automatic Posting -- Executable: GLPAUTOP (this will submit the GLPPOS)
    The ways to post journals in GL (except SLA journals) are:
    - run the Program - Automatic Posting
    - push the "Post" button on the journal entry form
    - use the Jpurnal -> Post navigator function
    In this case the validation I need would imply the forms customization + custom posting wrapping program.
    I was looking for a way of adding one more validation to the standard list of validations for the GLPPOS executable as this is the only executable being responsible for posting in GL.
    Thanks again for your response,
    Cosmnin

  • Regarding the validations in File Upload.

    Hi
    I am Using the X:InputFileUpload> for uploading of the my file and i am using validator class for checking the validation like if the file name is null. But i need one more validation to check the file format like if i have enter any special characters and invalid file format(SSS) i want give a message to the user.
    Please suggest me how can i approach using Myfaces.
    Thanks in advance.
    Regards
    Satish

    I have never used myfaces implementation but I am sure you can just define your own custom validator and attach it to this component or assign a method binding to its validator attribute to perform extra validation.

  • How to trap Submit button event in OAF

    Hello,
    I'm doing controller extension for create account button in Customer UI.
    Issue: I'm not able to trap the table action to add extra validation logic.
    I tried to use pageContext.getParameters("CreateButton") but it didn't work i.e. debug message was not printed written inside if statement.
    Button Structure:
    TableAction
    Flowlayout
    Submit button.
    Code:
    public void processFormRequest(OAPageContext pageContext,
                                       OAWebBean webBean) {
            //super.processFormRequest(pageContext, webBean);
            OAApplicationModule am = pageContext.getApplicationModule(webBean);
            ArrayList exceptions = new ArrayList();
            OAFlowLayoutBean oaflowlaybean =
                (OAFlowLayoutBean)webBean.findChildRecursive("TableActionsRN");
            OASubmitButtonBean vbuttonBean =
                (OASubmitButtonBean)oaflowlaybean.findChildRecursive("CreateButton");
            String buttonId = vbuttonBean.getID();
            String buttonId12 = vbuttonBean.getName();
            String asd=vbuttonBean.getEvent();
            String s = pageContext.getParameter(EVENT_PARAM);
            String s1 = pageContext.getParameter(vbuttonBean.getName());
                if (s.equalsIgnoreCase("CreateAccount")) {
                OAViewObject vo =
                    (OAViewObject)am.findViewObject("HzPuiAccountTableVO");
                if (vo != null) {
                    pageContext.writeDiagnostics("Jai-1", "VO Found", 1);
                    OARow row = (OARow)vo.getCurrentRow();
                    if (row != null) {
                        pageContext.writeDiagnostics("Jai-2", "Row Found", 1);
                        String partyid =
                            (String)row.getAttribute("PartyId").toString();
                        pageContext.writeDiagnostics("Jai-3", "PartyId" + partyid,
                                                     1);
                        int PartyNum = Integer.parseInt(partyid);
                        String partyacctcnt = null;
                        try {
                            OracleConnection conn =
                                (OracleConnection)pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();
                            pageContext.writeDiagnostics("Jai-4", "Inside Try", 1);
                            String query =
                                "SELECT count(1) lcount  FROM HZ_CUST_ACCOUNTS WHERE party_id=:1";
                            PreparedStatement stmt = conn.prepareStatement(query);
                            stmt.setInt(1, PartyNum);
                            ResultSet resultset = (ResultSet)stmt.executeQuery();
                            if (resultset.next()) {
                                pageContext.writeDiagnostics("Jai-5",
                                                             "Inside Result Next",
                                                             1);
                                partyacctcnt = resultset.getString("lcount");
                            stmt.close();
                        } catch (SQLException sqlexception) {
                            throw OAException.wrapperException(sqlexception);
                        int i = Integer.parseInt(partyacctcnt);
                        /*   String HoldFlag = (String)row.getAttribute("Attribute11");
                        // Check Hold Flag: "Y" then restrict to create new account
                        if (HoldFlag == "Y") {
                            pageContext.writeDiagnostics("Jai", "Inside Hold Flag", 1);
                            exceptions.add(new OAException("XXGCO",
                                                           "XXTCO_CREDIT_LIMIT_CHECK",
                                                           null, OAException.ERROR,
                                                           null));
                        // One Party-One Account: Greater or Equal to 1 then throw error mesaage
                        if (i > 1) {
                            pageContext.writeDiagnostics("Jai-6",
                                                         "Inside Account Check",
                                                         1);
                            exceptions.add(new OAException("XXGCO",
                                                           "XXTCO_CREDIT_LIMIT_CHECK",
                                                           null, OAException.ERROR,
                                                           null));
                        if (exceptions.size() > 0) {
                            pageContext.writeDiagnostics("Jai-7",
                                                         "Inside Exceptioon calling",
                                                         10);
                            OAException.raiseBundledOAException(exceptions);
                        } else {
                            pageContext.writeDiagnostics("Jai-8",
                                                         "Inside else Exceptioon calling",
                                                         10);
                           // super.initParametersPFR(pageContext,webBean);
                            vbuttonBean.setFireActionForSubmit(null, null, null, false);
                            super.processFormRequest(pageContext, webBean);
    Please suggest the how to overcome with above mention issue.

    Hi Kiranmai,
    You can capture the event of the radio button in the following way in oninputprocessing.
    DATA: event             TYPE REF TO if_htmlb_data,
                   radioButton_event TYPE REF TO CL_HTMLB_EVENT_RADIOBUTTON.
             event = cl_htmlb_manager=>get_event( request ).
             IF event IS NOT INITIAL AND event->event_name = htmlb_events=>radiobutton.
               radioButton_event ?= event.
               ENDIF.
    you can get the attributes of clicked radio button in
    event->event_class
    event->event_id.
    event->event_name
    event->event_type
    event->event_server_name
    In layout define the radio button as
    <htmlb:radioButtonGroup   id          = "test_id">
            <htmlb:radioButton      id          = "id_red"   text = "Red"               onClick="myClick" />
            <htmlb:radioButton      id          = "id_blue"  text = "Blue"          onClientClick="alert('blue clicked')"/>
            <htmlb:radioButton      id          = "id_green" text = "Green"      onClick="myClick" onClientClick="alert('green clicked')"/>
          </htmlb:radioButtonGroup>
    Hope this will solve your problem.
    Donot forget to assign points for helpful answers.
    Regards
    Aashish Garg

  • Error while accessing public holiday calendar on 20120101

    Dear All,
    When I'm posting PL(Personnel Leave) against 31.12.2011 it is working fine but If I'm posting a Sick Leave against 31.12.2011 or CB the error is coming like "Error while accessing public holiday calendar on 20120101".
    Please suggest what to do.

    Dear All,
    When I'm posting PL(Personnel Leave) against 31.12.2011
    it is working fine but If I'm posting a Sick Leave against 31.12.2011 or
    CB the error is coming like "Error while accessing public holiday calendar on 20120101".
    Please suggest what to do.
    the error clearly saying that you dont have holiday calendar for 01.01.2012,, so please change it using PT02 to avoid the error.
    then you check what exactly system is doing.
    you have to create a wsr with one month extra validity than the exact periods required to avoid the future errors as you are getting now.
    system always takes one month extra validity it is standard functionality.
    regards,
    mohammed

  • EM doesn't allow creation of tnsnames.ora entry with service name orcl11gr2

    Dear all,
    I'm trying to create a net service name with EM Database Control, via Net Services Administration link. On the service name field, under the 'Edit Net Service Name' screen, I key in orcl11gr2, and it throws the the following error:
    Validation Error
    Examine and correct the following errors, then retry the operation:
    Service Name - Specify a valid service name.
    I wonder what is the extra validation that EM is checking. I assume it's checking the number of characters to be 8 characters or less.
    Also, because of this extra validation that is in EM, all tnsnames.ora entry that have service name = orcl11gr2, I will not be able to use EM to modify them, as I will get the same above error.
    But why does Oracle implements this extra validation, when the same validation is not implemented on other Oracle tools? For instance:
    1. dbca allows me to create a database with instance_name greater than 8 characters, and the outcome of initialization parameters will be as follow:
    db_name=orcl11gr -- truncated to 8 characters
    instance_name=orcl11gr2
    db_unique_name=orcl11gr2
    service_names=orcl11gr2
    2. Oracle Net Manager supports service name of orcl11gr2. The created Net Service Name, I have no problem connecting to the database.
    3. Listener support orcl11gr2 service name
    I'm using Oracle 11g R2 (11.2.0.1.0) for Microsoft Windows (x64), running on Windows 7.

    For your reference, here is the bug numbner: 10278345.
    -Mughees

  • Print requirement for PO

    We are previously using requiremnet 101 for "XNEU" and YNEU,etc..  MESSAGE TYPE.
    But now user want add extra validation on this .
    <b>We only want to create an output for condition type XNEU if the tracking number contains a value. The tracking number on the Pur. Order is stored in EKPO-BEDNR</b>
    so how go ahead regarding this.
    regards,
    srini..,

    Hi,
    Welcome to SDN club!!!
    Can you give some more details about your requirement? It will help you to get solution very fast.
    Do you want to validate whether a tracking number exists for the purchase order when just before taking print out?
    If the above is true, please provide us your transaction name.
    Thanks
    Ramakrishna

  • Delivery address in PO Creation through ME21N

    Hi All,
    I want to change the Delivery Address in ME21N. By default this delivery address is the Plant address which we enter at the line item level. Now my requirement is to default the delivery address to other address based on the vendor given at the header level.
    I had tried User exit, MMDA0001 but this is not triggering, then tried BADI ME_PROCESS_PO_CUST method PROCESS_ITEM , even this does not help.
    Can anybody please let me if you had requirement like this and how you solve this problem.
    Thanks n Regards
    Maruthi

    Hi Mr A
    Please tell me which user exit did you use to resolve this issue because I have to also do extra validations and changes to some PO Items when user creates PO with ME21N.
    Thanks

  • ABAP Program to Create TRs in SOLMAN

    Currently, we are creating TRs through SOLMAN_WORKCENTER transaction. It is being done manually by going to 'Change management' Tab in 'SOLMAN_WORKCENTER'->'PROJECTS'(QGATE Project not CHARM)-> TR is being created for a specific project using 'Create Transport Request' button.
    I was wondering, whether this process can be automated, so that developers can directly create a TR, through a web application or email. The frontend application will be creating TR in backend in SOLMAN after some validations.
    I'm trying to write an ABAP program to create TRs in backend in SOLMAN, following the same process, which is being followed now using SOLMAN_WORKCENTER. This program will be called by the frontend application. This way developers can create a TR, without having direct access to SOLMAN.
    I tried to use CL_CTS* classes, but it's not working. Kindly suggest some BAPIs or classes available for it.
    If anybody has already worked in development of a similar solution, kindly share the technical knowhow. Also, please let me know any solutions from SAP available for it.
    Thanks in advance for your help....

    Thanks a lot for responding Guilherme.....
    But, we wanted to add our own validations as per our standards like naming convention of TRs, project to be used etc...
    Otherwise, the TRs created by developers in an incorrect approach, will be very hard to manage.
    That's why I was looking for an ABAP code to create a TR in SOLMAN_WORKCENTER, so that we can add our own validations to it before creating the TR. If the validations fail, it should't create the TR.
    Using the webdynpro link for SOLMAN_WORKCENTER as suggested, some of the functionalities can be controlled by authorizations maybe. But, we'll not able able to add any extra validations required.

  • Installation Error -403 on Creative Cloud Photoshop CS6 install

    Mac OS X 10.8.2, Retina MacBook Pro, 16GB RAM
    Greetings, and hoping for a hand here (already on hold for an hour and a half waiting for a tech from Adobe to become free...wow, there must be lots of similar problems...).
    Just started a Creative Cloud subscription. I already owned some CS6 applications, most notably Photoshop. I installed the AAM and downloaded some of the apps missing from my catalog. Cool! But I noticed that Photoshop was not Photoshop Extended. Some searches led me to believe that I needed to deactivate my purchased version and uninstall it (which I did with Adobe's uninstaller). AAM then reported that Photoshop was no longer installed, so I clicked to install. It downloaded and immediately at the end of installation, it gave me the following: Installation Failed. Download error. Press retry to try again or contact customer support. (403).
    Note that I've installed three other CS6 applications successfully on the same network setup with no issues. I've also run the Adobe Creative Suite Cleaner Tool, but it doesn't see Photoshop at all remaining on the machine. I see no remnants of it when I manually inspect things.
    Repeated downloads of Photoshop do nothing different. Always error 403. DLM_Native.log has nothing at all useful. Here is everything time stamped from this particular installation attempt:
    01/28/13 19:15:11:887 | [INFO] | CDFF7D65-5034-4576-A4AE-E6D145330E9E |  |  |  |  |  | 257138 | The value of ETAG for the file is "458dee0aea908cbf2ee8fe75028223ed:1335651561"
    01/28/13 19:15:13:031 | [INFO] | CDFF7D65-5034-4576-A4AE-E6D145330E9E |  |  |  |  |  | 257346 | The value of ETAG for the file is "1219c9a82eb11f915a5db2a227e99e94:1335651561"
    01/28/13 19:15:14:111 | [INFO] | CDFF7D65-5034-4576-A4AE-E6D145330E9E |  |  |  |  |  | 257346 | The value of ETAG for the file is "5e1223af0bed85f1384f80f014a3267f:1335585814"
    01/28/13 19:16:13:425 | [WARN] | CDFF7D65-5034-4576-A4AE-E6D145330E9E |  |  |  |  |  | 257631 | Some Error has come during download operation with Error type - -40, and Error Code - 403
    Anyone have any ideas? I have searched extensively and haven't seen anyone with this situation. Maybe Adobe rolled this out a little before it was ready? The hold times on the phone seem to indicate this...

    OK, I figured it out. It was the firewall at work. Installed correctly on the first try at home. What is strange here is that other applications installed just fine. It appears that Photoshop does some extra validation online that the other apps don't do. So, if you see this error, know that one cause of it can be firewall issues.

  • Webdav and xdb, xml-files are automatically deleted (or hidden)

    Hi All.
    In our project we have mounted webdav from a Linux box against an IBM database server running AIX and Oracle 11g.
    The file system on the Linux box is mounted to the xdb-schema on the dbserver.
    When placing xml-files into the database through the webdav-catalogue on the Linux-box the files are copied over, but almost immediatly removed (or hidden) from the target directory in the database.
    I´m thinking there might be a trigger that tries to validate the xml-file against an xsd that isn´t registered in XDB. The reason for this is that when suffixing these files with something other than .xml the files are kept visible to all users.
    What I´d like to know is how to disable this check/trigger, and which trigger does this.
    Can anybody tell me if my assumtion is correct, and if yes, how to disable this checking?
    Our users in the project will also be given access to folders through this webdav mount, and they will use this as a storage space for other xml-files as well. Files we do not have xsd´s for. Another function for this webdav directory is to serve as a source directory for ODI, and ODI validates the files against the xsd when transferring data to the database, so we don´t need this extra validation in the database.
    Thanks,
    Bob

    Hi,
    What's the database version? (select * from v$version)
    When placing xml-files into the database through the webdav-catalogue on the Linux-box the files are copied over, but almost immediatly removed (or hidden) Does that mean you see them for a short period of time, and then they disappear, or you never see them at all?
    Are you using XML DB events?
    You can check if there's any resource configuration defined, and that may explain this behaviour :
    select x.*
    from xdb.xdb$resconfig rc
       , xmltable(
           xmlnamespaces(default 'http://xmlns.oracle.com/xdb/XDBResConfig.xsd')
         , '/ResConfig/event-listeners/listener'
           passing rc.object_value
           columns description varchar2(300) path 'description'
                 , schema      varchar2(30)  path 'schema'
                 , source      varchar2(30)  path 'source'
                 , events      varchar2(300) path '(#ora:xq_proc#){string-join(for $i in events/child::* return name($i), ", ")}'
                 , condition   varchar2(300) path 'pre-condition/existsNode/XPath'
         ) x
    DESCRIPTION                                                    SCHEMA    SOURCE                         EVENTS                                             CONDITION
    Register event handlers for users.                             SYS       DBMS_XS_PRINCIPAL_EVENTS_INT   Pre-Create, Post-Create, Pre-Update, Pre-Delete    /r:Resource[r:SchemaElement="http://xmlns.oracle.com/xs/principal.xsd#user"]
    Register event handlers for role sets.                         SYS       DBMS_XS_ROLESET_EVENTS_INT     Pre-Create, Post-Create, Pre-Update, Pre-Delete    /r:Resource[r:SchemaElement="http://xmlns.oracle.com/xs/roleset.xsd#roleSet"]
    Register event handlers for roles.                             SYS       DBMS_XS_PRINCIPAL_EVENTS_INT   Pre-Create, Post-Create, Pre-Update, Pre-Delete    /r:Resource[r:SchemaElement="http://xmlns.oracle.com/xs/principal.xsd#dynamicRol
    Register event handlers for dynamic roles.                     SYS       DBMS_XS_PRINCIPAL_EVENTS_INT   Pre-Create, Post-Create, Pre-Update, Pre-Delete    /r:Resource[r:SchemaElement="http://xmlns.oracle.com/xs/principal.xsd#role"]
    Register event handlers for function roles.                    SYS       DBMS_XS_PRINCIPAL_EVENTS_INT   Pre-Create, Post-Create, Pre-Update, Pre-Delete    /r:Resource[r:SchemaElement="http://xmlns.oracle.com/xs/principal.xsd#functionRo
    Register event handlers for Data Security.                     SYS       DBMS_XS_DATA_SECURITY_EVENTS   Post-Update, Post-Delete                           /r:Resource[r:SchemaElement="http://xmlns.oracle.com/xs/dataSecurity.xsd#DataSec
    Register event handlers for Security Classes.                  SYS       DBMS_XS_SECCLASS_EVENTS        Pre-Update, Pre-Delete                             /r:Resource[r:SchemaElement="http://xmlns.oracle.com/xs/securityclass.xsd#securi
                                                                   SYS       DBMS_NETWORK_ACL_ADMIN         Pre-Delete                                        
                   PL/SQL Network ACL Resource Configuration                                                                                                  
    Handling of Office Open XML spreadsheets                       OOX       OOX_SML_STORE                  Pre-Create, Pre-Delete                             /Resource[ContentType="application/vnd.openxmlformats-officedocument.spreadsheet
    9 rows selected
    {code}
    And if your target folder has any config file associated, for example :
    {code}
    SQL> select *
      2  from table(dbms_resconfig.getResConfigPaths('/office/excel/docs'));
    COLUMN_VALUE
    /office/excel/conf/sml_rescfg.xml
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to add Exception handling in Oracle Business rules Function

    Hello,
    We use to have good number of business rules in our application. So we need to have some functions in BR Composite.
    Can some one let me know how to handle exception in Oracle business rules exception( Regular try catch will not compile)
    is there any way please let me know.
    Edited by: Network22 on Mar 25, 2013 10:21 AM

    Why aren't you using por_custom_pkg.custom_validate_req_line to add extra validations.
    Ensure that profile POR: Enable Requisition Line Customization is set to Yes if you were to use po_custom_pkg for Requisition line validations.
    OAF calls por_custom_pkg at various points depending upon the values in Profile Options:-
    POR: Enable Req Distribution Customization
    POR: Enable Req Header Customization
    POR: Enable Requisition Line Customization
    Thanks,
    Anil Passi

  • CTE instead of subquery to improve performance

    Hello I have a view query that I added a select case subquery for extra validation. I was told that this subquery is causing a performance impact and that it could be resolved by using CTE instead. I have worked with CTE before but not in a large query,
    any ideas suggestions on how to improve my query using CTE would be greatly appreciated. 
    IF EXISTS (SELECT * FROM sysobjects WHERE type = 'V' AND name = 'VW_TRPRINT_TITLERECORD1')
    BEGIN
    DROP View VW_TRPRINT_TITLERECORD1
    END
    GO
    Create VIEW VW_TRPRINT_TITLERECORD1
    as
    SELECT
    distinct(T.TTL_NUMBER), T.OWNERSHIP_DOC_ID
    , OD.TXN_ID
    , TX.TXN_DATE
    , OWNSHIP.CUS_ID
    , PTA.CUS_FULLNAME_PART1 AS PRIMARY_OWNER_NAME
    , PTA.CUS_FULLNAME_PART2 AS SECOND_OWNER_NAME
    , PTA.CUS_ADDR_ID
    , CUST_ADDR.ADDRESS_LINE_1 AS PRIMARY_OWNER_STREET_LINE_1 --PRIMARY OWNER NAME AND ADDRESS DETAILS
    , CUST_ADDR.CITY AS PRIMARY_OWNER_CITY
    , CUST_ADDR.STATE AS PRIMARY_OWNER_STATE
    , CUST_ADDR.ZIP_CODE AS PRIMARY_OWNER_ZIP_CODE
    , CUST_ADDR.ZIP_PLUS AS PRIMARY_OWNER_ZIP_PLUS
    , CUST_ADDR.POSTNET_BARCODE AS PRIMARY_OWNER_COUNTY
    , PTA.FIRST_LIEN_NAME AS FIRST_SECURED_NAME
    , PTA.FIRST_LOAN_DATE AS LOAN_DATE
    , PTA.FIRST_LIEN_ADDRESS_ID
    , FIRST_LIEN_ADDR.ADDRESS_LINE_1 AS FIRST_SECURED_STREET_LINE_1 --FIRST SECURED PARTY ADDRESS DETAILS
    , FIRST_LIEN_ADDR.CITY AS FIRST_SECURED_CITY
    , FIRST_LIEN_ADDR.STATE AS FIRST_SECURED_STATE
    , FIRST_LIEN_ADDR.ZIP_CODE AS FIRST_SECURED_ZIP_CODE
    , FIRST_LIEN_ADDR.ZIP_PLUS AS FIRST_SECURED_ZIP_PLUS
    , FIRST_LIEN_ADDR.POSTNET_BARCODE AS FIRST_LIEN_COUNTY
    , PTA.SECOND_LIEN_NAME AS SECOND_SECURED_PARTY_NAME
    , PTA.SECOND_LOAN_DATE
    , PTA.SECOND_LIEN_ADDRESS_ID
    , PTA.MAIL_TITLE_TO_SECURED_PARTY
    , SECOND_LIEN_ADDR.ADDRESS_LINE_1 AS SECOND_SECURED_STREET_1 --SECOND SECURED PARTY ADDRESS DETAILS
    , SECOND_LIEN_ADDR.CITY AS SECOND_SECURED_CITY
    , SECOND_LIEN_ADDR.STATE AS SECOND_SECURED_STATE
    , SECOND_LIEN_ADDR.ZIP_CODE AS SECOND_SECURED_ZIPCODE
    , SECOND_LIEN_ADDR.ZIP_PLUS AS SECOND_SECURED_ZIP_PLUS
    , SECOND_LIEN_ADDR.POSTNET_BARCODE AS SECOND_LIEN_COUNTY
    , TMP.ADDRESSEE AS SPECIAL_MAIL_NAME --SPECIAL MAILING NAME AND ADDRESS DETAILS
    , TMP.ADDRESS_LINE_1 AS SPECIAL_MAILING_LINE_1
    , TMP.CITY AS SPECIAL_MAILING_CITY
    , TMP.STATE AS SPECIAL_MAILING_STATE
    , TMP.ZIP_CODE AS SPELCIAL_MAILING_ZIP_CODE
    , TMP.ZIP_PLUS AS SPECIAL_MAILING_ZIP_PLUS
    , TMP.POSTNET_BARCODE AS SPELCIAL_MAILING_COUNTY
    , MAIL_TO_NAME
    , MAIL_TO_ADDR.ADDRESS_LINE_1 AS MAIL_TO_STREET_LINE_1
    , MAIL_TO_ADDR.CITY AS MAIL_To_CITY
    , CASE WHEN MAIL_TO_ADDR.STATE = '' THEN
    NULL ELSE
    MAIL_TO_ADDR.STATE END AS
    MAIL_TO_STATE
    , CASE WHEN MAIL_TO_ADDR.ZIP_CODE = '' THEN
    NULL ELSE
    MAIL_TO_ADDR.ZIP_CODE END AS
    MAIL_TO_ZIP_CODE
    , MAIL_TO_ADDR.ZIP_PLUS AS MAIL_TO_ZIP_PLUS
    , MAIL_TO_ADDR.POSTNET_BARCODE AS MAIL_TO_ZIP_COUNTY
    ,'MAILING_CODE' = CASE
    --WHEN TMP.ADDRESS_ID IS NOT NULL THEN 'M'
    WHEN PTA.MAIL_TITLE_TO_SECURED_PARTY = 1 THEN 'S'
    WHEN TMP.ADDRESS_ID IS NULL AND OWNSHIP.IS_MAIL_OWNER = 1 AND PTA.MAIL_TITLE_TO_SECURED_PARTY = 0 AND (PTA.CUS_ADDR_ID = PTA.MAIL_TO_ADDRESS_ID OR MAIL_TO_ADDR.ADDRESS_LINE_1 = CUST_ADDR.ADDRESS_LINE_1) THEN ''
    ELSE 'M'
    END
    FROM VW_NONVOIDED_TITLES T
    INNER JOIN PRESERVE_TITLE_ATTRIBUTES PTA ON PTA.TITLES_ID = T.ID
    LEFT OUTER JOIN ADDRESSES CUST_ADDR ON CUST_ADDR.ID = PTA.CUS_ADDR_ID
    LEFT OUTER JOIN ADDRESSES FIRST_LIEN_ADDR ON FIRST_LIEN_ADDR.ID = PTA.FIRST_LIEN_ADDRESS_ID
    LEFT OUTER JOIN ADDRESSES SECOND_LIEN_ADDR ON SECOND_LIEN_ADDR.ID = PTA.SECOND_LIEN_ADDRESS_ID
    LEFT OUTER JOIN ADDRESSES MAIL_TO_ADDR ON MAIL_TO_ADDR.ID =
    (SELECT
    CASE WHEN SMA.DOC_ID = 6 THEN
    PTA.CUS_ADDR_ID
    ELSE
    PTA.MAIL_TO_ADDRESS_ID
    END
    FROM
    PRESERVE_TITLE_ATTRIBUTES PA
    INNER JOIN SPECIAL_MAILING_ADDRESS SMA ON SMA.ADDRESS_ID = PTA.MAIL_TO_ADDRESS_ID AND PA.ID =PTA.ID )
    /*Title Contains a Second Owner*/
    INNER JOIN VW_NONVOIDED_OWNERSHIP_DOCUMENT OD ON OD.ID = T.OWNERSHIP_DOC_ID --AND OD.END_DATE IS NULL
    INNER JOIN VW_NONVOIDED_OWNERSHIPS OWNSHIP ON OWNSHIP.OWNERSHIP_DOCUMENT_ID = OD.ID AND OWNSHIP.IS_MAIL_OWNER = 1 --AND OWNSHIP.END_DATE IS NULL
    INNER JOIN VW_NONVOIDED_VEHICLES V ON V.ID = OD.VEH_ID AND V.END_DATE IS NULL
    INNER JOIN TXN TX ON TX.ID = OD.TXN_ID
    LEFT OUTER JOIN
    SELECT
    SMA.TXN_ID,
    SMA.DOC_ID,
    SMA.ADDRESS_ID,
    SMA.ADDRESSEE,
    SMA.CUST_ID,
    A.ADDRESS_LINE_1,
    A.CITY,
    CASE
    WHEN A.ADDRESS_TYPE =3 THEN
    A.INTL_STATE
    ELSE
    A.STATE
    END AS STATE,
    A.COUNTY,
    CASE
    WHEN A.ADDRESS_TYPE =3 THEN
    A.INTL_ZIP_CODE
    ELSE
    A.ZIP_CODE
    END AS ZIP_CODE,
    A.ZIP_PLUS,
    A.POSTNET_BARCODE
    FROM SPECIAL_MAILING_ADDRESS SMA
    INNER JOIN ADDRESSES A ON A.ID = SMA.ADDRESS_ID WHERE DOC_ID IN (1, 2, 3, 4, 25,27, 28, 29, 30, 92)
    ) TMP ON TX.ID = TMP.TXN_ID

    Hi, Thanks for the response, the subquery that is supposedly creating performance impact is: 
    LEFT OUTER JOIN ADDRESSES MAIL_TO_ADDR ON MAIL_TO_ADDR.ID =
    (SELECT
    CASE WHEN SMA.DOC_ID = 6 THEN
    PTA.CUS_ADDR_ID
    ELSE
    PTA.MAIL_TO_ADDRESS_ID
    END
    FROM
    PRESERVE_TITLE_ATTRIBUTES PA
    INNER JOIN SPECIAL_MAILING_ADDRESS SMA ON SMA.ADDRESS_ID = PTA.MAIL_TO_ADDRESS_ID AND PA.ID =PTA.ID )
    Here is where I get a bit lost on to how to change this subquery for CTE. What I've read and study so far for CTE mentions that CTE needs to be added to the beginning of the query followed by a SELECT, INSERT, etc statements. 

Maybe you are looking for

  • How can i see my formatted document??

    Hi, I have this table CREATE TABLE ARCHAEOLDB( ID_DOC NUMBER(5) PRIMARY KEY, NOME_DOC VARCHAR2(200), FMT_DOC VARCHAR2(10) this is an example of my formatted document in my table.It has stored in my file system INSERT INTO archaeoldb VALUES(1,'Rapport

  • How to manage a MS office file

    I'd like to choose the best apps to manage my work docs, we work in  LAN with Windows 7 Pro as OS & MS office 2010 Pro as suite. have you ever proove the IWorks with A complex spreadsheet in excel? is there another apps betterk than IWorks? Unfortuna

  • DHCP service randomly stopping, when restarted scopes disappear

    I have DHCP and DNS running on two OS X 10.5.7 servers; one is a G5 dual 1.8 Ghz PPC and the other is a 2.8 Ghz quad-core Intel Xserve. This summer I've added VLAN scopes (staff and student wired & wireless) with half the available addresses in each

  • Auditing the Error Records

    How can I audit the bad records that are getting rejected from the target table. ie) i want to store the bad records rejected out to a separate table. i tried checking it out in the wb_rt_error_sources table in runtime repository, but it holds only t

  • Download 9i database.

    Hi all, I wanted to perform a testing and I need Oracle 9i database. I went through the OTN pages, but unfortunately I dont see any download links to Oracle 9i databases but came across links for 10g and 11g. Can anyone help me in providing a downloa