How do I update the parent Entity Object when updating the child Entity Object in ADF? - parent

I finished the JDeveloper Cue Card "Build a Fusion Web Application" which is pretty basic and shows you have to update a parent( ORDER ) table and view the child ( ORDER_ITEM ) rows associated with the parent record. This is all fine but of course in the "real world" you would need to update/add items to an order. Naturally after add/updating the ORDER_ITEMS table you would want the ORDER_TOTAL value in the ORDER table to reflect the change. In other words, if you double the quantity of one of the items, the ORDER_TOTAL value in the ORDER table should increase.
So to expand on the Cue Card, I added another page which allows me to update the values in the ORDER_ITEMS table which works fine - this is just out-of-the-box ADF magic.
I tried to post an image of my task flow but my reputation level isn't high enough. I guess I have to play the game longer to earn more guild points :) Here's a link to a picture click here I originally posted this question to the Oracle User Group but got no responses so I thought I would try this forum.
I tried two ways to update the ORDER_TOTAL in the ORDER table after an add/update to ORDER_ITEM table.
1) Modify the orderview to include a nested select statement which calculates the ORDER_TOTAL dynamically
SELECT Orders.ORDER_ID,
Orders.ORDER_DATE,
Orders.ORDER_SHIPPED_DATE,
Orders.ORDER_STATUS_CODE,
(select sum(unit_price * quantity) from order_items a
where a.order_id = Orders.order_id
group by order_id )
AS ORDER_TOTAL,
Orders.CUSTOMER_ID,
Orders.SHIP_TO_NAME,
Orders.SHIP_TO_ADDRESS_ID,
Orders.SHIP_TO_PHONE_NUMBER,
. . . .
2) Add an update to the ORDER_TOTAL value in the ORDER table with in the task flow after an add/update to ORDER_ITEM table and COMMIT.
update orders set order_total = ???? where order_id = ????
With either solution, I get the same results which is as follows
I update the ORDER_ITEM table in the editOrderItem.jsff page, the task flow performs a COMMIT and returns to the editOrder.jsff page, ORDER_TOTAL amount does not reflect the change. Hitting cancel from editOrder.jsff returns to order.jsff which show the correct ORDER_TOTAL amount. Returning to editOrder.jsff from order.jsff and the correct value for ORDER_TOTAL appears. It seems that the values in the ADF form inside order.jsff are cached and the page never refreshes against any updates to the database. I've tried to make editOrder.jsff refresh by changing the properties from refresh "true" to "false". Also changed CacheResults from "true" to "false". Tried modifying the task flow properties from "no controller action" to "Always Begin New Transaction".

You need to re-execute the query containing the ORDER_TOTAL after you committed the ORDER_ITEM modifications.

Related

Changing Qty of SOLine from a Different Page

I have a customization in which the user can adjust the quantity of an SO Line from a different page. This works perfectly, except when the user goes to execute the action "Create Shipment" for that SO. When "Create Shipment" executes, the shipment record created reflects the original values the user put in for the line's quantity instead of the adjusted quantity. Here is an example:
I created an order with original SO quantities of 10 and one respectively. I then changed the quantities to 8 and 5 respectively through my customization page:
This is the shipment I get when I select Actions -> Create Shipment:
I have looked through and adjusted any numbers misrepresenting the values I desired in the SQL tables SOOrder, SOLine, and SOLineSplit, but I still get the incorrect values when creating a shipment. Is there a table I am missing?
Sounds like the issue could be the PlanQty found on the related INItemPlan record which the Create Shipment process uses to create the shipment.
Might be worth looking into getting the SOLine updated via the SOOrderEntry graph or make sure the INItemPlan values are getting updated correctly. Maybe a missing view in your custom page. I think the values are updated from the attribute on PlanID of SOLineSplit if that helps.

Adding a field to a table that is the result of a query to another table

In MS Access 2010, I have two tables - one with Candidates and one with Package Actions. The Actions are associated with the Candidates via the CandidateID field, which is an autonumber in the Candidates table. The Actions table has a date field for each action. I have a field in the Candidates field that I would like to display the action type of the most recent action associated with that particular candidate, but can't seem to figure out how to do it. I've tried implementing a subquery as a default value:
SELECT TOP 1 ActionT.ActionType FROM ActionT WHERE
(((ActionT.CandidateID)=13))
ORDER BY ActionT.DateCompleted DESC;
Obviously, this query on its own only returns the most recent action for candidate 13 but ideally I would like to replace the =13 with =CandidateID but I can't even get the field to populate with the result of the query as is. I've also tried using DLookup but got an error while trying to make that the default value. I've also tried using the button "Modify Lookups", pasting the query and the DLookup directly into the cell, and trying to change the type of the field from "Text" to "Calculated", all to no avail.
Novice MS Access user here, so I appreciate any extra explanations y'all may have.
Thanks In Advance.
EDIT:
Just to be clear, I'm not looking for a query, per se. I want to know how I can make the result of my query above always be the value of a field in the candidate table. (If my code above needs corrections, I'm open to that, but that isn't really my question.)
Example: Candidate A has several actions in theActionTable associated with him. They are ResumeRecieved, ResumeReviewed, and Interviewed. The date associated with Interviewed is the most recent, therefore in the CandidateTable, the status for Candidate A should be "Interviewed." We then decide to extend an offer, so we add an action to the ActionTable "OfferExtended."
The Status field in the CandidateTable for Candidate A should automaticaaly update to read "OfferExtended"
Inside your main SELECT STATEMENT, you need to have a nested SELECT STATEMENT descendingly ordered by DateCompleted to get the most recent DateCompleted for each CondidateId.
Below should do the trick for you:
SELECT con.Id,
con.Name,
(SELECT TOP 1 ActionType FROM ActionT
WHERE CandidateId = con.Id ORDER BY DateCompleted DESC) AS ActionType
FROM Candidates AS con

Filtering based off #me

I have created a custom screen that records a "SalesPerson" ID that links back to the Salespersons records.
One of the requirements is to create an inquiry screen (not generic inquiry) that has a filter for the current sales person (based on logged in user). The Filters should be "All Records" / "My Items" with the second being the default displayed (based on the recorded "Sales Person)
For this, The PXSelect statement links {customtable} -> {employee} (where salesperson record = employee.salesperson
I even extended that to link employee.userId -> users.pKid.
The actual select statement is below:
public PXSelectJoin<CWAItem,
LeftJoin<EPEmployee,On<CWAItem.salesPersonID,Equal<EPEmployee.salesPersonID>>,
LeftJoin<Users, On<Users.pKID,Equal<EPEmployee.userID>>>>> MobileOrders;
Both of these correctly display the user name in the grid however when i create a filter where EPEmployee__UserID = #me or Users.UserName = #me no records are returned.
Scanning through the system this appears to be used on the "WZ201500" screen that has a simular filter. The difference that I see is this is referencing "EPEmployee_UserId" based on the table definition.
Is there a limitation to using child DAC's and the #me or is there a different way to handle the joins so the #me works correctly?
Any assistance would be appreciated.
Having not used #me I am not sure what this refers to, however we did something similar limiting records based on the current user ID using access info like such:
Where<EPEmployee.userID, Equal<Current<AccessInfo.userID>>
Hope that helps
Just use the Table AccessInfo then Default Value of your Filter Equals to AccessInfo.UserID to any of the Table Field you need like CreatedByID or ModifiedByID

COGNOS report for a simple sub query and join Query

Here is my query. I am new to Cognos and using Cognos 10. And I am having a bit difficulty in developing a report which uses a Sub Query and an Inner Join Query.
1.
SELECT ID, BATCH_DT, LOCIT FROM AOI.TEMP_BRICK
WHERE BATCH_DT < (SELECT MAX(DATE) FROM CALENDAR)
2.
SELECT A.ID, B.SAL FROM TABLE as A LEFT OUTER JOIN TABLE as B
WHERE A.ID=B.ID
First, you must understand that Cognos generates its own SQL. In order for it to do that, you must define relationships between tables in Cognos Framework Manager. Once that is done your report has 3 major parts, The Report Page(s), the Prompt Page(s) and the Query(s).
a.) Setup the CALENDAR and AOI.TEMP_BRICK tables in Cognos. You may want to define a relationship between TEMP_BRICK.BATCH_DT and CALENDAR.DATE (assuming your calendar has date records for every date that may be present in TEMP_BRICK).
b.) Next you would create a new List Report. You would grab your ID, BATCH_DT and DATE fields into the list. (Date would come from the calendar if you decided to link the two tables in step A, otherwise you use the BATCH_DT field in TEMP_BRICK.)
c.) You would open the Query pages and see that Cognos has already created one query, called Query1. You need to create a new query (we will call it qryMaxDate). That query would have one element, 'DATE' from CALENDAR. On the properties of the 'DATE' field in Data Items, you would chagne the 'Agregate Function' from None to 'Maximum'.
d.) Now edit your Query1, add a Filter on the Date from that query. In the Expression Definition, select the Queries tab and drag the 'DATE' field from your qryMaxDate. Should look something like this [Batch Date] = [qryMaxDate].[Date]
e.) You are done! Run the report. in this case, the user running the report is giving no input, so no Prompt page is necessary.
a.) Setup Table A and B in the Framework Manager. You need to define a relationship between Table A and B in Framework Manager via a Star Schema (define A.ID = B.ID and specify 1 to n, or n to 1).
b.) Create a new report and simply drag in elements from table a and table b. Their relationship is already defined in Framework manager, so there is no need to re-define it while writing reports.
Your second example is a great demonstration of the power of BI programs like Cognos. Report Authors dont need to fully understand the ways that two tables are joined... they simply pull out elements from each table and they work, as the relationships are already defined in the Framework.

Updating a table Access and Excel VBA

I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed in an excel sheet that is connected with MS Access database. ID is the only unique field. Sometimes, my user submits a transaction that has let's say 5 records. Then, they want to modify the submitted data in case if they entered incorrect amount and they want to correct it. I want to write a code in VBA that will do the update. my current query is:
Update table Transaction(ProductName,Amount) set ProductName=#Product,Amount=#Amount)
where Date=#date;
This query does not work fine because obviously it replaces all the records data with the data of the last resubmitted record because my condition is weak. My difficulty is that I can't find a good condition in the where clause that will do the update a record by record accordingly.
Please help,
You will need to use the unique id of the record, in your case the ID field to guarantee you are updating the correct record.
Something like the following:
Update table Transaction(ProductName,Amount) set ProductName=#Product,Amount=#Amount) where ID = "id of record you want to update"
Enjoy!

Resources