cancel
Showing results for 
Search instead for 
Did you mean: 

Custom price field validation

matteo_montalto
Contributor
0 Kudos

Hello expert,

sorry by the cross-post, I posted something similar on the SRM place on SCN, but lately realized it has probably more to do with WD abap.

Shortly: I noticed that SRM manages prices in documents such as PO or contract according to the currency value.

In particular:

1 - PRICE value, at item level, is rendered via abap WD with the proper number of decimals according to the selected currency.

For instance, if dealing with CLP (chile pesos), which is defined without decimals, then prices are automatically rendered without decimals:

I.e: entering 156,00 -> on screen only 156 is shown (correctly without decimals, as CLP currency is defined with 0 decimals).

     while if the currency is EUR, then 2 digits after comma are allowed and representation switches to 2 decimals (e.g. "156,00")... Note I'm just talking about how the system renders the price, without considering conversions between different currencies.

2 - If I enter a value, say 123,45, as price for an item where the currency is set by customizing as a 0 decimals, then I get the error (DB 739):
"Too many decimal places (maximum &)"

and the price inputfield in the item table is highlighted with a red box.

Now... I'd like to understand if it's possible to obtain the same behaviour for a custom "price" field, let's call it Z_PRICE, at header's level.

This field is typized as CURR and has BBPS_CTR_HEADER (or BBP_PDHGP, tried both) -> CURRENCY entry in the "Currency/Quantity fields" tab.
This field, so far, is not subjected to any validation and does not dynamically react to currency's changes.

That is to say, for instance:

- CURRENCY is set to EUR (2 decimals);

- enter a value in Z_PRICE, let's say "150,00";

- switch currency to "CLP" (chilean pesos, 0 decimals);

While all item prices (standard fields) do not show any decimals, Z_PRICE remains unaltered with two digits after comma.


Is there a way to obtain the same standard behaviour on Z_PRICE field? I thought it could be related to the "Currency/Quantity fields" in the definition of the custom field itself, but no matter what I specify, it simply doesn't seem to affect the runtime behaviour in any way.

Help/suggestions on this task?


Thanks in advance,

M.

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Matteo,

Yes, you can achieve your requirement for custom field Z_PRICE as below

  • Let us say you have added a field Z_PRICE inside structure BBPS_CTR_HEADER
  • Now, you need to define the currency reference from same structure BBPS_CTR_HEADER
  • Hope, your context node is created using structure BBPS_CTR_HEADER, then system automatically converts the currency decimals based on reference key of same structure BBPS_CTR_HEADER

If on_enter event is not triggered, create an event handler DUMMY and attach to the field Z_CURRENCY. So that on an enter event, framework renders the view by updating decimal places based on key

Hope this helps you.

Regards,

Rama

matteo_montalto
Contributor
0 Kudos

Hello Rama and thanks for your help,

my Z_PRICE field is in a custom append structure for custom fields, included in INCL_EEW_PD_HEADER_CSF structure.

This include is then part of the BBP_PDHSC - Header Extension for Customer Fields.

Unfortunately, BBP_PDHSC does not contain a currency field, which is instead present in BBP_PDHGP table.

So, I tried to specify in BBP_PDHSC, for my field Z_PRICE, that there's a currency reference table-field, using BBP_PDHGP as table, CURRENCY as field. But in this case, the solution doesn't work.

Just to add additional information on the task: the WD of interest is /SAPSRM/WDC_CTR_DODC_H_BD, view V_CTR_H_BD.
In this view, on WDDOMODIFYVIEW, there's a custom routine to add all header-related fields. Z_PRICE is one of these.

former_member184578
Active Contributor
0 Kudos

Hi,

You can give the standard table and field(to which already validation is automatically happening) as reference table.

Regards,

Kiran

matteo_montalto
Contributor
0 Kudos

Hi Kiran,

I tried without success; the problem is that the standard price validation occours in a different WD, which is /SAPSRM/WDC_CTR_DOTC_IT, view V_CTR_DODC_ITEMS.

In that view, items are represented in tabular form and the price is an inputfield.

I'd like to obtain the same behaviour for my custom price field, which is instead at header level, rendered in WD /SAPSRM/WDC_CTR_DODC_H_BD, view V_CTR_H_BD.


I hoped such kind of validation is independent from the WD but relies instead on the currency reference table-field, but this doesn't seems to work.


Maybe I should try to bring the CURRENCY field also as custom field, filling it properly in accordance to the original BBP_PDHGP-CURRENCY field, and set this as reference for currency. Do you think this could be a good idea?

matteo_montalto
Contributor
0 Kudos

Solved!!!
I noticed that in /SAPSRM/WDC_CTR_DODC_H_BD, the main context node is typized as /SAPSRM/S_CLL_CTR_HEADER. Such structure contains BBP_PDS_CTR_HEADER_U as include structure, and this one contains the CURRENCY field.

So I set BBP_PDS_CTR_HEADER_U -> CURRENCY as reference table/field for my custom price, and everything works as expected.

Thank you all for your support!

Answers (0)