Recursive query to calculate new value in a table.

Hello folks,
I have following data.
drop table transactions;
create table transactions
( ac varchar2(10), rec_seq int, tr_ref int, action varchar2(100), qty int );
select * from transactions;
insert into transactions values ('A1', 1, null, 'BUY', 1);
insert into transactions values ('A1', 2, null, 'BUY', 4);
insert into transactions values ('A1', 3, 1, 'TR to A2', -2);
insert into transactions values ('A1', 4, null, 'SELL', -1);
insert into transactions values ('A1', 5, 2, 'TR from A2', 2);
insert into transactions values ('A1', 6, null, 'BUY', 5);
insert into transactions values ('A1', 3, 3, 'TR to A3', -1);
insert into transactions values ('A2', 1, null, 'BUY', 5);
insert into transactions values ('A2', 2, null, 'BUY', 5);
insert into transactions values ('A2', 3, null, 'BUY', 5);
insert into transactions values ('A2', 4, 1, 'TR from A1', 2);
insert into transactions values ('A2', 5, null, 'SELL', 2);
insert into transactions values ('A2', 6, null, 'BUY', 1);
insert into transactions values ('A2', 7, null, 'BUY', 1);
insert into transactions values ('A2', 8, 2, 'TR to A1', -2);
insert into transactions values ('A2', 9, null, 'sell', 3);
insert into transactions values ('A2', 10, 4, 'TR from A3', 3);
insert into transactions values ('A3', 1, null, 'BUY', 5);
insert into transactions values ('A3', 2, 3, 'TR from A1', 1);
insert into transactions values ('A3', 3, null, 'SELL', 2);
insert into transactions values ('A3', 4, 4, 'TR to A2', -3);I the transactions table that holds the activity took place in a time. Below is some description of the table.
1. rec_seq is the unique for each row within each AC value
2. action column holds the nature of the activity
3. tr_ref holds to link between the transfers. That is, source and destination of the transfers can be matched using this column.
Now I want to write a query such that It returns the whole table with value of rec_seq changed in a recursive fashion that is
1. Compare transfer records using tr_ref.
2. Assign the greatest rec_seq to both the records.
3. Recalculate the rec_seq of the following records from the new value. This recalculation to happen in a recursive fashion.
Any hint/partial or full assistance in this will immensely help.
Thank you.
Girish

Hi,
Transfers are the key events in this problem. Every time there is a transfer, the new rec_seq number has to be adjusted. The new rec_seq value will be the greater of two numbers:
(1) the req_seq of the last transfer in this ac, plus the number of other transactions in this ac since then, and
(2) the req_seq of the last transfer in the other ac, plus the number of other transactions in that ac since then.
(I assume a transfer always involves two different ac's. If not, the query below can be changed.)
One way to approach this problem is to think of a directed graph, where every node is a transfer row, and it may have up to two parents:
(1) the previous transfer in the same ac
(2) the previous transfer in the other ac
The query below constructs such a graph, then finds all the paths through that graph (in the sub-query named graph). It finds the longest path to each node (weighted by the number of rows between transactions). The main query references that number, and assigns consectuive new_rec_seqs starting with it.
WITH     got_trs  AS
     SELECT     ac, rec_seq, tr_ref, action, qTy
     ,     LAST_VALUE (tr_ref IGNORE NULLS)  OVER ( PARTITION BY  ac
                                                       ORDER BY      rec_seq
                                        ROWS BETWEEN  UNBOUNDED PRECEDING
                                         AND  1            PRECEDING
                                       )        AS prev_tr
     ,       LAST_VALUE (tr_ref IGNORE NULLS)  OVER ( PARTITION BY  ac
                                                       ORDER BY      rec_seq     DESC
                                             )        AS next_tr
     FROM    transactions
--     WHERE     ...     -- if you need any filtering, put it here
,     got_tr_cnt     AS
     SELECT     got_trs.*
     ,     COUNT (*) OVER ( PARTITION BY  ac
                              ,            next_tr
                      )    AS tr_cnt
     FROM    got_trs
,     nodes     AS
     SELECT     ac
     ,     tr_ref
     ,     tr_cnt
     ,     ac          AS parent_ac
     ,     prev_tr          AS parent_tr
     FROM     got_tr_cnt
     WHERE     tr_ref     IS NOT NULL
    UNION
     SELECT     s.ac
     ,     s.tr_ref
     ,     o.tr_cnt
     ,     o.ac          AS parent_ac
     ,     o.prev_tr     AS parent_tr
     FROM     got_tr_cnt     s
     JOIN     got_tr_cnt      o  ON     s.tr_ref     = o.tr_ref
                       AND     s.ac          != o.ac
     WHERE     o.prev_tr        IS NOT NULL
,     graph     AS
     SELECT     tr_ref
     ,     MAX ( LENGTH ( REPLACE ( SYS_CONNECT_BY_PATH ( LPAD ('.', tr_cnt, '.')
                )     AS start_pt
     FROM     nodes
     START WITH     parent_tr     IS NULL
     CONNECT BY     parent_tr     = PRIOR tr_ref
          AND     parent_ac     = PRIOR ac
     GROUP BY     tr_ref
SELECT       t.ac
,       t.rec_seq
,       t.tr_ref
,       t.action
,       t.qty
,       NVL ( g.start_pt
           , 1
           ) + ROW_NUMBER () OVER ( PARTITION BY  ac
                                        ,          NVL ( t.tr_ref
                                                , t.prev_tr
                                        ORDER BY          rec_seq
          - 1     AS new_rec_seq
FROM           got_trs  t
LEFT OUTER JOIN      graph       g  ON  g.tr_ref     = NVL ( t.tr_ref
                                                   , t.prev_tr
ORDER BY  t.ac
,            t.rec_seq
;Output:
AC    REC_SEQ TR_REF ACTION     QTY NEW_REC_SEQ
A1          1        BUY          1           1
A1          2        BUY          4           2
A1          3      1 TR to A2    -2           4
A1          4        SELL        -1           5
A1          5      2 TR from A2   2           8
A1          6        BUY          5           9
A1          7      3 TR to A3    -1          10
A2          1        BUY          5           1
A2          2        BUY          5           2
A2          3        BUY          5           3
A2          4      1 TR from A1   2           4
A2          5        SELL         2           5
A2          6        BUY          1           6
A2          7        BUY          1           7
A2          8      2 TR to A1    -2           8
A2          9        sell         3           9
A2         10      4 TR from A3   3          12
A3          1        BUY          5           1
A3          2      3 TR from A1   1          10
A3          3        SELL         2          11
A3          4      4 TR to A2    -3          12I don't recommend trying to store this number in the table; it will be a nightmare trying to keep it up to date. However, if you do want to store it in the table, you can use something like the query above in a MERGE statement.
When trying to understnad any quiery that uses sub-queries, it can be helpful to run the individual sub-queries by themselves, and study the output.

Similar Messages

  • Use Planning Function to calculate new value

    Hi All,
    I have what seems to be a simple problem, but no success in resolving.
    I have 3 planning keyfigures:
    -Units
    -Price
    -Value
    The price field is populated from another planning sheet.
    The unit field is entered by the user.
    The value should be calculated by planning function when button pushed.
    I have tried just basic "Value=Units*Price", but always comes back zero.
    I have also tried more complex "{Value, CharA, CharB, CharC} = {Units, CharA, CharB...." for each characteristic.  Still zero.
    It must be multipling by zero, but not sure how to avoid.
    If I put "Value=Price", it works. If I put "Value=Units", it works. If I put "Value=Units+Price", it works.
    Please help.
    Terrence

A: Use Planning Function to calculate new value

Here is the details.
In the infoprovider the data is like this:
Country/    Product/     Unit Sales/     Price/      Value
DE/             Shirt/            50/                 0/             0
DE/             Shirt/              0/             100.00/        0
The query is display:
Country/    Product/     Unit Sales/     Price/      Value
DE/             Shirt/            50/              100.00/         0
I have tried the following 2 formulas:
Formula 1:
= {Unit Sales} *
Formula 2:
FOREACH Country, Product.
{Value, Country, Product} = {Unit Sales, Country, Product} * {Price, Country, Product}
ENDFOR.
Both return zero for values.
Thanks,
Terrence

Here is the details.
In the infoprovider the data is like this:
Country/    Product/     Unit Sales/     Price/      Value
DE/             Shirt/            50/                 0/             0
DE/             Shirt/              0/             100.00/        0
The query is display:
Country/    Product/     Unit Sales/     Price/      Value
DE/             Shirt/            50/              100.00/         0
I have tried the following 2 formulas:
Formula 1:
= {Unit Sales} *
Formula 2:
FOREACH Country, Product.
{Value, Country, Product} = {Unit Sales, Country, Product} * {Price, Country, Product}
ENDFOR.
Both return zero for values.
Thanks,
Terrence

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • Query Expression not returing value from Systemuser table

    HI All,
    I tried to fetch user from Systemuserbase using QueryExpression using below Query but its not Retriving values
    QueryExpression query = new QueryExpression("systemuser");
    query.ColumnSet = new ColumnSet(true);
    query.Criteria.AddCondition(new ConditionExpression("domainname", ConditionOperator.Equal,
    proposal.ModifiedBy));
    var coltest = orgService.RetrieveMultiple(query);
     for (int i = 0; i < coltest.Entities.Count; i++)
     systemuserid = new Guid(coltest[i].Attributes["systemuserid"].ToString());
    proposal.ModifiedBy may change based on user the values will be ASKA\ADMIN and ASKA\USER (the user will be passed from share point)

    Hi,
    What happens if you put the proposal.ModifiedBy into a string of its own before using it in the fetch?
    I.e.
    string userName = proposal.ModifiedBy;QueryExpression query = new QueryExpression("systemuser");
    query.ColumnSet = new ColumnSet(true);
    query.Criteria.AddCondition(new ConditionExpression("domainname", ConditionOperator.Equal, userName));
    var coltest = orgService.RetrieveMultiple(query);
     for (int i = 0; i < coltest.Entities.Count; i++)
     systemuserid = new Guid(coltest[i].Attributes["systemuserid"].ToString());
    There might be som issues with how the string is formatted from wherever you're getting it. If that doesn't work you can do a string.replace and add an extra backslash if needed.
    Regards
    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

  • Server 2010 SP2 - New values in lookup table are not updated in the user client

    Hello,
    I added a value to a lookup table in the PWA.
    Most users see the new value in the field based on this lookup table.
    One user doesn't see the update for 2 weeks now. He did close and opened the application over these 2 weeks.
    Any Idea?
    Thanks,
    Barak

    Hi Barak,
    I am assuming the issue is with PWA? Has the user tried to access PWA from a different machine/browser?Other things you can try are:
    - Reset IE settings
    - CTRL+F5 (on the page)
    If it is MS Project that doesn't have the new value, try closing MS Project and re-open it
    Hope this helps
    Paul

  • Unsaved new values disappear on table column sort

    Guys,
    I have an af:table.
    I display row from a view object. One of them is from calculated attribute (attr1). I show attr1 on the table.
    1. i create a new row on the table.
    2. provide value to the attr1
    3. sort the column of attr1
    4. The value which was input in step 2 disappears.
    How this can be resolved?

    non - persistent value will not retains their values, you wont save those things.
    someother way to retains the value in theri place until session kills.
    1.take groovy support for the viewobject - attribute
    2.take getter/setter method of viewobjectimpl.

  • Data pump + inserting new values in a table

    Hello Everybody!!
    My question is : is it possible to insert new row into a table which is included in running DataPump process (export data) ?
    Best regards
    Marcin Migdal

    Have a look here, never done it myself but seems kind of cool :)
    http://www.pythian.com/blogs/766/oracle-data-pump-11g-little-known-new-feature

  • Trigger is not updateing the :new value in the table

    Hi,
    I've greated a row trigger that will trigger on insert statements.
    The last thing the trigger will do is to update the :NEW.role_id value in the inserted row, see the trigger bellow.
    The trigger was mutation so I had to add the 'PRAGMA AUTONOMOUS_TRANSACTION;' to avoid the mutation error.
    When performing test with controlled insert statements the trigger is working without problems, but when I my J2EE application is inserting rows to the table the role_id value is nog updated, see the trigger below and the :NEW.role_id := nRole_id; part. The role_id for the new row is empty. What can be the problem?
    CREATE OR REPLACE TRIGGER MSP_36.M2_USER_ALERT_INSERT_TRG_SCA
    BEFORE INSERT
    ON MSP_36.M2_USER_ALERT
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    ex_not_valid_role_name EXCEPTION;
    /* Variables */
    nAlertTypeId M2_USER_ALERT.alert_type%TYPE;
    isLogical      boolean;
    validRole     boolean;
    nRole_id      M2_ROLE.role_id%TYPE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
         BEGIN
              SELECT distinct at.alert_type INTO nAlertTypeId
              FROM M2_USER_ALERT ua, M2_ALERT_TYPE at,M2_ALERT_TYPE_PROPERTIES atp
              WHERE ua.alert_type = at.alert_type
              AND at.alert_type = atp.ALERT_TYPE_ID
              AND ua.alert_type = :NEW.alert_type
              AND upper(atp.property_name) = 'LOGICAL'
              AND upper(atp.property_value) = 'TRUE';
              isLogical := true;
         EXCEPTION
                   WHEN no_data_found THEN
                   isLogical := false;
                   NULL;     
         END;     
    IF (isLogical = true) THEN
    BEGIN
              SELECT distinct ro.role_id INTO nRole_id
              FROM M2_ROLE ro, M2_USER_ALERT
              WHERE ro.name = :NEW.name;
         EXCEPTION
                   WHEN no_data_found THEN
                        validRole :=false;
                        RAISE_APPLICATION_ERROR(-20001,'LOGICAL UserAlert: Role with id'|| nRole_id || ' does not exist.');     
                        NULL;
         END;
         validRole := true;
         IF (isLogical = true AND validRole = true AND :NEW.status = 1) THEN
         INSERT INTO M2_USER_ROLE (user_id,role_id)
         VALUES (:NEW.user_id,nRole_id);
         :NEW.role_id := nRole_id;
    END IF;
    END IF;
    commit;
    END;
    Many thanks,
    Michael

    I only get a empty column that include now data. The first insert is working correct so I know that the role_id is valid and working. Can there be problem with commit or my AUTONOMOUS_TRANSACTION running this from JDBC ?
    EXAMPLE data from
    M2_USER_ROLE
    ===================
    USER_ID = ROLE_ID =
    ===================
    20 = 10040 =
    1259756 = 10040 =
    ===================
    Example partly data from
    M2_USER_ALERT
    =========================================================
    USERALERT_ID = USER_ID = ALERT_TYPE = NAME = ROLE_ID =
    =========================================================
    3725 = 1259756 = 10288 = MG_Test = =
    =========================================================
    When inserted from the application the role_id is empty and I've taken the same SQL from the library cache and run it with same BIND variables and then it's working.
    Michael

  • Get old and new values from DBTABLOG table

    Hi,
    I am developing a report to display all changes to some fields of PKHD table over a date range. CDHDR & CDPOS do not capture the changes while DBTABLOG does. But the variable key field (LOGDATA) in DBTABLOG does hold encrypted values which need to be decrypted. Is there any FM or a way out to get them ?
    Please let me know. Thanks a lot.
    Regards
    Neeraj

    Use DBLOG_READ and then work with the data like in the following sample
    * Constants (cf. SAP RSVTPTOP)
      CONSTANTS: type_i4 LIKE x031l-fieldtype VALUE 'AC',       "UF160698B
                 type_i2 LIKE x031l-fieldtype VALUE 'A8',
                 type_f  LIKE x031l-fieldtype VALUE '88'.       "UF160698E
    * First - informations from directory
            REFRESH fld_list.
            CALL FUNCTION 'GET_FIELDTAB'
              EXPORTING
                langu                     = sy-langu
                only                      = ' '
                tabname                   = 'TEVEN'
                withtext                  = 'X'
    *       IMPORTING
    *         HEADER                      =
    *         RC                        =
              TABLES
                fieldtab                  = fld_list
              EXCEPTIONS
                internal_error            = 1
                no_texts_found            = 2
                table_has_no_fields       = 3
                table_not_activ           = 4
                OTHERS                    = 5.
            LOOP AT fld_list INTO fld WHERE keyflag = 'X'.
              ADD fld-intlen TO keylen.
            ENDLOOP.
    * Then extract data log
            REFRESH obj_list.
            obj-tab = 'TEVEN'.
            INSERT obj INTO  TABLE obj_list.
            CALL FUNCTION 'DBLOG_READ'
              EXPORTING
                from_day                   = s-aedtm-low
    *           FROM_TIME                  = '000000'
                to_day                     = s-aedtm-high
    *           TO_TIME                    = '235959'
                obj_list                   = obj_list
    *         ACCESS_DATABASE            = 'X'
    *         ACCESS_ARCHIVES            = ' '
    *         AUTO_ARCH_SEL              = ' '
    *         USER_LIST                  =
              CHANGING
                log_list                   = log_list
              EXCEPTIONS
                archive_access_error       = 1
                no_archives_found          = 2
                OTHERS                     = 3.
    *   Extract data from returned tables
            LOOP AT log_list INTO log.
              LOOP AT fld_list INTO fld.
                IF fld-keyflag = 'X'.
                  ASSIGN log-logkey+fld-offset(fld-intlen)
                    TO <hexa> TYPE 'X'.
                ELSE.
                  fld-offset = fld-offset - keylen.
                  ASSIGN log-logdata+fld-offset(fld-intlen)
                    TO <hexa> TYPE 'X'.
                  fld-offset = fld-offset + keylen.
                ENDIF.
                CASE fld-inttype.
                  WHEN 's'.
                    f_type = type_i2.
                  WHEN 'I'.
                    f_type = type_i4.
                  WHEN 'F'.
                    f_type = type_f.
                ENDCASE.
                IF 'sIF' CS fld-inttype.
                  feld = <hexa>.
                  CALL FUNCTION 'DB_CONVERT_FIELD_TO_HOST'
                       EXPORTING
                            type        = f_type
                       CHANGING
                            field       = feld
                       EXCEPTIONS
                            wrong_param = 1
                            OTHERS      = 2.
                  ASSIGN feld TO <hexa> TYPE 'X'.
                ENDIF.
                ASSIGN <hexa> TO <char> TYPE 'C'.
                teven+fld-offset(fld-intlen) = <char>.
              ENDLOOP.
    *     Here structure teven is filled
            ENDLOOP.
    Regards

  • Need a Query to search a value from all tables.

    Hi,
    I would like to know, is there any way that we could search a string from all the tables.
    For example I need to find a STRING 'hello world', on which table it presents. I want to search it from all the tables, as there might be a situtation
    where we dont knwo which table the value gets stored.
    REgards
    Suresh

    Run this code ---this is only search for required value in VARCHAR2 column.as per ur requirement u can change it to oher dataype..
    Reply if its helpful to you
    DECLARE
    S SYS_REFCURSOR;
    CURSOR c_user_col IS
    SELECT TABLE_NAME,COLUMN_NAME,DATA_TYPE FROM USER_TAB_COLUMNS,TAB
    WHERE TABLE_NAME=TNAME AND TABTYPE='TABLE'
    ORDER BY TABLE_NAME;
    TYPE TAB_LIST
    IS
    RECORD
    TABLE_NAME VARCHAR2(1000),
    COLUMN_NAME VARCHAR2(1000),
    DATA_TYPE VARCHAR2(100));
    TYPE T_TAB_LIST
    IS
    TABLE OF TAB_LIST;
    L_TAB_LIST T_TAB_LIST := T_TAB_LIST();
    L_STMT CLOB;
    l_exists NUMBER;
    BEGIN
    FOR i IN c_user_col LOOP
    L_TAB_LIST.EXTEND;
    L_TAB_LIST(L_TAB_LIST.LAST).TABLE_NAME := I.TABLE_NAME;
    L_TAB_LIST(L_TAB_LIST.LAST).COLUMN_NAME := i.COLUMN_NAME;
    L_TAB_LIST(L_TAB_LIST.LAST).DATA_TYPE := i.DATA_TYPE;
    END LOOP;
    FOR i in 1..L_TAB_LIST.COUNT LOOP
    l_exists := NULL;
    IF L_TAB_LIST(I).DATA_TYPE = 'VARCHAR2' THEN
    L_STMT := 'SELECT 1 FROM '||L_TAB_LIST(I).TABLE_NAME||' WHERE '||L_TAB_LIST(I).COLUMN_NAME||'=''samplesdfsdfsdf''';
    OPEN S FOR L_STMT;
    FETCH S INTO l_exists;
    CLOSE S;
    IF l_exists IS NULL THEN
    NULL;
    ELSE
    DBMS_OUTPUT.PUT_LINE('Table name: '||L_TAB_LIST(I).TABLE_NAME||'--Column Name: '||L_TAB_LIST(I).COLUMN_NAME);
    DBMS_OUTPUT.PUT_LINE(L_STMT);
    END IF;
    END IF;
    END LOOP;
    END;

  • FM - Add new value to WRTTP Field

    Hi experts,
    I would like to add a new value to the table Value types.
    Currently this table contains values form 1- 3C.
    Could Anybody tell me how I 'd add a new value?.
    Thanks in advance,
    Greetings,
    Nachos

    Hi,
    I dont think you will be able to add more values to this field from configuration.
    If you check the data element and domain associated with this field (LTAK_SPEZI) in SE11. You can see that the value range for the domain has been defined there as  A and B only.
    So if you want to add a new value you can ask and ABAP/technical consulatnt to add new values to this Domain.
    However i am not sure it will be useful (unless you have a specific requirement and want to modify the standard programs) as the field is checked in different program (eg in inculde  LL03AF4V , LL03AF7F ) against these fixed values A and B.

  • How to allow user to enter new values in a segmnt which's having a ValueSet

    Hi Gurus
    I am having a DFF segment where user needs the following validation. I have to check whether the value entered by user is having status number as 5 in a custom table. I can do this by Table type Validation.
    But the problem here is, they should also be able to enter new values which not in that table.
    How i can achieve this. Appreciate your help on this.
    Thanks.
    Praveen

    Value sets allow only for standar list for validation, not a combobox that is what may help You to achieve what You want. You either have a restricted list or an open field to type whatever matches the format restrictions.
    For what You specify, I see no reason on having a table validation is the user can after all enter new values, perhaps it's to have the table values as references and avoid duplicates. Workarounds may be:
    Add an "others" value to the table, and enable another segment to enter new values and add custom validation to avoid duplicates and insert the new values to the table for future use.
    Have an independent value set and add a customization to avoid duplicates (more difficult considering typos) and insert new values.

  • Insert values to one table based on a value inserted into another table

    Hi,
    I've got a form based off a report which creates a new project. I've added an additional process to this form to insert four new values into another table as soon as the new project is created and the PK for that project is generated. This was working last week (of course!) and now seems to not work at all. It's complaining that the PK I was getting from my first insert was null. Here is one the the statements in my process I'm trying to run:
    insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER);
    The complaint I get that it's getting null where :P45_PROJECT_SEQ should be.
    Thoughts?
    Thanks,
    Jon

    Hi Andy,
    Thanks for the tip. Those two values didn't match and I updated them so they do and I'm still getting a "cannot insert NULL..." error.
    When I turn on debug I see that I'm getting the PK and I see the value. Here's my debug output:
    0.24: ...Process "Get PK": PLSQL (AFTER_SUBMIT) declare function get_pk return varchar2 is begin for c1 in (select PROJECT_SEQ.nextval next_val from dual) loop return c1.next_val; end loop; end; begin :P45_PROJECT_SEQ := get_pk; end;
    0.25: ...Session State: Saved Item "P45_PROJECT_SEQ" New Value="252"
    0.25: ...Process "Process Row of PROJECT": DML_PROCESS_ROW (AFTER_SUBMIT) #OWNER#:PROJECT:P45_PROJECT_SEQ:PROJECT_SEQ|IUD
    0.26: ...Session State: Save "P45_PROJECT_SEQ" - saving same value: "252"
    0.26: ...Process "reset page": CLEAR_CACHE_FOR_PAGES (AFTER_SUBMIT) 45
    0.27: Nulling cache for application "120" page: 45
    0.27: ...Process "Add Week Groups": PLSQL (AFTER_SUBMIT) insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER); insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY') +
    0.28: Encountered unhandled exception in process type PLSQL
    0.28: Show ERROR page...
    0.28: Performing rollback...
    I notice that when it runs my process "Add Week Groups" it's not displaying all of the SQL. But the SQL is fine, it's right here:
    insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER);
    Hmmm....what about the "reset page" action in the last of the 0.26 lines?
    Thanks,
    Jon

  • Write back values to db table

    Hi folks,
    I want to read the description-texts from maintenance-positions, modify them a little and then write the new values back. I arranged a User-selection using select options and I can process those objects and read their descriptions, but I don't know how to write back the new values to database-table MPOS.
    Here is what I have:
    DATA tmpos LIKE mpos OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN  BEGIN OF BLOCK txt WITH FRAME TITLE text-001.
    SELECT-OPTIONS:
    t_warpl FOR tmpos-warpl.
    SELECTION-SCREEN END OF BLOCK txt.
      SELECT * FROM mpos into table tmpos
      WHERE warpl IN t_warpl.
      LOOP AT tmpos.
          WRITE / tmpos-pstxt.
          tmpos-pstxt = 'TEST'.
          modify table tmpos.
      ENDLOOP.
    It seems I just modify the temporal table, but not the one in db.
    Can you help me out?
    Thanx and have a nice day!

    HI,
    Can u elaborate what is your requirement because ur passing the description HARDCODED in the loop
    LOOP AT tmpos.
          WRITE / tmpos-pstxt.
          tmpos-pstxt = 'TEST'. "I did n't get ur changing this description with a hardcoded value
          modify table tmpos.
      ENDLOOP.
    The solution for this is update the PSTXT  in the loop of tmpos
    Regards,
    Madhukar Shetty

  • New KF in query based on rows values

    Hi guys,
    I hope you can help me with this requirement...
    I already have a query that has cost element's hierarchy in rows and several restricted key figures in columns. Those KF are basically amounts filtered by cost centers (some nodes of CC hierarchy).
    What i need...
    I need a new column that gets for each node of cost element's hierarchy the value of a different KF. Let's simplify... For row 1 I need the KF1, for row 2 I need KF2, and for row 3 I need KF3 (not that simply in fact)
    Stores--WHSupervision of Stores--
    NEW KF
    Net Sales--1002000--
    100
    Margin--15250--
    25
    Labor Costs--561440--
    40
    I think it should be based in an IF/THEN clause. Something like:
    IF Cost element = net Sales -> NEW KF = 'Stores'
    IF Cost element = Margin -> NEW KF = 'WH'
    IF Cost element = Labor cost -> NEW KF = 'Supervision'
    but I don't know how to achive this with BEX query designer.
    The point is that this query is dynamic so values for my new column change while i expand or collapse the structure. In the other hand the different nodes in Cost element's hierarchy are known and fixed.
    I tried to use replacement path in variables but I was unable to do it, probably because I'm newbie in BI and don't know if they are intended for issues like this.
    Do you think I can achieve this? Can you give me any ideas?
    Thanks,
    Ruben
    Edited by: ruben melendez on Sep 2, 2008 11:02 AM.

    Hi Ruben,
    If Then Else statements can be entered in a formula.
    For example if I wanted a formula to show me the result of KF "Sales Qty TY" to be displayed if it is greater than KF "Sales Qty LY",  I would enter the following :
    ("Sales Qty TY" > "Sales Qty LY") * "Sales Qty TY" + (Not("Sales Qty TY > "Sales Qty LY")) * "Sales Qty LY
    This basically says that if the key figure SQTY is greater than SQLY then SQTY else if it isn't show me SQLY
    You can make multiple statements within the same formula but I think that can get quite messy.
    Hope this helps you if you intend to use If Then Else statements for this issue.
    Regards
    Nick

  • Maybe you are looking for