Help in user-defined values

Dear experts, please, how to adust this query to show in column "Advice based on Packing Unit" only values > 0?
Thank you in advance for your help.
declare @mag1 as char(8)
set @mag1= left($[OPOR.Comments],2)
SELECT      
          'Advice based on Packing Unit'=     case when     ((T1.ordrmulti = 0 or T1.ordrmulti = 1) and (t1.purpackun = 0 or t1.purpackun = 1)) and T0.maxstock = 0 then
                                   T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0))
                              when      ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti > 0 and T1.ordrmulti > 1 then
                                   case when  (ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti - T0.Maxstock) / T0.Maxstock < 0.1 then
                                                            ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                   else
                                                         case when floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti < T0.maxstock then
                                                  case when round(((T0.maxstock - floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti)/T1.purpackun),0) > 0 then
                                                  case when ((ceiling(((T0.maxstock - floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)T1.ordrmulti)/T1.purpackun))T1.purpackun  + floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti)- T0.maxstock ) /T0.maxstock < 0.1 then
                                                       ceiling(((T0.maxstock - floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)T1.ordrmulti)/T1.purpackun))T1.purpackun  + floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                                  else
                                                       floor(((T0.maxstock - floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)T1.ordrmulti)/T1.purpackun))T1.purpackun  + floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                                  end
                                             else
                                                  floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                             end
                                        else
                                        floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                        end
                                   end
                             when      ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun > 0 and T1.purpackun > 1 then
                                   case when  (ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun - T0.Maxstock) / T0.Maxstock < 0.1 then
                                        ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun
                                   else
case when floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun > 0 then
                                                                          floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun
                                        else
                                                                    T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)) 
                                        end        
                                   end     
                              else
                                   T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0))
                         end
FROM  OITM T1
INNER JOIN OITW T0 ON T1.ItemCode = T0.ItemCode
WHERE   T0.WhsCode = @mag1
     AND  (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0) < T0.MinStock) and T1.CardCode = $[OPOR.CARDCODE] and T0.itemcode = $[POR1.itemcode]

Dear experts, please, how to adust this query to show in column "Advice based on Packing Unit" only values > 0?
Thank you in advance for your help.
declare @mag1 as char(8)
set @mag1= left($[OPOR.Comments],2)
SELECT      
          'Advice based on Packing Unit'=     case when     ((T1.ordrmulti = 0 or T1.ordrmulti = 1) and (t1.purpackun = 0 or t1.purpackun = 1)) and T0.maxstock = 0 then
                                   T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0))
                              when      ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti > 0 and T1.ordrmulti > 1 then
                                   case when  (ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti - T0.Maxstock) / T0.Maxstock < 0.1 then
                                                            ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                   else
                                                         case when floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti < T0.maxstock then
                                                  case when round(((T0.maxstock - floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti)/T1.purpackun),0) > 0 then
                                                  case when ((ceiling(((T0.maxstock - floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)T1.ordrmulti)/T1.purpackun))T1.purpackun  + floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti)- T0.maxstock ) /T0.maxstock < 0.1 then
                                                       ceiling(((T0.maxstock - floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)T1.ordrmulti)/T1.purpackun))T1.purpackun  + floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                                  else
                                                       floor(((T0.maxstock - floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)T1.ordrmulti)/T1.purpackun))T1.purpackun  + floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                                  end
                                             else
                                                  floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                             end
                                        else
                                        floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.ordrmulti)*T1.ordrmulti
                                        end
                                   end
                             when      ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun > 0 and T1.purpackun > 1 then
                                   case when  (ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun - T0.Maxstock) / T0.Maxstock < 0.1 then
                                        ceiling((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun
                                   else
case when floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun > 0 then
                                                                          floor((T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)))/T1.purpackun)*T1.purpackun
                                        else
                                                                    T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0)) 
                                        end        
                                   end     
                              else
                                   T0.MaxStock - (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0))
                         end
FROM  OITM T1
INNER JOIN OITW T0 ON T1.ItemCode = T0.ItemCode
WHERE   T0.WhsCode = @mag1
     AND  (T0.OnHand - T0.IsCommited T0.OnOrderisnull((select T5.onhand from oitw T5 where T5.itemcode = T0.itemcode and T5.whscode = 'T'+@mag1),0) < T0.MinStock) and T1.CardCode = $[OPOR.CARDCODE] and T0.itemcode = $[POR1.itemcode]

Similar Messages

  • User-defined value help and dispatcher configuration

    HI all.
    This is adrian. I gots my hands in PCUI. Facing a prob. Hope someone can help.
    The User-defined value help and dispatcher iViews in CRM-PCUI are no longer displayed after I installed CRM 4.0 Support Package 03. I also get a portal error when I execute the link.
    Did some one work with such a prob.
    Acosta.

    Adrian,
    I did work with a lil of PCUI some time back.
    Well the upfront easy solution is upgrade your pack level to one less than the latest.
    Julius

  • How to display user define value in list screen from detail screen

    Hello Experts
    I am working on task in which i have to display the user define value on list screen. like i have one list list screen which have one button for add..once i click on add which navigate to detail screen and detail screen has two fields one for ID AND other for name and detail screen has one button for save once i put value for id and name and click on save button which will navigate to previous list screen and those values which should be display on list screen.
    Regards:
    Sumit

    Hi Sumit,
    To navigate to the Master page on button click , you need some thing like,
    oSplitApp.toMaster("masterpage_id");
    to understand the navigation for Master/Detail page , have a look at,
    http://help.sap.com/saphelp_uiaddon10/helpdata/en/df/adb6b7247e4826b0fcde472b029840/content.htm
    Also to pass value from Detail page to Master page, you can use a Global variable to store your values on click of the Save button. For eg. You may have a global JS file which both Master and Detail page can access like App.Js, Application.JS etc.
    After navigating to the Master page, you can read the Global variables and show it on your Master page.

  • Prevent manual entry  in user defined value

    Is it possible to prevent manual entry  in user defined value (Formatted search)?
    Thanks

    Hi
    I don't think there is any out of the box solution .
    It is possible if formatted search automatically populates your data but I think in your case ,user is selecting the list of special codes you have provided .
    May be it can be done by SDK . Try posting in SDK forum .
    Hope this helps
    Bishal

  • How to make user-define value's query

    Dear All,
    In we have 3 user-defined fields in marketing document. When I type in field 1 and field 2, we need line total = field 1 * field 2.
    Would it be possible for me to config it in SAP? I setup a user-define value and have a query for it. Make it updated when field 2 changed. But when I am not clear on how to write the query. I have a query select $[POR1.U_Field1]*$[POR1.U_Field2]
    But I got an error message. It has to be some syn error in my query.
    It is a service type document so that I cannot have a where POR1.Itemcode = ...
    Can anybody help me out? Thanks in advance.
    Regards,
    Yuka
    Edited by: Jie Jin on Mar 23, 2010 7:28 PM

    I use Select $(Por1.Price.number)*$(Por1.U_Numberofunit.number)   //replace ( to [
    The price was been change to null. Then my query is like select *6. Thanks.
    Edited by: Jie Jin on Mar 23, 2010 7:42 PM
    Edited by: Jie Jin on Mar 23, 2010 7:44 PM

  • User Defined field and User defined values.

    Curently testing this in the demo database before rolling it out to a customer.
    I added a user defined field to my item master data base called Lengthcm of type Amount.
    I have created a query:
    SELECT u_lengthcm = CASE
                      WHEN $[oitm.blen1unit] = 5 THEN $[oitm.blength1] * 2.54
                      WHEN $[oitm.blen1unit] = 6 THEN $[oitm.blength1] * 2.54 * 12
                      ELSE 0 END
    Length unit 5 is inches and length unit 6 is feet.
    In Item Maintenance then I create a user defined value for the lengthcm field linked to the query and set to auto-update when the blength1 field changes.
    This works perfectly for 1 inch through 9 inches (1" through 9") and fills in the centimeter value. When I put in a value in feet (1', 2'), it does nothing and if I put in any value of 10" or greater gives an error message:
    [Microsoft][SQL Server Native Client 10.0][SQL Server] Arithmetic overflow error
    converting nvarchar to data type numeric. 'Received Alerts' (OAIB).
    Checking database structure back end, blen1unit is of type small int, blength1 is numeric of size 19, 6 and so is my lengthcm field.
    Edited by: Danielle Ostach on Mar 18, 2011 8:18 PM
    Edited by: Danielle Ostach on Mar 18, 2011 8:19 PM
    Edited by: Danielle Ostach on Mar 18, 2011 8:20 PM
    Edited by: Danielle Ostach on Mar 18, 2011 8:21 PM
    Edited by: Danielle Ostach on Mar 18, 2011 8:21 PM

    Hi Danielle ,
    Try this...
    SELECT u_lengthcm = CASE
                      WHEN $[oitm.blen1unit] = 5 THEN (cast(($[oitm.blen1unit]) as decimal(19,6)))  * 2.54
                      WHEN $[oitm.blen1unit] = 6 THEN (cast(($[oitm.blen1unit]) as decimal(19,6)))  * 2.54 * 12
                      ELSE 0 END
    Regards,
    Sachin

  • Undo User Defined Value

    I create a user defined value in the production order screen for Product No. by mistake.  How do I reestablish the connection between Product No. and the List of Bill of Material?
    Regards,
    Fred

    Hi Fred,
    You just need to ShiftAtlF2 to bring up design page and change it to without User Defined Value.
    Thanks,
    Gordon

  • Row limitation for list of User Defined Values

    Dear all,
    I need to make list of User Defined Values at the field in SO. Is there any limitation of row quantity for that ? because the list will grow until thousand..
    Regards
    Wibisana

    Dear Ho we,
    There is no limitation of user define filed for document level and document row level.
    At present i think no budy use 1000 UDF at row level so its very difficult to say after creation of 1000 UDF what is impact on system performance.
    You have to work try basis.
    REGARDS
    MANGESH PAGDHARE.

  • Need help with user defined function

    Hello SDN,
    I need some help with a user-defined function. My source message contains multiple
    generic records (1000 char string), and my target message is 1 header record,
    then multiple generic records.  See description of source and target messages below:
    Source:
      GenericRecordTable 1..unbounded
        Row (1000 char string)
    Target:
      Field1 (char5)
      Field2 (char5)
      Field3 (char5)
      IT_Data
        GenericRecordTable 1..unbounded
          Row (1000 char string)
    Basically, what I need to do in my user defined funtion is to map the first record
    in my source record to the 3 header fields, then map all of the rest of the records
    (starting from line 2) into the GenericRecordTable.
    Can someone please help me with the code for the user defined function(s) for this
    mapping?
    Thank you.

    hi,
    Activities
    1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
    graphic is explained in the accompanying text), which is located on the lower left-hand side of the
    screen. In the menu, choose Simple Function or Advanced Function.
    2. In the window that appears, specify the attributes of the new function:
    Name
    Technical name of the function. The name is displayed in the function chooser and on the data-flow
    object.
    Description
    Description of how the function is used.
    Cache
    Function type (see above)
    Argument Count
    In this table, you specify the number of input values the function can process, and name them. All
    functions are of type String.
    3. In the window that appears, you can create Java source code:
    a. You can import Java packages to your methods from the Imports input field, by specifying them
    separated by a comma or semi-colon:
    You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
    all message mappings require these packages and therefore import them. You should be able to
    access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
    package under Import. In other words, you do not have to import it as an archive into the Integration
    Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
    SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
    In addition to the standard packages, you can also specify Java packages that you have imported as
    archives and that are located in the same, or in an underlying software component version as the
    message mapping.
    b. Create your Java source text in the editor window or copy source text from another editor.
    4. Confirm with Save and Close.
    5. User-defined functions are limited to the message mapping in which you created the function. To
    save the new function, save the message mapping.
    6. To test the function, use the test environment.
    The new function is now visible in the User-Defined function category. When you select this category,
    a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
    function to the data-flow editor, choose the arrow next to the button and select from the list box
    displayed.
    http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
    http://java.sun.com/j2se/1.5.0/docs/api/
    /people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
    /people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    UDF -
    http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
    Regards

  • Please help for User defined extension functions

    the tutorial given for extension functions doesn't work as well as our new functions
    even though i follow all the given steps and see the functions in my user defined extension functions tab in xslt map.
    all the target nodes that use the extension function disappear in the resulted target xml.
    please help.

    have you compiled your java file and uploaded the jar file(containg the .class file and the Manifest.MF file) in the <OC4J_HOME>\j2ee\home\applib directory and then restarted the server??

  • To change User defined Value field from Amount to Quantity in COPA

    I have created a created a User defined Characteristics VV930 - Number of labor hours.  While creating, i wrongly assigned the chategory Amount instead of Quantity.
    Now when i am trying to change it is giving me errors.
    Also it is not allowing to delete and recreate the new VV930 with category as Quatity.
    No data is posted in COPA.

    Hi Rupesh
    1. Remove it from your COPA data structure in KEA0... Shift it from Left to right in data structure screen... Then try to delete it
    2. Else, reserve this Value Field for future use and change the name as of now to XXXXXX...Create a new Qty Field for your use now.
    Regards
    Ajay M

  • Help in user defined exception handler

    Hi
    Can some one help in solving this error .
    when i run my procedure i get this error which is given below .
    ORA-06510 PL/SQL unhandeled user defined exception at line 7
    Procedure FMG_EXTRACT_MOTORBIKE_NEWBUS (P_NSSC_YN VARCHAR2) IS
    l_start date;
    l_end date;
    cursor motorbike_rec is
    select
    c.id,
    k.id pak_id,
    p.ref,
    i.description,
    i.current_status,
    i.premium,
    i.sum_insured,
    mv.registration_no,
    mv.cc_rating,
    nl.ncl_level,
    nl.percentage_discount,
    dp.full_name main_driver,
    dpd.birth_date,
    e.user_name entered_by,
    ep.full_name emp_name,
    fmg_get_imposed_terms(i.id,'. ',';') imposed_terms
    from
    fmg_clients c,
    fmg_client_paks k,
    fmg_policies p,
    fmg_Policy_items i,
    fmg_mv_usages u,
    fmg_people dp,
    fmg_people_details dpd,
    fmg_employees e,
    fmg_people ep,
    fmg_motor_vehicles mv,
    fmg_ncb_levels nl
    where i.date_created>=l_start
    and i.date_created<l_end
    and i.pol_id=p.id
    and p.ctp_id=k.id
    and k.cli_id=c.id
    and i.id=u.poi_id(+)
    and u.per_id=dp.id(+)
    and dp.id=dpd.per_id(+)
    and i.id=mv.poi_id(+)
    and i.ncl_id=nl.id(+)
    and ( (i.pit_pro_code in ('TFF','FMC','FMT','FMF','FBK','PMC','TPO','MCL'))
    or (i.pit_pro_code = 'CMV' and i.pit_code = 'MCL')
    or (i.pit_pro_code = 'PMS' and i.pit_code = 'MCL')
    or (i.pit_pro_code = 'PMT' and i.pit_code in ('MCT','MCF'))
    and i.user_created=e.user_name
    and ( (e.business_unit='BCC' and P_NSSC_YN='Y') OR (nvl(e.business_unit,'X')<>'BCC' and P_NSSC_YN='N') )
    and e.per_id=ep.id;
    l_file UTL_FILE.FILE_TYPE;
    l_file_name varchar2(100);
    l_data VARCHAR2(4000);
    BEGIN
    if P_NSSC_YN='Y' then
    l_start := trunc(sysdate)-1;
    l_end := trunc(sysdate);
    l_file_name := 'MotorCycle_Daily_'||to_char(l_start)||'.csv';
    l_file := utl_file.fopen( fmg_re_filepath('SSC'), l_file_name, 'W' );
    else
    l_start := to_date('01-' || to_char(sysdate-28,'MM-YYYY'));
    l_end := last_day(to_date('01-' || to_char(sysdate-28,'MM-YYYY')));
    l_file_name := 'MotorCycle_Monthly_'||to_char(l_start)||'_'||to_char(l_end)||'.csv';
    l_file := utl_file.fopen( fmg_re_filepath('GAU'), l_file_name, 'W' );
    end if;
    l_data := '"Client ID","Pak ID","Policy Ref","Item Desc","RegoNo","CC","Item Status","Premium","Sum Insured",' ||
    '"NCB Level","NCB%","Main Driver","Birth Date","Imposed terms","EnteredBy","Employee Name"';
    utl_file.put_line(l_file, l_data );
    for i in motorbike_rec loop
    l_data :=
    to_char(i.id) || ',' ||
    to_char(i.pak_id) || ',' ||
    i.ref || ',' ||
    '"' || i.description || '",' ||
    '"' || i.registration_no || '",' ||
    to_char(i.cc_Rating) || ',' ||
    i.current_status || ',' ||
    to_char(i.premium) || ',' ||
    to_char(i.sum_insured) || ',' ||
    to_char(i.ncl_level) || ',' ||
    to_char(i.percentage_discount) || ',' ||
    '"' || i.main_driver || '",' ||
    to_char(i.birth_date) || ',' ||
    '"' || i.imposed_terms || '",' ||
    i.entered_by || ',' ||
    '"' || i.emp_name || '"' ;
    utl_file.put_line(l_file,l_data);
    end loop;
    utl_file.fclose( l_file );
    exception
    when others then
    if utl_file.is_open(l_file) then
    utl_file.fclose( l_file );
    end if;
    raise;
    END;

    What does fmg_re_filepath('SSC') return? Are their sufficient rights with Oracle user on the location that is returned by this function?
    Which OS are you using?

  • Need help with User Defined Aggregates - Statistical Mode

    I would like to use User Defined Aggregates (UDAG) to calculate the Statistical Mode. The mode is the most frequent value among a set of observations.
    http://en.wikipedia.org/wiki/Mode_(statistics)
    In my application I aggregate an address level table of 130 million records to a ZIP4 level table of roughly 36 million records. Some ZIP4s will have 1 record, some may have 1000+ records. I need to use statistical modes to pick the most frequent values for some of the attribute fields.
    Presently I am using an approach from AskTom using the Analytic functions combined with nesting subqueries. The code works but it's cumbersome. I feel user defined aggregates should be able to perform a simpler more straightforward integration into SQL queries.
    I've reviewed several of the other posts in this forum on User Defined Aggregates. I feel I could write a procedure that calculates and average or merely concatenates strings. But this particular application of the UDAGs is stumping me. Rather than just increased a running total or count or concatenating a master string, you'd have to keep every distinct values and a count for how many times that value occured. Then evaluate those items to pick the most frequent to pass to output. I'm finding it difficult as a novice.
    Any, I'll post a quick example using the present approach that I want to replace with a UDAG:
    Here's a small table:
    DRD> desc statmodetest
    Name Null? Type
    ID NUMBER
    STATE VARCHAR2(2)
    REGION VARCHAR2(1)
    1* select * from statmodetest
    DRD> /
    ID ST REG
    1 TX W
    2 MN W
    3 CA W
    4 VA E
    5 VA E
    6 KY E
    7 MN W
    8 FL E
    9 OK W
    10 NC E
    11 TX W
    12 WI E
    13 CA W
    14 MI E
    15 FL E
    16 FL E
    17 TN E
    18 FL E
    19 WI E
    20 MA E
    Now here's a query approach that gets the MODE State value for each Region.
    1 SELECT DISTINCT region, mode_state, mode_state_cnt FROM (
    2 SELECT region,
    3 FIRST_VALUE(state) OVER (PARTITION BY region ORDER BY stcnt DESC) AS mode_state,
    4 FIRST_VALUE(stcnt) OVER (PARTITION BY region ORDER BY stcnt DESC) AS mode_state_cnt
    5 FROM (
    6 select id, state, region, COUNT(state) OVER (PARTITION BY region, state) AS stcnt
    7* from statmodetest t ) )
    DRD> /
    R MO MODE_STATE_CNT
    W CA 2
    E FL 4
    What I'd like to be able to do is have a UDAG that supports this style query:
    SELECT region, UDAGMODE(state)
    FROM statmodetest
    GROUP BY region ;
    Thanks,
    Paul

    This is not what you want..?
    SQL> select * from test;
            ID STATU REGIO
             1 TX    W
             2 MN    W
             3 CA    W
             4 VA    E
             5 VA    E
             6 KY    E
             7 MN    W
             8 FL    E
             9 OK    W
            10 NC    E
            11 TX    W
            12 WI    E
            13 CA    W
            14 MI    E
            15 FL    E
            16 FL    E
            17 TN    E
            18 FL    E
            19 WI    E
            20 MA    E
    20 rows selected.
    SQL> select region,max(status) keep(dense_rank first order by cnt desc,status) st,
      2         max(cnt)
      3  from(
      4       select region,status,count(*) cnt
      5       from test
      6       group by region,status)
      7  group by region;
    REGIO ST      MAX(CNT)
    E     FL             4
    W     CA             2
    <br>
    <br>
    Or I misread..?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to popluate user defined values in Paramter field of a report using "Report Server Project", BIDS

    Hello,
    I am creating report using "Business Intelligence Development Studio", creating "Report Server Project" connected to TFS database.
    I have created Variance report and the output of report  as below sample:
    Project   Assigned To      Planned Effort        Completed    Remaining  Variance
    P1            X                        20                        
    10                 5              5
    P2            Y                        10                        
    10                 0             0
    P3            Z                          5                        
    0                  5              0
    By default I made Assigned To as parameter field and its showing data for selection in a drop down box (X, Y and Z) and data also filtered correctly.
    Q. how can I fill resource names in a drop down of my own choice (in this scenario, I want to display only X and Y) and display data based on the selected resource? By default parameter displays all the resources which I don't want.
    I did the below but could not get correct result:
    1. Right Click on "Assigned To" parameter, Clicked on "Available Values" and Selected "Specify values" instead of "Get values from query"
    2. Added X as Label and Value as 2 (Employee ID as mentioned in dbPerson table)
    Drop down displays X but when I clicked on report, it gives an error...
    Appreciate your help on this.
    Regards
    Abdul Kalam

    Hi Abdul,
    From the document, we know that CONSTRAINED flag is used to reduce the risk of injection attacks via the specified string. If a string is provided that is not directly resolvable to qualified
    or unqualified member names, the following error appears: "The restrictions imposed by the CONSTRAINED flag in the STRTOSET function were violated."
    So you need to make sure the members are passed properly to the STRTOSET function. For more details, please see the following links:
    http://ch1n2.wordpress.com/2010/02/21/the-restrictions-imposed-by-the-constrained-flag-in-the-strtoset-function-were-violated/
    http://www.bp-msbi.com/2010/04/passing-unconstrained-set-and-member-parameters-between-reports-in-reporting-services/
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Allow user defined values during run time

    Hi ,
    I have created a VI wherein I have 3 inputs as enums, I also want to give the user the capability to enter runtime values which are not present in the drop down for the enum , is it possible ? I see an option in the propeties of the enums as "allow user to enter undefined values during runtime" , will this serve the same purpose as I am looking for or is it something different ?
    Please see the attached snapshot for the option I am referring to .
    Thanks
    Attachments:
    Allow_undefined_values_during_runtime.PNG ‏25 KB

    Manreet wrote:
    Hi ,
    I have created a VI wherein I have 3 inputs as enums, I also want to give the user the capability to enter runtime values which are not present in the drop down for the enum , is it possible ? I see an option in the propeties of the enums as "allow user to enter undefined values during runtime" , will this serve the same purpose as I am looking for or is it something different ?
    Please see the attached snapshot for the option I am referring to .
    Thanks
    What you see is a disabled option in the items editor.  The items editor is common between Rings Comboboxs and enums.  I don't know why  the gurus and R&D decided to disable and grey the checkbox rather than hide the darn thing.  Lucky for us its not something that customers see just developers.  At least we have the ability to ask about what that is if we don't know.
    Jeff

Maybe you are looking for