Select multiple summations for different where clauses

Hello,
I have table with invoice amounts of an article stored per period per year.
The table looks like this:
YEAR number(4) #pk
PERIOD number(2) #pk
ART number(12) #pk
AMOUNT number(10,2)
Suppose i have stored following info
YEAR PERIOD ART AMOUNT
2001 11 455 100.00
2001 12 455 150.00
2002 1 455 300.00
2002 2 455 200.00
2002 12 455 700.00
2003 1 455 220.00
I want to select the total amounts per article per year
and the total amounts per article per previous years
in ONE SELECT statement
When performing the follwing select i dont get the right information:
select a.year
, a.art
, sum(a.amt) year_amt
, nvl(sum(b.amt)) previous_years_amt
from app_inv a
, app_inv b
where b.YEAR (+) <= ( a.year - 1 )
and b.ART (+) = b.art
group
by a.year
, a.art
Results in:
YEAR ART YEAR_AMT PREVIOUS_YEARS_AMT
2001 455 250 0
2002 455 2400 750
2003 455 1100 1450
But i expected
YEAR ART YEAR_AMT PREVIOUS_YEARS_AMT
2001 455 250 0
2002 455 1200 250
2003 455 220 1450
The cause is a cartesian product because i omit the
column PERIOD, but adding that extra where
(b.PERIOD (+) = a.period) isn't also succesful:
YEAR ART YEAR_AMT PREVIOUS_YEARS_AMT
2001 455 250 0
2002 455 1200 150
2003 455 220 300
Does anyone know how format this into 1 select statement resulting in on record per year per article.
Thanks in advance
Auke Quist.

Thanks, your select works, but just for one article
When storing multiple articles over multiple years/periods
i don't get the expected result.
create table app_inv
( YEAR number(4) not null
, PERIOD number(2) not null
, ART number(12) not null
, AMOUNT number(10,2) not null
delete app_inv
insert into app_inv values ( 2001, 11, 455, 100.00 )
insert into app_inv values ( 2001, 12, 455, 150.00 )
insert into app_inv values ( 2002, 1, 455, 300.00 )
insert into app_inv values ( 2002, 2, 455, 200.00 )
insert into app_inv values ( 2002, 12, 455, 700.00 )
insert into app_inv values ( 2003, 1, 455, 220.00 )
insert into app_inv values ( 2001, 10, 475, 100.00 )
insert into app_inv values ( 2001, 11, 475, 150.00 )
insert into app_inv values ( 2002, 3, 475, 300.00 )
insert into app_inv values ( 2002, 4, 475, 200.00 )
insert into app_inv values ( 2002, 5, 465, 700.00 )
insert into app_inv values ( 2003, 1, 475, 220.00 )
Prompt select statement works for 1 article
SELECT a.year
, a.art
, sum(a.amount) year_amt
, sum(sum(a.amount))
OVER (ORDER by a.year, a.art ROWS UNBOUNDED PRECEDING)
- sum(a.amount) AS previous_years_amt
FROM app_inv a
WHERE a.art=455
GROUP BY a.year
, a.art
order by a.art
Prompt select statement fails for more than 1 article
SELECT a.year
, a.art
, sum(a.amount) year_amt
, sum(sum(a.amount))
OVER (ORDER by a.year, a.art ROWS UNBOUNDED PRECEDING)
- sum(a.amount) AS previous_years_amt
FROM app_inv a
GROUP BY a.year
, a.art
order by a.art
Are you able to help me further on, or anyone else?
Note i'm using 8.1.7.1.1 RDBMS
Thanks in advance
Auke Quist

Similar Messages

  • Select multiple value in a where clause

    hello,
    im using developer 2000.
    suppose I have several values in a data grid. I want to use all of them in a where clause using IN operator or something. anybody knows how to do that. what I do is always insert all values in the grid into a temporary table and use that table in the where clause. is there any other easy, effective way of doing that?
    select *
    from table1
    where category in (-- I want to select multiple values form a data grid here--)
    thanks in advance.
    bonny.

    Hello Bonny,
    You might consider the use of PL/SQL Collection Types
    The first step in the process is to create a type and a table of that type.
    CREATE OR REPLACE TYPE DateType IS OBJECT ( Arg1 DATE );
    CREATE OR REPLACE TYPE TableList IS TABLE OF DateType;
    DECLARE
    list1 tablelist;
    BEGIN
    SELECT datetype (arg1)
    BULK COLLECT INTO list1
    FROM table1;
    FOR c1 IN (SELECT arg1
    FROM TABLE (CAST (list1 AS tablelist)))
    LOOP
    ---- Your code -----;
    END LOOP;
    END;
    For further insight please refer: http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm
    Regards.

  • Parsing an input parameter for the where clause or record select value

    In my limited CR experience, I've always used a command database connection so that I can write my own SQL.  However, now I have to parse a  pipe delimited parameter to get my value for the where clause, so I'm selecting several tables and joining them through the Database Expert Links tab.  All works fine, but after doing that and then parsing the parameter with the below formula in the Select Expert, I notice that there is no where clause in the SQL query, and although the report eventually displays the proper values, it runs through thousands of records first.  Here is my Select Expert - Record formula:
    StringVar array Parm1;
    Parm1 := Split({?DATA_AREA}, "|");
    {SO_ORDERS.CASE_ID} = Parm1[2]
    If I change "Parm1[2]" on the last line to a valid Case ID, then there is a where clause in the SQL and the report generates immediately. 
    It seems like the record select formula is applied AFTER all of the records (without a where clause) are searched when I use the parsed parameter value, but when I hard code a valid value, it places that into the where clause BEFORE the sql is executed.  Is there a way to get the parameter parsed first and then use that parsed value in the SQL where clause?
    Thanks.
    Bill

    Yes crystal will run the query first to get 100% data and then applies record selection condition. To increase the performance you need to pass the where condition at the command level instead of report level. So you need to create a report using add command like this
    select * from tablename where field={?Parameter}
    {?Parameter} is a command level parameter.
    Now insert this report as a subreport in another report which has no connection but has a parameter
    {?DATA_AREA} and create a formula like this in the main report
    Split({?DATA_AREA}, "|")[2]
    Now right click on the subreport and go to change subreport links and add this formula from main report and link this to sub report parameter {?Parameter} without linking any database field from the subreport.
    Now your subreport runs with the where clause to get the data.
    Regards,
    Raghavendra

  • Re: Running the same (Forte) application multiple times -for different

    Hi
    We had the same problem - how to deploy a number of identical applications, using each their own db.
    (for training).
    The solution we used is to wrap the entire application into different applications by using a very small
    module called KURSUS01, KURSUS02 etc, that did nothing but call the start procedure of the main app.
    Then in the dbsession connect, we made a call appname to get the application name, and appended the
    first 8 chars to the dbname. Thus our dbnames now points to logicals name: rdbdataKURSUS01, rdbdataKURSUS02 etc.
    All this allows us to deploy the identical apps in the same env, or change one version, and run both the old
    and new program on the same pc and server at the same time (eg. KURSUS01 and KURSUS02).
    I also think this is a kludge - but it works nicely!
    Jens Chr
    KAD/Denmark
    -----Original Message-----
    From: Haben, Dirk <[email protected]>
    To: 'Soapbox Forte Users' <[email protected]>
    Date: 15. januar 1999 09:41
    Subject: Running the same (Forte) application multiple times - for different business clients.
    Hi All
    We have a number of different business clients all willing to use our
    application.
    The (forte) application is to run on our machines etc for these (business)
    clients.
    All (business) clients will have their data kept in separate Oracle DBs
    (instance).
    The problem now is that the entire (forte) application is written using
    DBSessions.
    Now, depending on what business client needs to be serviced (so to speak) we
    need to attach to the right DB - or use the "right" SO.
    The two options we can think of are:
    Option1:
    Programatic change to somehow "know" what (business) client (DB) I'm talking
    about and then use the right DB.
    Pro:
    Only one forte environment to maintain
    Can run multiple (business) clients on same PC at the same time
    Con:
    Requires many program changes
    bending O-O rules(?)
    can't dynamically name SOs so can it be done at all? (ResourceMGRs maybe?)
    Option2:
    Use separate environments! One for each business client.
    Pro:
    More defined separation of app and data,
    SLA-easy
    Con:
    Maintain "n" number of environments
    Can only run the application for one environment (business client) at a time
    on one PC - Big Negative here!
    Not knowing any feasible solution to option 1 (without much code changes and
    developer moaning) I would go for option two; as I have already worked on
    multi-environment setups on VMS back at the Hydro (hi guys).
    I would appreciate any comments from anyone who has solved this problem.
    How, Why Pro Con etc.
    TIA,
    Dirk Haben
    Perth, WA
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi
    We had the same problem - how to deploy a number of identical applications, using each their own db.
    (for training).
    The solution we used is to wrap the entire application into different applications by using a very small
    module called KURSUS01, KURSUS02 etc, that did nothing but call the start procedure of the main app.
    Then in the dbsession connect, we made a call appname to get the application name, and appended the
    first 8 chars to the dbname. Thus our dbnames now points to logicals name: rdbdataKURSUS01, rdbdataKURSUS02 etc.
    All this allows us to deploy the identical apps in the same env, or change one version, and run both the old
    and new program on the same pc and server at the same time (eg. KURSUS01 and KURSUS02).
    I also think this is a kludge - but it works nicely!
    Jens Chr
    KAD/Denmark
    -----Original Message-----
    From: Haben, Dirk <[email protected]>
    To: 'Soapbox Forte Users' <[email protected]>
    Date: 15. januar 1999 09:41
    Subject: Running the same (Forte) application multiple times - for different business clients.
    Hi All
    We have a number of different business clients all willing to use our
    application.
    The (forte) application is to run on our machines etc for these (business)
    clients.
    All (business) clients will have their data kept in separate Oracle DBs
    (instance).
    The problem now is that the entire (forte) application is written using
    DBSessions.
    Now, depending on what business client needs to be serviced (so to speak) we
    need to attach to the right DB - or use the "right" SO.
    The two options we can think of are:
    Option1:
    Programatic change to somehow "know" what (business) client (DB) I'm talking
    about and then use the right DB.
    Pro:
    Only one forte environment to maintain
    Can run multiple (business) clients on same PC at the same time
    Con:
    Requires many program changes
    bending O-O rules(?)
    can't dynamically name SOs so can it be done at all? (ResourceMGRs maybe?)
    Option2:
    Use separate environments! One for each business client.
    Pro:
    More defined separation of app and data,
    SLA-easy
    Con:
    Maintain "n" number of environments
    Can only run the application for one environment (business client) at a time
    on one PC - Big Negative here!
    Not knowing any feasible solution to option 1 (without much code changes and
    developer moaning) I would go for option two; as I have already worked on
    multi-environment setups on VMS back at the Hydro (hi guys).
    I would appreciate any comments from anyone who has solved this problem.
    How, Why Pro Con etc.
    TIA,
    Dirk Haben
    Perth, WA
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • How do I select multiple contacts for an e-mail?

    Using an iMac and wondering how to send an e-mail to multiple people in my contact list without having to open the contact list every time I select a name.  It would be nice if I could just open the contact list and select multiple people for the same e-mail.  Does anyone know how to do this?

    Hi there Kathy, The easiest way is Window (along the menu bar) > Address Pannel, then you can select multipul contacts and then click the "To:" Button in the top left of the window.
    (Tip: You can use comand and click to select multipul at once, then click the "To:" button in the top left)

  • Unable to select multiple images for upload

    I have Windows 7 Pro and FF 9.0
    I have an online store and am always uploading product photos for items I have listed. I recently switched from XP Pro to Windows 7 Pro. I had no issues with XP. However, now that I have Windows 7 Pro I am unable to select multiple images for upload when using FF. I can only select one image at a time.
    The issue is unique to FF. I have tried in several other browsers, and FF is the only one that I am unable to select multiple images from.
    I had FF 8.0.1 and upgraded to 9.0... hoping that would resolve the issue. It did not. I have restarted my computer several times which has also had no effect.

    Hi,
    Welcome to the    Discussions
    I see it is about 6 hours since you posted, so I guess you will get this when you wake. (I'll be sleeping then)
    This would be better asked in the forum for Using Leopard inside the Leopard Category sating which browser and which site it was.
    (it probably made lots of sense to you when you were typing it but it seems a little short in facts or workable info.)
    8:43 PM Wednesday; March 24, 2010
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
    Message was edited by: Ralph Johns (UK)

  • Dispatch center - Select multiple tasks for scheduling at the same time

    Hi!
    I need a consultation regarding Dispatch center. Is there a functionality to select multiple tasks for scheduling at the same time for one resource?
    Please, guys, this is urgent.
    Jan

    You can schedule a single task or multiple tasks automatically directly from the
    dispatch center. The scheduling criteria applied come from Advanced Scheduler.
    Make Sure, you have the advanced scheduler. With out Advanced Scheduler and by just using Advice, you can only assign one task at a time.
    HTH
    ps: for more information, refer Field Service User Guide, "Scheduling Tasks"

  • Using multiple values in a where clause, for values only known at runtime

    Dear all
    I am creating a PL/SQL program which returns multiple rows of data but only where it meets a set id values that a user has previously chosen. The id values are stored in an associative array and are chosen by a user in the preceding procedure at run time.
    I know all the table and column names in advance. The only things I don't know are the exact number of ids selected from the id column and what their values will be. This will only be known at runtime. When the procedure is run by the user it prints multiple rows of data to a web browser.
    I have been reading the following posting, which I understand to a large extent, Query for multiple value search But I cannot seem to figure out how I would apply it to my work as I am dealing with multiple rows and a cursor.
    The code as I have currently written it is wrong because I get an error not found message in my web browser. I think the var_user_chosen_map_list_ids in the for cursor loop could be the problem. I am using the variable_user_chosen_map_list_ids to store all the id values from my associatative array as a string. Which I modified from the code that vidyadhars posted in the other thread.
    Should I be creating a OPEN FOR ref cursor and if so where would I put my associative array into it? At the moment I take the value, turning it into a string and IN part in the WHERE clause holds the string, allowing the WHERE clause to read all the values from it. I would expect the where clause to read everything in the string as 1 complete string of VARCHAR2 data but this would not be the case if this part of the code at least was correct. The code is as follows:
    --Global variable section contains:
    var_user_chosen_map_list_ids VARCHAR2(32767);
    PROCEDURE PROCMAPSEARCH (par_user_chosen_map_list_ids PKG_ARR_MAPS.ARR_MAP_LIST)
    IS
    CURSOR cur_map_search (par_user_chosen_map_list_ids IN NUMBER)
    IS
    SELECT MI.map_date
           MT.map_title,
    FROM map_info MI,
         map_title MT,
    WHERE MI.map_title_id = MT.map_title_id
    AND MI.map_publication_id IN
    (var_user_chosen_map_list_ids);
    var_map_list_to_compare VARCHAR2(32767) := '';
    var_exe_imm_map VARCHAR2(32767);
    BEGIN
    FOR rec_user_chosen_map_list_ids IN 1 .. par_user_chosen_map_list_ids.count
    LOOP
       var_user_chosen_map_list_ids := var_user_chosen_map_list_ids ||
       '''' ||
       par_user_chosen_map_list_ids(rec_user_chosen_map_list_ids) ||
    END LOOP;
    var_user_chosen_map_list_ids := substr(var_user_chosen_map_list_ids,
                                            1,
                                            length(var_user_chosen_map_list_ids)-1);
    var_exe_imm_map := 'FOR rec_search_entered_details IN cur_map_search
    LOOP
    htp.print('Map date: ' || cur_map_search.map_date || ' Map title: ' || cur_map_search.map_title)
    END LOOP;';
    END PROCMAPSEARCH;EXECUTE IMMEDIATE var_exe_imm_map;
    I would be grateful of any comments or advice.
    Kind regards
    Tim

    I would like to thank everyone for their kind help.
    I have now successfully converted my code for use with dynamic SQL. Part of my problem was getting the concept confused a little, especially as I could get everything work in a static cursor, including variables, as long as they did not contain multiple values. I have learnt that dynamic sql runs the complete select statement at runtime. However even with this I was getting concepts confused. For example I was including variables and the terminator; inside my select string, where as these should be outside it. For example the following is wrong:
         TABLE (sys.dbms_debug_vc2coll(par_user_chosen_map_list_ids))....
    AND MI.map_publication_id = column_value;';Where as the following is correct:
         TABLE (sys.dbms_debug_vc2coll('||par_user_chosen_map_list_ids||'))....
    AND MI.map_publication_id = column_value';PL/SQL is inserting the values and then running the select statement, as opposed to running the select statement with the variables and then accessing the values stored in those variables. Once I resolved that it worked. My revised code is as follows:
    --Global variable section contains:
    var_user_chosen_map_list_ids VARCHAR2(32767);
    var_details VARCHAR(32767);
    PROCEDURE PROCMAPSEARCH (par_user_chosen_map_list_ids PKG_ARR_MAPS.ARR_MAP_LIST)
    IS
    BEGIN
    FOR rec_user_chosen_map_list_ids IN 1 .. par_user_chosen_map_list_ids.count
    LOOP
       var_user_chosen_map_list_ids := var_user_chosen_map_list_ids ||
       '''' ||
       par_user_chosen_map_list_ids(rec_user_chosen_map_list_ids) ||
    END LOOP;
    var_user_chosen_map_list_ids := substr(var_user_chosen_map_list_ids,
                                            1,
                                            length(var_user_chosen_map_list_ids)-1);
    var_details := FUNCMAPDATAFIND (var_user_chosen_map_list_ids);
    htp.print(var_details);
    END PROCMAPSEARCH;
    FUNCTION FUNCMAPDETAILS (par_user_chosen_map_list_ids IN VARCHAR2(32767)
    RETURN VARCHAR2
    AS
    TYPE cur_type_map_search IS REF CURSOR;
    cur_map_search cur_type_map_search;
    var_map_date NUMBER(4);
    var_map_title VARCHAR2(32767);
    begin:
    OPEN cur_map_search FOR
    'SELECT MI.map_date,
           MT.map_title
    FROM map_info MI,
         map_title MT,
         TABLE (sys.dbms_debug_vc2coll(' || par_user_chosen_map_list_ids || '))
    WHERE MI.map_title_id = MT.map_title_id
    AND MI.map_publication_id = column_value';
    LOOP
    FETCH cur_map_compare INTO
    var_map_date,
    var_map_title;
    var_details := var_details || 'Map date: '||
                        var_map_date ||
                        'Map title: ' ||
                        var_map_title;
    EXIT WHEN cur_map_compare%NOTFOUND;
    END LOOP;
    RETURN var_details;
    END FUNCMAPDETAILS;Kind regards
    Tim

  • Selecting values for query where clause

    hi guys, this is possibly a silly question but not sure if i am approaching the solution in the correct mannor.
    At the top of my form i have text box which the user fills in various values. These values are then used to refine the query results in the block below. I know i can go into the datablock being queried and set the where clause to equal the value of the text boxes above but i dont feel this is the right place to do it.
    If i do it that way when the text box above is blank it returns no reults when infact i want to query everything if the values are left blank. So should i put it in pre query? if so what way should it be done?
    Any help would be greatly appreciated.
    Thanks.

    Hello,
    If i do it that way when the text box above is blank it returns no reults when infact i want to query everything if the values are left blank. So should i put it in pre query? if so what way should it be done?Not really if you use like below in block's where clause...
    db_field_name1=NVL(:form_field_name1,db_field_name1) AND
    db_field_name2=NVL(:form_field_name2,db_field_name2)-Ammad

  • Using a report value for a where clause in other report

    Hi All,
    i'm getting kinda nuts here. I created a page with three reports.
    First report show the name of the user who logged in with his/her whole name. Second report shows the year, week, begin/end date of the week for the user in the first report. The third report show the hours the user worked in the week selected in the second report.
    The link between first and second report is on column report. Somehow i managed it to work with second_report.mdw_code = :P3_ACRONIEM. I have no idea were this P3_ACRONIEM item is coming from, while i have no items in my page whatsoever. Now i need to link the second report to the third report. I have to use the second_report.mdw_code, second_report.year and second_report.week but i have no idea how to link these together. Any idea's? (Like making items, but then i have no idea how to link that item to the value in the second report). Please help.
    Kind regards,
    Dave
    The link between the first and the second i could get it to work with :P3_ACRONIEM. I have no idea where this ITEM is coming from, because i have no items in my page (and it's the only page in the application). Then

    Hi Dave,
    If I understand you correctly, you have a one report that lists users, a second report that lists dates and a final report that shows hours worked?
    If so, you may find it easiest to have hidden fields on your page and base the second and third reports on these using appropriate WHERE clauses. (I generally put hidden fields in a region in the "After Header" position)
    So, if the first report contains a USER_ID field, have a hidden field called P1_USER_ID. The link on the first report will branch back to the same page and set the value of P1_USER_ID to #USER_ID# The second report can then use WHERE USER_ID = :P1_USER_ID. When the page reloads, the second report redisplays and is filtered to show only those records relating to the selected USER_ID in the first report.
    To extend this, if the second report contains WEEK_NUMBER, it should have a link that branches back to the same page and sets a hidden P1_WEEK_NUMBER field with #WEEK_NUMBER#. The third report should when have WHERE WEEK_NUMBER = :P1_WEEK_NUMBER AND USER_ID = :P1_USER_ID. You can, if need be, have and set more than one hidden field during each link.
    Regards
    Andy

  • Passing Multiple Parameters to a Where clause

    Dear All,
    Using Crystal 11.5 on XP workstations, communicating with a SQL database.
    I want to allow users to input two or three or four Meeting codes -- text fields about 10 characters -- into a Crystal multiple parameter field.  Then I want to use those names to access data for each meeting, grouping on the meeting . . .
    WHERE meeting.name = 'MeetingCode1' or meeting.name = 'MeetingCode2 or meeting.name = 'MeetingCode3'
    I've tried just using "IN" with the parameter and that won't work for this -- though it seems to get data for cvross tabs which is puzzling.  I've tried using the JOIN function to parse out the data and build the WHERE clause and have been unsuccessful (but if you tell me that should work, I can go at it again that way -- all kinds of issues there comparing it to Crystal's SQL view.
    Any thoughts about how to tackle this would be greatly appreciated.
    Sincerely,
    Ridge (in New Joisey)

    I just tested this again -- going very slowly and very carefully -- and it seems to be working setting the
    { table.field} IN
    for both numeric and string values.
    Sorry for wasting bandwidth.
    R

  • Variable for entire where clause

    Is it possible to use a variable for the entire where clause in a PL/SQL select statement?
    I have a where clause stored as a string in the database and I want to use that entire string as a variable, but my procedure will not compile because it is missing the relational operator.
    SELECT whereclause FROM clausetable WHERE clause = 'TEST'; will return this string: column1 = 'abc'
    Here's my procedure:
    create or replace
    PROCEDURE TESTWC
    (c_out OUT sys_refcursor )
    AS
    BEGIN
    DECLARE
    v_whereclause VARCHAR2(255);
    BEGIN
    SELECT whereclause
    INTO v_whereclause
    FROM clause_table
    WHERE clause = 'TEST';
    DBMS_OUTPUT.PUT_LINE(v_whereclause);
    OPEN c_test FOR SELECT * FROM dpacsoftware WHERE v_whereclause;
    NULL;
    END;
    END TESTWC;

    Is it possible to use a variable for the entire where clause in a PL/SQL select statement?Unfortunately yes.
    I have a where clause stored as a string in the databaseThis is a really bad idea, like storing the source for half your program in a text file with a bunch of Java or C or FORTRAN code and opening, reading, compiling and linking at run time.
    It is slow, slow, slow as you can expect, and dangerous and insecure, since someone could have put a format C: command in your source file, or something equivalently nasty to a database.

  • Delivery to multiple invoices for different BPs

    Hi,
    I have the following scenario:
    You add a delivery note for one customer. There are situations when should be three different invoices, but for other 3 different BPs as the customer who received the goods is not necessarily the one paying for them.
    I know there is a payment consolidation, but you can only include one father code.
    Any ideas?
    Thanks,
    Cristina

    Hi Cristina,
    it must be very difficult to keep track of who received what goods & who is meant to pay for them.
    If this group of BPs is definite, you could create a virtual 'master' consolidating BP & run a group account where you keep all the billing addresses in the one spot. The disadvantage is that you will not easily be able to pinpoint which of the 'child' BPs still owes for what invoice.
    You can also create invoices & payments for different BPs & then use internal reconciliation with multiple BPs. This may be more traceable option, but depends on manual actions & is therefore error prone.
    All the best,
    Kerstin

  • Selecting Multiple Members for Allocation SP7

    Hi Experts,
    Before upgrading to SP7 from SP3, I could select multiple product categories in my data manager for allocation, ex. PROD_CAT_001,PROD_CAT_001,PROD_CAT_001 and then my allocation would run smoothly. But after the upgrade, whenever I select more than one product category, I'm now encountering this error:
    TOTAL STEPS  1
    1. Execute formulas:       Failed  in 1 sec.
    2. IC Eliminations:        completed  in 1 sec.
    [Selection]
    CHECKLCK= No
    (Member Selection)
    Version: ACTUAL
    Entity: DMPI
    Time: 2009.MAR
    Product: PROD_CAT_001,PROD_CAT_002,PROD_CAT_003,PROD_CAT_004,PROD_CAT_005
    [Messages]
    Execute formulasError
    Unclosed quotation mark after the character string 'PROD_CAT_001'. in:
    select [ID] from mbrPRODUCT where [CATEGORY]='PROD_CAT_001
    My logic is below:
    *RUNALLOCATION
    *FACTOR=USING/TOTAL
    *DIM COPAACCOUNT   WHAT=[EXPORT_ALLOC_BASIS]='Stat Cases';  WHERE=<<<;      USING=COPAVVSCA;   TOTAL=<<<;
    *DIM PRODUCT       WHERE=[CATEGORY]='%PRODUCT_SET%';   USING=<<<;   TOTAL=<<<;
    *DIM CUSTOMER      WHAT=ALC_CG_01;  WHERE=[SHPTO_LEVEL]='ALC_CG_01';   USING=<<<;   TOTAL=<<<;
    *DIM DATASRC       WHAT=11_INPUT;   WHERE=11_ALLOC;   USING=11_INPUT;   TOTAL=<<<;
    *ENDALLOCATION
    Hope you could help me,
    Marvin

    Hi nilanjan,
    I revised my code as shown below but I still get the same error. I really want to avoid selecting all product categories since there would be 450 members so I don't use select statements. I just want to select the product categories that have values so there would be no need to loop all 450 members because it's causing my logic to hang when validate and save it. Any suggestion on how I can select product categories that have value only?
    *FOR %PROD_CAT%=%PRODUCT_SET%
    *RUNALLOCATION
    *FACTOR=USING/TOTAL
    *DIM COPAACCOUNT   WHAT=[EXPORT_ALLOC_BASIS]='Stat Cases';  WHERE=<<<;      USING=COPAVVSCA;   TOTAL=<<<;
    *DIM PRODUCT       WHERE=[CATEGORY]='%PRODUCT_SET%';   USING=<<<;   TOTAL=<<<;
    *DIM CUSTOMER      WHAT=ALC_CG_01;  WHERE=[SHPTO_LEVEL]='ALC_CG_01';   USING=<<<;   TOTAL=<<<;
    *DIM DATASRC       WHAT=11_INPUT;   WHERE=11_ALLOC;   USING=11_INPUT;   TOTAL=<<<;
    *ENDALLOCATION
    *NEXT
    *COMMIT
    Thanks,
    Marvin

  • Tuning Select Statement . field sequence and where clause

    Hi All
    Are there any general guidelines how to write select < field sequence >where clause < field sequence ? Is that shuld be in order of the field sequence in tables?
    And how to use this when we have a view or a inner - join . Is that separate from normal select statement that is using FOR ALL ENTRIES.
    Please let me know any general guidelines available on this,
    Amol

    Hello Amol,
    I have another hint:
    The statement FOR ALL ENTRIES will package the select statements for every five entries in the internal table. So in comparison to the following code sequence...
    LOOP AT itab.
       SELECT * FROM table WHERE key = itab-key.
    ENDLOOP
    the number of select statements is reduced to 20% with
    SELECT * FROM table INTO TABLE ...
         FOR ALL ENTRIES IN itab
         WHERE key = itab-key
    If I'm expecting a <i>huge</i>  amount of data a go a step further and create my own packages by building a range table with around 100-500 entries and execute a select there...
    LOOP AT itab.
       IF counter < 500.
          APPEND itab-key TO range-tab.   " just code example
       ENDIF.
       IF count >= 500.
          SELECT * FROM table APPENDING TABLE ...
             WHERE key IN range_tab
       ENDIF.
       " adjust and calculate counter
    ENDLOOP.
    * Don't forget last select statement after loop
    Best wishes,
    Florin

Maybe you are looking for