cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ME_CUST_PO Enhancement : PO Amount Check Against PR

Sudipta099
Explorer
0 Likes
1,189

The goal is to ensure PO line items don't exceed the approved amount on the corresponding Purchase Requisition (PR).

Here's a simplified explanation:

  1. Check for PR Reference: For each item in the PO (table EKPO), the system first checks if it's linked to a PR. It does this by looking at the BANFN (PR Number) and BNFPO (PR Item) fields. If these fields are blank, it means the PO item isn't related to a PR, and the system skips this item. We only care about PO items that are based on PRs.

  2. Get PR Amount: If a PR link exists, the system retrieves the approved amount for that PR item. It goes to the EBAN table (PR table) and uses the BANFN (PR Number) and BNFPO (PR Item) as search criteria. It then fetches the NETWR field, which represents the PR item's net value (approved amount).

  3. Calculate Total PO Amount for Each PR: Now, for each unique PR referenced in the PO, the system calculates the total amount of all PO items related to that specific PR. It sums up the NETWR (Net price) of all PO items that have the same BANFN (PR Number). Think of it as grouping PO items by PR and summing their amounts.

  4. Compare and Validate: The crucial step: the system compares the total PO amount calculated in the previous step with the original PR amount fetched from EBAN. This comparison is done for each PR referenced in the PO.

  5. Error Message: If the total PO amount for a given PR exceeds the PR amount, the system throws an error message: "PO amount exceeds PR amount for PR: ****** (the PR number). Please adjust the PO amount." This prevents POs from being created that overspend the approved PR budget.

In essence: The enhancement ensures that the total amount of all PO items linked to a specific PR never goes over the approved amount on that PR. It acts as a budget control mechanism during PO creation.

Example:

Let's say PR 12345 has an approved amount of $1000. A PO is being created with two items linked to PR 12345:

  • PO Item 1: $600
  • PO Item 2: $500

The system will:

  1. Recognize both PO items are linked to PR 12345.
  2. Fetch the PR amount ($1000) from EBAN for PR 12345.
  3. Calculate the total PO amount for PR 12345: $600 + $500 = $1100.
  4. Compare $1100 (PO total) with $1000 (PR total).
  5. Since $1100 > $1000, the system will display the error message.

This prevents the PO from being saved until the amounts are adjusted.

Accepted Solutions (0)

Answers (1)

Answers (1)

RaymondGiuseppi
Active Contributor
0 Likes

Use the provided macros to handle error message as in this answer

  • use a metafield for eban purchase requisition number
  • insure correct handling of decimals in your code (currency)
  • Use the SET_DATA methods to update some values (similar to the GET_DATA)
  • For some global check, use the CHECK method, this method will be called by user or before save/post.
  • In CHECK_HEADER and CHECK methods, you can get an internal table of reference to items with GET_ITEMS method

 

Sudipta099
Explorer
0 Likes
Hi everyone , i am trying to create an enhancement using the badi me_process_po_cust , the requirement is pretty simple here , we need to validate the total PR with the total PO amount , if the po amount exceeds the PR amount then we should give error , this i can validate it process_item, but i am confused in case of a scenario where there's one PR and there are multiple POs referencing that PR , and i need to calculate the total PR with respect to multiple POs totalling it and then to compare it that wether it is exceeding the total pr or not if yes then error otherwise allow to save , so this where i should write , because in process_item it validates single line item not overall , and if i write in process_header then there's no signature for im_item , there's only one signature of IM_HEADER and if i export parameters , there's no exporting parameters from process_item method , Please suggest/help