Tuesday 25 December 2018

FieldEdit vs FieldChange Event in PeopleSoft

FieldEdit event is more of a validation event used to validate the value entered in a field and throw error/warning if the value is not what is supposed to be when the cursor is tabbed out. This event won't allow the user to save transaction unless and until the appropriate value isn't provided in the field and the validation passed. The FieldChange PeopleCode fires after the field value has been changed.


FieldChange event is used where you want to change other fields in response to when another field is changed. The FieldEdit PeopleCode fires before the field value 
is actually changed.


HAPPY LEARNING:)

PreBuild Vs PostBuild Event in PeopleSoft

PreBuild fires before any PeopleCode code event on all the rows and fields in the component such as FieldDefault and RowInit. During the PreBuild event, there will not be any data in the component buffer other than the search record as it's executing prior to the component build process.

During the PostBuild event, you will have access to the data read from the database into the component buffer.

PreBuild and PostBuild is most commonly used to hide or unhide pages.



HAPPY LEARNING :)

Monday 26 November 2018

Dynamic view in PeopleSoft

Views are a useful feature of SQL databases, letting us create virtual tables based on SQL select statements.
PeopleSoft 8 provides the functionality to create dynamic views. These are essentially SQL statements executed on the fly by the PeopleSoft component processor. We can use dynamic views in Peoplesoft pages only because they are PeopleTools objects, not SQL Objects.
Using Dynamic view as Prompt Table
In this article, we will see the use of Dynamic view as a prompt table. Please note that a dynamic view can be used for other purposes such as search records which will not be discussed in the article.
One major question that pops up to many of us the first time we use a dynamic view, why not use a normal view instead of a dynamic view. A dynamic view’s select statement may include Peoplesoft’s meta-SQL, and it may be replaced by a different SQL statement while the user is using the page. And also there might be situations where which you do not save the view in the database.
Using Edit Table for prompt tables
Assume that you have a page in which the user selects a country and depending on the selection you want a different prompt table for the states. For example, if the user selects US show states for US and user selects Canada show states of Canada.
This can be achieved by following the steps below
Step 1: Create two views/dynamic views to show the states of the US and Canada.
Step 2: Go to record field, in our case it is state field (Right click and select View Definition on the state field on the page).
Step 3: Right Click and select Record Field Properties
Step 4: Select Edits tab and then select Table Edit. Select Prompt table with edit( or No Edit) as per your requirement. Write %EDITTABLE against Prompt table.*EDITTABLE is a field in table named DERIVED, provided by PeopleSoft.
Step 5: Place the EDITTABLE field from DERIVED Table on the page.
Step 6: On field change of Country Field, write the below code

if YOURRECORDNAME.COUNTRY = "US";
  DERIVED.EDITTABLE = "STATE_US_DVW"; // dynamic view of list of states of US
Else
  DERIVED.EDITTABLE = "STATE_CAN_DVW"; // dynamic view of list of states of CAN
End-if;
Using SQL Text
Instead of creating two views/dynamic views, you can also create one dynamic view and pass the SQL dynamically to change the prompt table.
Step 1: Create and save A Dynamic view
Step 2: Give the dynamic view as a prompt table to the state field.
Step 3: On field change of your country field you can write.

if YOURRECORDNAME.COUNTRY = "US";
  YOURRECORDNAME.FIELD.SqlText = "Select State from MY_STATE_TBL where country = 'US'";
ELSE
  YOURRECORDNAME.FIELD.SqlText = "Select State from MY_STATE_TBL where country = 'CAN'";
END-IF;

HAPPY LEARNING :)

Monday 5 June 2017

Costed Flag in PS_TRANSACTION_INV table

COSTED_FLAG = Y or N

If you are adding a row PS_TRANSACTION_INV, you have to decide if you want the row to be taken into account by the costing process by setting the field COSTED_FLAG either to Y or to N. If you set it to Y, the costing process will skip the row.


HAPPY LEARNING :)

Inventory Issues and Resolution

Completions Pending Putaway =

1) Difference between the quantity (field COMPLETED_QTY) in PS_SF_OUTPUT_LIST for an Item by Production ID where MG_OUTPUT_TYPE = CP (Primary Item) or CS (Secondary Co-Product) and the sum of the quantities (field QTY_BASE) in PS_TRANSACTION_INV for the Item by Production ID for the Transaction Groups 021 (Receipts from production) and 221 (Route to Production Kit).

+

2) Quantity (field COMPLETED_QTY) in PS_SF_OUTPUT_LIST for the Item by Production ID if the Production ID's are not found in PS_TRANSACTION_INV for the Transaction Groups 021 (Receipts from production) and 221 (Route to Production Kit).


Part 1 of the above formula is done by running a query against the View PS_CM_NP_PID_VW and part 2 against the View PS_CM_NP_PID2_VW. So in order to check where the problem is, just run the following two queries:


SELECT COUNT(*) FROM PS_CM_NP_PID_VW WHERE BUSINESS_UNIT = 'Your Business Unit' AND CM_BOOK = 'Your Cost Book';

SELECT COUNT(*) FROM PS_CM_NP_PID2_VW WHERE BUSINESS_UNIT = 'Your Business Unit' AND CM_BOOK = 'Your Cost Book';

Usually the issues lies in the PS_TRANSACTION_INV that has not been updated properly and this is the second query that returns a count <> 0. Note that if a negative completion following by a positive completion was recorded for the PID in an attempt to solve the issue, this is the first query that returns a count <> 0 and not the second one.



Most of the times, once you are sure that there's no staging error and no staging ID waiting to be processed for your PID, the best way to solve the issue is just to update PS_TRANSACTION_INV with the missing information. You might have to add the missing Putaway with a Transaction Groups 021 into PS_TRANSACTION_INV or update an existing Putaway that was created manually into Inventory. Here is the list of fields that must be updated (there might be others depending on how you are using the system):


BUSINESS_UNIT
INV_ITEM_ID
DT_TIMESTAMP
SEQ_NBR = 1
RECEIVER_ID = ALL
RECV_LN_NBR = 999
TRANSACTION_GROUP = 021
QTY_BASE
QTY
UNIT_MEASURE_STD
UNIT_OF_MEASURE
COSTED_FLAG = Y or N
PRODUCTION_ID
MA_PRDN_ID_FLG = Y
PRDN_AREA_CODE
PRODUCTION_TYPE = PR
STAGED_TYPE = 1
TRANSACTION_SOURCE = WL
OP_SEQUENCE

If you are adding a row PS_TRANSACTION_INV, you have to decide if you want the row to be taken into account by the costing process by setting the field COSTED_FLAG either to Y or to N. If you set it to Y, the costing process will skip the row.

Once the missing row has been added into PS_TRANSACTION_INV or the existing manual Putaway modified, check the Pending Transactions page to make sure that Completion Pending Putaway = 0. Run then the costing process and check the results to make sure everything is fine.



=== QUERY VIEW INFORMATION ===

*** Query view CM_NP_PID_VW:


SELECT A.BUSINESS_UNIT
, D.CM_BOOK
, A.PRODUCTION_ID
, A.MG_OUTPUT_ITEM
, (A.COMPLETED_QTY - B.COMPLETED_QTY)
, %Substring(C.MESSAGE_TEXT, 1, 50)
FROM PS_CE_OUTPUT2_VW A
, PS_CE_PID_CMP_VW B
, PSMSGCATDEFN C
, PS_CM_BU_BOOK_TBL D
WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT
AND A.PRODUCTION_ID = B.PRODUCTION_ID
AND A.MG_OUTPUT_ITEM = B.INV_ITEM_ID
AND (B.COMPLETED_QTY - A.COMPLETED_QTY) <> 0
AND C.MESSAGE_SET_NBR = 15500
AND C.MESSAGE_NBR = 177
AND A.BUSINESS_UNIT = D.BUSINESS_UNIT
AND D.CM_BOOK_STATUS = 'A'


*** Query view CM_NP_PID2_VW:


SELECT A.BUSINESS_UNIT
, B.CM_BOOK
, A.PRODUCTION_ID
, A.MG_OUTPUT_ITEM
, A.COMPLETED_QTY
, %Substring(C.MESSAGE_TEXT, 1, 50)
FROM PS_CE_OUTPUT2_VW A
, PS_CM_BU_BOOK_TBL B
, PSMSGCATDEFN C
WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT
AND B.CM_BOOK_STATUS = 'A'
AND A.COMPLETED_QTY > 0
AND C.MESSAGE_SET_NBR = 15500
AND C.MESSAGE_NBR = 177
AND NOT EXISTS (
SELECT 'X'
FROM PS_CE_PID_CMP_VW BB
WHERE A.BUSINESS_UNIT = BB.BUSINESS_UNIT
AND A.PRODUCTION_ID = BB.PRODUCTION_ID
AND A.MG_OUTPUT_ITEM = BB.INV_ITEM_ID)


*** Query view CE_OUTPUT2_VW:


SELECT BUSINESS_UNIT
, PRODUCTION_ID
, MG_OUTPUT_ITEM
, COMPLETED_QTY
, MG_OUTPUT_TYPE
FROM PS_SF_OUTPUT_LIST
WHERE MG_OUTPUT_TYPE IN ('CP','CS')


*** Query view CE_PID_CMP_VW:


SELECT BUSINESS_UNIT
, PRODUCTION_ID
, INV_ITEM_ID
, SUM(QTY_BASE)
FROM PS_TRANSACTION_INV
WHERE PRODUCTION_ID <> ' '
AND TRANSACTION_GROUP IN ('021','221')
GROUP BY BUSINESS_UNIT, PRODUCTION_ID , INV_ITEM_ID


=====================

The 'Insufficient Qty Cost Option' is there for you to decide if you want to cost the negative Depletions or to wait until a new Putaway is received.

If you decide to cost the negative Depletions, then checking the 'Resolve Negative Inventory' check box on the Run Control page of the CM_CSTACCTG makes the 'Resolver' run. The 'Resolver' looks for any new Putaway to re-cost the negative Depletions based on the new Cost received on the new Putaway. If you do not select the 'Resolve Negative Inventory' check box, the 'Resolver' will not run.


Example in case you set the 'Insufficient Qty Cost Option' to 'Always cost insufficient qty':

Assume there are 10 units of an Item available in the Inventory Business Unit and a demand line is shipped and depleted for 15 units, then the entire depletion transaction of the 15 units is costed the next time the CM_CSTACCTG process is run, even if this is before sufficient stock is placed in the Business Unit. Of the 15 units, 10 are costed using the existing stock on hand, and 5 are costed using the current Average Cost, current Standard Cost, or last Actual Cost depending on the Cost Method employed.

Assume now you have received the 5 units. Next time you run the CM_CSTACCTG process with the 'Resolve Negative Inventory' check box selected, the 'Resolver' runs and will do the following:

Applies the new Receipt quantities to the previously recorded negative inventory Depletion transactions. The 'Resolver' matches the negative inventory Depletion transactions to the actual Received stock.

Creates Adjustment Accounting entries for the Item using the Deplete Cost Method of Actual Cost. The 'Resolver' creates an entry to reverse the cost previously recorded for the negative inventory Depletion transactions and to record new transactions at the Actual Receipt Cost. The following Accounting Lines are created:

* A reversing entry to remove the Depletion based on the last Actual Cost received before the negative state,
* An entry to record the Depletion based on the Actual Receipt Costs.

For Items using the Deplete Cost Method at Current Standard, Perpetual Weighted Average, or Retroactive Perpetual Weighted Average, the 'Resolver' does not change the previously recorded cost for the negative inventory Depletion transaction. The Standard or Average Cost at the time of the Depletion is used on the original Depletion and is not changed when the 'Resolver' corrects the negative state by matching the negative inventory Depletion transactions to the actual received stock.

Inserts the resolved negative inventory Depletion transactions into a history table called PS_CM_RESOLVE_HIST.

Note:

Running the 'Resolver' is optional. It is highly recommended that you use this process to resolve all negative Depletion transactions so that reports and queries do not reflect negative states that have been resolved. The 'Resolver' does not impact the total on hand quantity. For costs, it only impacts the total inventory value for Actual Cost Items.

Two inquiries are available to monitor the costing of negative inventory Depletion transactions and the recalculations of the quantities and costs performed by the 'Resolver'. These queries are called CM_PENDING_RESOLVER and CM_RESOLVED_NEG_HIST and can be viewed using the Query Viewer.

The CM_PENDING_RESOLVER query returns negative inventory Depletion transactions that have not been resolved.
The CM_RESOLVED_NEG_HIST query returns negative inventory Depletion transactions that have been resolved and recorded in the history table PS_ CM_RESOLVE_HIST.

================

1) Why aren't my rows costing?

Follow the below step when you find out that some inventory transactions are not being costed by the CM_COSTING or the CM_CSTACCTG process:

Check the Message Log of your Process Instance in the Process Monitor.

Query the PS_TRANSACTION_INV.COSTED_FLAG field for the inventory transactions you want to check.

If the value is 'X' it means that the inventory transaction doesn't need to be processed, for example because the Item is a non-costed or a non-owned Item.

If the value is 'N',  it means that the inventory transaction has not been processed yet or the process is not able to process it at this time (see the Top Reasons section below).

If the value is 'Y', it means that the inventory transaction has been processed.


2) Top Reasons why inventory transactions are not being processed

Inventory transaction rows expanded for Books but not costed:

Possible reasons:
Costing hasn't been run for this Inventory Business Unit and Book
SELECT * FROM PS_CM_TRANSACTION WHERE POSTED_FLAG = 'N'


Cost Adjustments not processed:

Possible reasons:
(a) The ''Apply Perpetual Average Adjs' check box has not been selected on the Run Control page.
(b) The Payables Matching process has been run for Voucher(s) before the corresponding Receipt(s) have been putaway.
SELECT * FROM PS_CM_MATCHED_COST WHERE POSTED_FLAG = 'N'
SELECT * FROM PS_CM_COST_ADJ WHERE POSTED_FLAG = 'N'
SELECT * FROM PS_CM_ACTUAL_BOOK WHERE POSTED_FLAG = 'N'


Receipts not costed:

Possible reasons:
(a) There is no cost for the Item.
(b) The process is waiting for the Voucher Cost from Payables or waiting for user to run the process in 'Regular Mode' for period end.
SELECT * FROM PS_CM_RECEIPTS WHERE POSTED_FLAG = 'N'


Depletion rows not depleted:

Possible reasons:
(a) Not enough qty on-hand to satisfy the depletion (see MESSAGE_SET_NBR & MESSAGE_NBR on the CM_DEPLETION rows).
(b) might be explainable if the negative inventory is allowed for the Inventory Business Unit 
SELECT * FROM PS_CM_DEPLETION WHERE POSTED_FLAG = 'N'


Depletion rows not costed:

Possible reasons:
(a) There is no cost for the Item.
(b) The process is waiting for the Voucher Cost from Payables or waiting for user to run the process in 'Regular Mode' for period end.
SELECT * FROM PS_CM_DEPLETE WHERE POSTED_FLAG = 'N'


3) SQL statements you can use to help you resolve missing cost issues



Missing Receipt Costs (Actual and Average Costs):

This query helps identifying rows from the PS_CM_RECEIPTS table which are not getting processed due to a missing Cost or Actual Cost rows without an Actual Cost.
SELECT * FROM PS_CM_RECEIPTS, PS_CM_ITEM_METH_VW
WHERE NOT EXISTS (SELECT 'X' FROM PS_CM_ACTUAL_COST
WHERE PS_CM_RECEIPTS.BUSINESS_UNIT = PS_CM_ACTUAL_COST.BUSINESS_UNIT
AND PS_CM_RECEIPTS.INV_ITEM_ID = PS_CM_ACTUAL_COST.INV_ITEM_ID
AND PS_CM_RECEIPTS.CM_DT_TIMESTAMP_A = PS_CM_ACTUAL_COST.DT_TIMESTAMP
AND PS_CM_RECEIPTS.CM_SEQ_NBR_A = PS_CM_ACTUAL_COST.SEQ_NBR)
AND PS_CM_RECEIPTS.BUSINESS_UNIT = PS_CM_ITEM_METH_VW.BUSINESS_UNIT
AND PS_CM_RECEIPTS.CM_BOOK = PS_CM_ITEM_METH_VW.CM_BOOK
AND PS_CM_RECEIPTS.INV_ITEM_ID = PS_CM_ITEM_METH_VW.INV_ITEM_ID
AND PS_CM_RECEIPTS.POSTED_FLAG = 'N'
AND PS_CM_ITEM_METH_VW.CM_TYPE IN ('1')


Missing Receipt Costs (Standard Costs):

This query helps identifying rows from the PS_CM_RECEIPTS table which are not getting processed due to a missing Cost or Standard Cost rows without a Standard Cost (not accurate for Configured Items).
SELECT * FROM PS_CM_RECEIPTS, PS_CM_ITEM_METH_VW
WHERE NOT EXISTS (SELECT 'X' FROM PS_CM_STDCOSTD_VW
WHERE PS_CM_RECEIPTS.BUSINESS_UNIT = PS_CM_STDCOSTD_VW.BUSINESS_UNIT
AND PS_CM_RECEIPTS.INV_ITEM_ID = PS_CM_STDCOSTD_VW.INV_ITEM_ID)
AND PS_CM_RECEIPTS.BUSINESS_UNIT = PS_CM_ITEM_METH_VW.BUSINESS_UNIT
AND PS_CM_RECEIPTS.CM_BOOK = PS_CM_ITEM_METH_VW.CM_BOOK
AND PS_CM_RECEIPTS.INV_ITEM_ID = PS_CM_ITEM_METH_VW.INV_ITEM_ID
AND PS_CM_RECEIPTS.POSTED_FLAG = 'N'
AND PS_CM_ITEM_METH_VW.CM_TYPE IN ('2')


Missing Deplete Costs (Actual Costs):

This query helps identifying rows from the PS_CM_DEPLETE table which are not getting processed due to a missing Cost or Actual Cost rows without an Actual Cost.
SELECT * FROM PS_CM_DEPLETE, PS_CM_ITEM_METH_VW
WHERE NOT EXISTS (SELECT 'X' FROM PS_CM_ACTUAL_COST
WHERE PS_CM_DEPLETE.BUSINESS_UNIT = PS_CM_ACTUAL_COST.BUSINESS_UNIT
AND PS_CM_DEPLETE.INV_ITEM_ID = PS_CM_ACTUAL_COST.INV_ITEM_ID
AND PS_CM_DEPLETE.CM_DT_TIMESTAMP_A = PS_CM_ACTUAL_COST.DT_TIMESTAMP
AND PS_CM_DEPLETE.CM_SEQ_NBR_A = PS_CM_ACTUAL_COST.SEQ_NBR)
AND PS_CM_DEPLETE.BUSINESS_UNIT = PS_CM_ITEM_METH_VW.BUSINESS_UNIT
AND PS_CM_DEPLETE.CM_BOOK = PS_CM_ITEM_METH_VW.CM_BOOK
AND PS_CM_DEPLETE.INV_ITEM_ID = PS_CM_ITEM_METH_VW.INV_ITEM_ID
AND PS_CM_DEPLETE.POSTED_FLAG = 'N'
AND PS_CM_ITEM_METH_VW.CM_METHOD IN ('1')


Missing Deplete Costs (Standard Cost):

This query helps identifying rows from the PS_CM_DEPLETE table which are not getting processed due to a missing Cost or Standard Cost rows without a Standard Cost (not accurate for Configured Items).
SELECT * FROM PS_CM_DEPLETE, PS_CM_ITEM_METH_VW
WHERE NOT EXISTS (SELECT 'X' FROM PS_CM_STDCOSTD_VW
WHERE PS_CM_DEPLETE.BUSINESS_UNIT = PS_CM_STDCOSTD_VW.BUSINESS_UNIT
AND PS_CM_DEPLETE.INV_ITEM_ID = PS_CM_STDCOSTD_VW.INV_ITEM_ID)
AND PS_CM_DEPLETE.BUSINESS_UNIT = PS_CM_ITEM_METH_VW.BUSINESS_UNIT
AND PS_CM_DEPLETE.CM_BOOK = PS_CM_ITEM_METH_VW.CM_BOOK
AND PS_CM_DEPLETE.INV_ITEM_ID = PS_CM_ITEM_METH_VW.INV_ITEM_ID
AND PS_CM_DEPLETE.POSTED_FLAG = 'N'
AND PS_CM_ITEM_METH_VW.CM_METHOD IN ('8')


Missing Deplete Costs (Average Costs):

This query helps identifying rows from the PS_CM_DEPLETE table which are not getting processed due to a missing Cost or Perpetual Average Cost row without a Cost.
SELECT * FROM PS_CM_DEPLETE, PS_CM_ITEM_METH_VW
WHERE NOT EXISTS (SELECT 'X' FROM PS_CM_PERPAVG_COST
WHERE PS_CM_DEPLETE.BUSINESS_UNIT = PS_CM_PERPAVG_COST.BUSINESS_UNIT
AND PS_CM_DEPLETE.INV_ITEM_ID = PS_CM_PERPAVG_COST.INV_ITEM_ID
AND PS_CM_DEPLETE.CM_DT_TIMESTAMP_A = PS_CM_PERPAVG_COST.DT_TIMESTAMP
AND PS_CM_DEPLETE.CM_SEQ_NBR_A = PS_CM_PERPAVG_COST.SEQ_NBR)
AND PS_CM_DEPLETE.BUSINESS_UNIT = PS_CM_ITEM_METH_VW.BUSINESS_UNIT
AND PS_CM_DEPLETE.CM_BOOK = PS_CM_ITEM_METH_VW.CM_BOOK
AND PS_CM_DEPLETE.INV_ITEM_ID = PS_CM_ITEM_METH_VW.INV_ITEM_ID
AND PS_CM_DEPLETE.POSTED_FLAG = 'N'
AND PS_CM_ITEM_METH_VW.CM_TYPE IN ('6').


HAPPY LEARNING :)

FieldEdit vs FieldChange Event in PeopleSoft

FieldEdit event is more of a validation event used to validate the value entered in a field and throw error/warning if the value is not wh...