Order of values passed to ODCIAggregateIterate

I have implemented my own aggregate function that concatenates varchar2 values together. It works perfectly, however, the order of the aggregated data is inconsistent and does not match the order that it occurs in the table the aggregation is over ( I have sorted the data). As an example:
original data:
column_a     column_b
a                1-abc
a                2-abc
a                3-abc
b                1-abc
b                2-abc
b                3-abcafter aggregation query
column_a         column_b_concat
a                    1-abc,3-abc,2-abc
b                    1-abc,2-abc,3-abcMost of the concatenated data is correct (2nd row) but some of it is not (1st row). My question is....Is there a way to force the order of the aggregated rows to be maintained? I understand for aggregations such as count, sum or avg order is unimportant and so the db optimizes it to run as fast as possible. I can do this using PL/SQL but the execution time is much longer and would rather avoid it if possible.
Thanks.
Edited by: user8092994 on Feb 23, 2009 5:11 PM

Hi,
Let's phrase the question in terms of the scott.emp table and the wm_concat function, which a lot of people using Oracle 10 (and up) have available.
Right now you're doing something like:
SELECT    deptno
,       WM_CONCAT (ename)     AS ename_concat
FROM       scott.emp
GROUP BY  deptno;and getting results like
.   DEPTNO ENAME_CONCAT
        10 CLARK,KING,MILLER
        20 SMITH,FORD,ADAMS,SCOTT,JONES
        30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARDexcept that the names aren't in order (which is exactly the problem: you need to be sure they are in order, as shown above).
I can think of three ways to do that:
(1) modify the function (as you have already considered)
(2) use CONNECT_BY_PATH instead of the function
(3) use the analytic form of the function
My guess is that the options above are listed in order of execution speed ((1) is fastest), but that's just my hunch.
Option (2) works like this:
WITH       got_r_num   AS
     SELECT     deptno
     ,     ename
     ,     ROW_NUMBER () OVER
                  (     PARTITION BY     deptno
                       ORDER BY       ename
                  ) AS r_num
     FROM     scott.emp
SELECT     deptno
,     SUBSTR ( SYS_CONNECT_BY_PATH (ename, ',')
            , 2
            )     AS ename_concat
FROM     got_r_num
WHERE     CONNECT_BY_ISLEAF     = 1
START WITH     r_num     = 1
CONNECT BY     r_num     = PRIOR r_num + 1
     AND     deptno     = PRIOR deptno;Option (3) works like this:
WITH  got_concat     AS
     SELECT     deptno
     ,     WM_CONCAT (ename) OVER
                 (       PARTITION BY     deptno
                        ORDER BY       ename
                 ) AS e_concat
     FROM     scott.emp
SELECT       deptno
,       MAX (e_concat)     AS ename_concat
FROM       got_concat
GROUP BY  deptno;Any user-defined aggregate function can also serve as an analytic function: just add "OVER (...)" when you run it.
Within each partition, the various values of e_concat will all be longer versions of one another, all starting the same way.
For example, in deoptno = 10, the various values are
CLARK
CLARK,KING
CLARK,KING,MILLERThe one you want to display is the longest one, which, since they all start the same way, will also be the MAX.

Similar Messages

  • Reduce Remaining Order Planned value for services with PO

    Hi guys,
    I'am looking for a way to reduce the remaining or residual order plan value for a network activity with services where the amount on the PO is below the planned value. If for example the planned value amounts up to 1000 and the PO has been reduced due to negotiations to 900, a remainder order plan of 100 remains on the network activity till the activity is technically closed.
    Is there a way to reduce the ROP when a PO exists for the network activity?
    Thanks, Geert

    We are combining an early visibility of all costs and a strict budget availability control with a formal procedure for project managers to request additional budget.
    We have more and more projects where a part of the budget remains blocked in ROP for service activities because the planned value was more pessimistic than the real PO amount. Since these service activities are typically executed at the end of the project that part remains blocked. Of course the project managers want to use that marging elsewhere without having to pass a request for additional budget.
    We have no issue with the network activity planned costs remaining visible, we just want the ROP to be 0 when a the purchase requisition for the service activity has been transformed into a purchase order. In the above example 100 of the budget would be freed for other use.

  • Open Sales Order quantity & value

    Hi,
    We have a requirement here of report to show open sales order quantity & value for any month (monthend). There is a datasource 2LIS_11_V_ITM which gives Open order quantity. I have created an ODS with 2LIS_11_VAITM & 2LIS_11_V_ITM which can give me desired qty & value, but only for date of last data upload and not for date in the past.(and to get that, I have to sumup all open orders quantity without using any date filter)
    I am thinking of creating a Infocube over this ODS to update the Open Order qty & value at the monthend (Snapshot scenario). But to update this, I am not able to get the logic for date to be used in time dimension.
    If anyone can think of the solution or any alternate way to develop this kind of report, your help/suggestions are most welcome.
    Thanks,
    Vikram.

    Hi Vikram,
    Find the link, which solves u r requirement
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/bi/arobustdesignofopensalesorderdataflow
    Thanks & Regards
    Ramakrishna Kamurthy

  • Open sales order credit value (S066-OEIKW)

    Hello experts,
    I need to update the table S066 with the Open sales order credit value when an item has no confirmed quantity (VBEP-BMENG). So I have created the new rountine under
    VOFM -> Requirements -> Credit checks -> new include RVKMP901. But I don't know how to update this table.
    From the note 377165, the same is explained. But I am niot able to achieve my requirement.
    So please help me in this regard.
    Waiting for your reply.
    Any Suggestion...
    With regards,
    Vasanth M
    Edited by: Vasanth M on Feb 15, 2010 8:21 PM

    Hello Jack,
    Thanks fo your answer. But I have to update the credit amount to the table S066.
    This credit limit could be viewed in the TC FD33. So please suggest me what to do.
    Thanks in Advance
    Best Regards,
    Vasanth M

  • How to get the Open Order Qty value from Transaction Code RWBE?

    Hello,
    Recently I have a program that needs to extract the value of Open Order Qty value from RWBE.
    My specific steps are as follows:
    - I go to tcode <b>RWBE</b>
    - I select the <b>material and plant</b>
    - I tick the checbox for <b>"Also select special stocks"</b> and <b>"Also select stock commitments"</b>
    - I execute the program double click one of the rows for the <b>Unrestricted Use coulmn</b> and view the <b>Open Order Qty</b>.
    My question is how is this particlar variable attained? I tried Ekbe and the ELIKZ feild from EKPO and I still cant seem to get the right value.
    Hope to hear from you soon.
    Thank you and good day.

    check with FM :
    CALL FUNCTION 'MB_ADD_PURCHASE_ORDER_QUANTITY'
           EXPORTING
              x_matnr = t_matnr-matnr         " TGA/4.6 Erw. Lot
              x_meins = t_matnr-basme         " TGA/4.6 Erw. Lot
                x_matnr = prt_matnr-matnr  " TGA/4.6 Erw. Lot
                x_meins = prt_matnr-basme  " TGA/4.6 Erw. Lot
                x_elikz = space
                x_loekz = space
           TABLES
                xtab    = xtab
                xwerks  = r_werks.
    above fm will get open order qty for given material in po

  • How to summarize Open sales order credit value

    Hi, friends.
    I am designing Add-on report about credit exposure.
    I found the relevant tables of Credit Limit in FD32
    KNKK
    S066
    S067
    Then, I would like to show the document details of open sales order credit value in the report.
    I tried to summarize the open sales order amount from VBAK, VAUK, VBAP, VBUP.
    However, it doest match to the amount in S066 table.
    Can anyone tell us how to summarize Open sales order credit value from SD documents?
    Regards,
    Yu

    Sudheer,
    You need to check the update rule given in the definition of the Credit control Area which you are using for credit management. If you want only the open deliveries then you need to have update rule 15 in the credit control area.
    In the credit controal settings, you need to have settings for the credit check at the delivery level.
    Hope this will solve your issue.
    Regards,
    Chetan
    Edited by: Chetan Gupte on Jul 15, 2010 8:56 PM

  • How to construct a standard rowKeyStr based on a value passed to a method ?

    Hi to all im on a proyect and i really appreciate some people can help with this
    looking ADF joins all use rowKey values and i need to know how to generate a standard rowKeyStr based on a value passed to an event, so it let me access any page on my Jsp ADF application and pass some values to a method and get the rowKeyStr.
    i have this method actually getting the current row, how i can generate a standard rowKeyStr value.
    public String myrowKeyStr(String id) {
    if (id != null) {
    PbeVisitasViewImpl vo = (PbeVisitasViewImpl)getPbeVisitasView1();
    Key k = new Key(new Object[]{id});
    Row[] found = vo.findByKey(k,1);
    vo.setCurrentRow(vo.findByKey(k,1)[0]);
    return someRowKeyStr;
    }

    once you do the
    Key k = new Key ( new Object[] { p1 } );
    The rowkeystring comes from:
    String strRowKeyStr = k.toStringFormat();
    Just type k. and press ctrl-space to see the list of methods.

  • BOM not exploding in Sales order & Net Value error

    Hello Dear all,
    I have created a product "A" with BOM items 10, 20 & 30.
    Item cat. Gr for "A" is ERLA & for 10, 20 & 30 is LUMF.
    I have also created BOM with these 3 matls. (ie 10, 20 & 30).
    When processing Sales Order Item cat. appeared in SO for "A" is TAP & for other 3 is TAN. "A" shows the price maintained for it, but not showing Net Value at Header level data in SO.
    Also document is incomplete because of Net value for Items 10, 20 & 30.
    I don?t want price of 10, 20 & 30 should display in SO at Item level
    Can anyone suggest the required setting?
    Thanks
    Shan

    hi,
    For BOM mainly two material groups are used.
    LUMF and ERLA.
    If you used ERLA in the main material which consists of different materials then the pricing would be carried out only for the main item, while the other sub items pricing would not be displayed.
    while if you use LUMF then the main material would not be priced but only the sub items would be relevant for pricing the the total of all the sub items forms the basis of the sales order net value.
    regarding the net value error you can just check the pricing configuration for the steps and sub total.
    regards,
    Siddharth.
    Edited by: SD on Mar 11, 2008 7:51 AM

  • Unable to change the order quantity value during save of sales order

    Hi Experts,
    There is a need to change the order quantity value, based on some conditions, when pressed 'ENTER' or during 'SAVE' of the sales order (VA01, VA02).
    We are trying to change the order quantity value (KWMENG) in table XVBAP in the subroutines userexit_field_modification, userexit_save_document and userexit_save_document_prepare of the user exit 'MV45AFZZ'. But the change is not replicated to field on GUI.
    The order quantity value can be changed in subroutine 'userexit_move_field_to_vbap', but the subroutine is not getting triggered when user changes only the order quantity on screen.
    Please help us in resolving this issue.
    Regards,
    Santosh

    Thanks for your time guys. The issue is resolved.
    SAP is not triggering the vbap user exit as the order quantity on screen is in structure RV45A.
    There are two ways of resolving the issue.
    1. Implement the SAP note #513342 - Quantity change and USEREXIT_MOVE_FIELD_TO_VBAP. But, it is SAP modification note.
    2. Write the code in VBEP exit of MV45AFZZ. This user exit is called whenever the order quantity is changed. But, it is called multiple times in some cases. Hence, need to write code to limit our code execution only once e.g. maintain a global table with our quantity & uom. Check when the quantity and uom in our table is same as quantity on screen. If not, exit from user-exit.
    Edited by: Santosh Kacham on Nov 11, 2011 6:37 AM

  • How to Retrieve Purchase order TAX value price

    Hi,
    I want to retrieve Purchase order TAX value price from the purchase order is there any function module to retrieve this value.  Or from which table we can retrieve this value using purchase order no.
    Thanks in advance

    Hi Pradeep,
    Have you looked BAPI <b>BAPI_PRICES_CONDITIONS</b>?
    Hope this will help.
    Regards,
    Ferry Lianto

  • Sales order net value and invoice net value differ

    Hi Gurus,
    i placed  sale order 03/08/2009 the net value of the order is 30000 USD, the same day i have done some price modification (manually i entered the header condition with value of 50 USD) after entering the header condition sales order net values is showing 50 USD. then delivered and invoiced. in the invoice net value is showing 30000 USD. my requirement is the invoice also has to show the 50 USD only. why it is not showing the sales order net value? is there any setting need to be done  regarding this problem?
    Thanks in advance

    i changed the pricing type as D
    From your comments, I presume in copy control, a different alpha value would have been maintained and with that settings, sale order, delivery and billing were generated.
    What I would suggest you is that you create a sale order once again for the same customer and 5 materials, make same changes in pricing, do PGI and billing.  See how it works.
    thanks
    G. Lakshmipathi

  • Restrict value of one variable corresponding to value passed in other.

    Dear Experts,
    I have query regarding BEx Authorization for the given selection screen of any variable for any report :
    I have three parameters/variables( Circle ,SSA and Exchange) which needs to be passed from User. Circle(state)->SSA(City)->Exchange(Sub Locality). I want to restrict the value of second and third variable corresponding to the values passed in first variable. For e.g. : if a value Madhya Pradesh is passed as a Circle then SSA selection screen should show only
    City or SSAs of Madhya Pradesh only. Same case with selection screen of exchange variable also.

    Hi Shikhar,
    I think you will have to have Circle (State) as the attribute of SSA(City) and SSA(City) will have to be attribute of Exchange (Sub Locality). Then when you enter a value in Circle variable, the take the F4 help on SSA, then you will get the values which are relevant for the respective Circle. Similarly the Exchange.
    If you enter a wrong value for SSA and Exchange...and click check, then the system should throw an error.
    Apart from this you can also create Authorization objects for all the three objects in RSECADMIN and provide appropriate access to relevant users. In this case the users will see only the authorized values in the F4. However the system will not throw an error during the input of the variables. But will only display authorization error only when you execute the query.
    Good Luck,
    Vikram

  • Restrict Purchase Order Minimum Value

    Hi,
    We want that the SAP System should not allow the user to create a Purchase Order of Value less than Rs. 5000.
    Is there any SAP Standard Functionality available for the same or we need to use the User Exit?
    Regards,
    PK

    Thanks Shital for the reply.
    We are not using Release Strategy, hence we want to out the check at the PO Creation level only.
    Pls. advise.
    Regards,
    PK

  • Sales order net value

    How and where the sales order net value will be communicate with credit management as a open order value?

    Hi Gopalal.,
                          The subtotal field A is related with credit managemnt in Pricing,In pricing if we want to caliculate the credit limit on only PR00 you can set subtotal A immediatly after A,If you want to caliculate Credit limit after dicounts then Subtotal A should be placed after discounts,
    So Subtotal A is nothing but the values of the pricing are stored in A field which compares the credit limit in sales order
    IMPORTANT thing is credit limit gets updated with the help Of INfo structure SO66 in OMO1
    REWARD if helpfull
    Thanks & Regards
    Narayana

  • Determine if value passed is empty

    Hello,
    i am attempting to determine if a value passed as a parameter to a stored procedure in a package is empty. The relevant target field in the database does not allow nulls, but the interface passes several values to be inserted and must determine if any of them are empty and if so skip inserting that value through the stored procedure and move on to next passed value. The syntax compiles okay but i get an error.
    For example;
    If passing several name values, i.e. 'Mr', 'John', 'Smith', and all with a value inserted into field Name_Value and the code to determine if empty is;
    If P_NameText <> '' Then
    <process statements>
    End if;
    If the title value inputted is empty the error i receive is;
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("Database_Name"."NAME_VALUE")
    ORA-06512: at "PKG_INSERT_CUST", line 307
    ORA-06512: at "PKG_INSERT_CUST", line 89
    ORA-06512: at line 1
    Thanks in advance, i'm fairly new to Oracle.

    Hello,
    i am attempting to determine if a value passed as a
    parameter to a stored procedure in a package is
    empty. The relevant target field in the database
    does not allow nulls, but the interface passes
    several values to be inserted and must determine if
    any of them are empty and if so skip inserting that
    value through the stored procedure and move on to
    next passed value. The syntax compiles okay but i
    get an error.
    For example;
    If passing several name values, i.e. 'Mr', 'John',
    'Smith', and all with a value inserted into field
    Name_Value and the code to determine if empty is;
    If P_NameText <> '' Then
    <process statements>
    if;
    If the title value inputted is empty the error i
    receive is;
    ERROR at line 1:
    ORA-01400: cannot insert NULL into
    ("Database_Name"."NAME_VALUE")
    ORA-06512: at "PKG_INSERT_CUST", line 307
    ORA-06512: at "PKG_INSERT_CUST", line 89
    ORA-06512: at line 1
    Thanks in advance, i'm fairly new to Oracle.This error due to constraint which you defined at table level can handle it by
    If P_NameText IS NULL Then
           Raise_application_error(-20011, 'Name cannot be null..');
    ELSE
          <process statements>;
    End if;Depends what value you pass NULL,' '.
    Khurram

Maybe you are looking for

  • One USB HD with Multiple AEBS, Move from NAS/File Server

    Okay to explain my question I'll describe what i want to do. If this is possible i would buy 2 airport extremes, and one USB HD. I would then use the USB HD to do TimeMachine backups to an Airdisk. I would like to then be able to take the USB HD with

  • Xerces Sockets and The root element is required

    Hi, I have a problem with Xerces 1.4.3 saying "The root element is required in a well-formed document.". The story is as follows: When I read the XML from a file, it works OK. But when I send the file over a socket stream, and try to parse it in the

  • A short question ????

    Hi guys... I am trying to write a program that takes a source file and displays the data the source file contains into a browser. Do you guys know if there is such a thing as invisible tabel on html couse I am trying to list the data and arrange them

  • App Store crashes immediately after opening

    App Store crashes every time I open it.  Also having a problem with iPhoto crashing as well.  Initially tried reinstalling OSX 10.9.4, but that didn't fix it either. Model: iMac12,1, BootROM IM121.0047.B1F, 4 processors, Intel Core i5, 2.7 GHz, 4 GB,

  • My USB Flash Drive isn't recognised?

    Today, when using my Macbook with Mac OS X Tiger (10.4.11), suddenly it did not recognize my Verbatim 4GB USB flash drive. What's strange is that when I plug it in, the light on the flash drive blinks as if the computer has connected to it, but it do