on 09-16-2014 3:45 PM
Experts,
We are having trouble summing amount columns of tables in BRFplus. We have tried 2 different ideas and each has a different error:
Any ideas? Your help would be greatly appreciated.
We have opened OSS Note 887267/2014 for this issue. The error in the formula function can be worked around by switching to expert mode and changing the column name to the field in single quotes (although SAP should still fix this issue - workarounds are not acceptable):
TABLE_SUM_AMOUNT ( 0050569BA4BE1EE486990918279CB05B , 'BETRW' )
However, once this is fixed, the Formula Function now has the same currency problem as the Table Operation in #1 of my original post. Considering BRFplus is used by a large number of SAP customers, I find it hard to believe that this issue has not been encountered before.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post some screenshots? How does the structure of the table look like? What is the exact error message? Do you have currency conversion customizing set up?
In fast the usage of the column name is not a workaround but the formula function was build like this from the beginning. You do not have to enter the expert mode. You can stay in the standard mode and use the buttons below the formula pane to insert a text for the column name.
Carsten,
From ABAP, you can only pass an amount to BRFplus. For example, 10 instead of 10 USD. In your example, you are specifying the currency. The purpose of my post is that none of the summing functionality works without currency specified, and I cannot find a way to pass the currency to BRFplus from ABAP.
Jon
Jon,
You have to pass an amount consisting of a number and a currency. Without the currency the conversion cannot be performed. An amount is not an amount without a currency.
You may use the BRFplus standard types (IF_FDT_TYPES and the DDIC data elements used there) or you can use your own type. Make sure you have a number value and a currency in your structure and have one point to the other (CURR + CUKY). Then you can pass this to BRFplus and work with it.
Regards,
Carsten
My specific requirement is to sum the BETRW amount field on an internal table of structure DFKKOP. In ABAP, the structure contains a currency field called WAERS. If you attempt to create a table Data Object in BRFplus based on the DFKKOP structure, for some reason the WAERS field disappears:
This is really a very simple and common use case. My function module that calls BRFplus is posted below. What I need to know from the experts is:
****HOW DO I SUM THE FIELD BETRW IN TABLE DFKKOP?****
The examples posted so far are not helping at all.
FUNCTION ZFICA_BRFPLUS_SUM_TEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" VALUE(EV_AMOUNT) TYPE BETRW_KK
*" TABLES
*" IT_DFKKOP STRUCTURE DFKKOP
*" EXCEPTIONS
*" NO_INKGP_FOUND
*"----------------------------------------------------------------------
CONSTANTS: lv_function_id TYPE if_fdt_types=>id VALUE '0050569BA4BE1EE48FE94B283920E9F1'. "THE BRFPLUS FUNCTION
DATA: lt_name_value TYPE abap_parmbind_tab,
ls_name_value TYPE abap_parmbind,
lv_timestamp TYPE timestamp,
exc TYPE REF TO cx_fdt,
lr_data TYPE REF TO data.
FIELD-SYMBOLS: <logmsg> TYPE if_fdt_actn_message_log=>s_log_msg,
<wa> TYPE any.
GET TIME STAMP FIELD lv_timestamp.
"SEND THE OPEN ITEMS TO BRFPLUS
CLEAR ls_name_value.
MOVE: 'IT_DFKKOP' TO ls_name_value-name.
GET REFERENCE OF IT_DFKKOP INTO lr_data.
TRY.
CALL METHOD cl_fdt_function_process=>move_data_to_data_object
EXPORTING
ir_data = lr_data
iv_function_id = lv_function_id
iv_data_object = 'IT_DFKKOP'
iv_timestamp = lv_timestamp
IMPORTING
er_data = ls_name_value-value.
CATCH cx_fdt_input.
ENDTRY.
INSERT ls_name_value INTO TABLE lt_name_value.
"THEN CALL THE BRFPLUS FUNCTION
TRY.
CALL METHOD cl_fdt_function_process=>process
EXPORTING
iv_function_id = lv_function_id
iv_timestamp = lv_timestamp
CHANGING
ct_name_value = lt_name_value.
CATCH cx_fdt_input cx_fdt INTO exc.
MESSAGE exc TYPE 'E'.
ENDTRY.
"NOW GET THE RESULT FROM THE CALL TO THE BRFPLUS FUNCTION
cl_fdt_function_process=>get_context_value( EXPORTING iv_function_id = lv_function_id
iv_data_object = 'EV_AMOUNT'
iv_timestamp = lv_timestamp
IMPORTING ev_data = EV_AMOUNT ).
ENDFUNCTION.
Field WAERS is a currency key. Therefore, it is not taken over into the structure in BRFplus.
Fields BETR* (e.g. BETRH) are taken over as amounts. In the DDIC they are defined with a pointer to WAERS.
The data types in BRFplus differ from ABAP. In BRFplus there are amounts that consist of number and currency. In case we can find this relationship in DDIC we use it. Some fields however are just ignored like types xstring.
Jon
The question is not how to sum a column in BRFplus. It is more about how to pass the data into BRFplus. In case you have more complex variables you should use method CL_FDT_FUNCTION_PROCESS=>MOVE_DATA_TO_DATA_OBJECT for this purpose. The code template generator can output some code for you. In release >=731 you can find it in the menu on the function UI. In earlier releases use report FDT_TEMPLATE_FUNCTION_PROCESS.
Carsten
Hi Jon,
Also if you are always or mostly summing to one main currency you might want to put a default currency in your Rules Applications settings.. at least that helps sort out the default treatment of decimal places.
Also Amounts in BRFplus have both a value and a currency part. You need to move both into and out of your BRFplus amount. If you move your BETRW and WAERS to a value of data type IF_FDT_TYPES=>ELEMENT_AMOUNT then you can easily map it to your BRFplus amount, and pass it to BRFplus as fully formulated amount with currency. Put the BETRW in the NUMBER part, and WAERS in the CURRENCY part.
I'd also warn you that the standard conversion formula function CONVERT_AMOUNT only converts at the default exchange rate on the current date. However it's really surprisingly easy to create a custom formula function that extends that. (One blog I'm still trying to find time to write). Took me about an hour to create the custom formula function... seriously! The code's more than half written for you already in CL_FDT_FORMULA_FUNCTIONAL->CONVERT_AMOUNT. Let me know if that's critical to what you are doing and I'll try and move up my blogging timeframe.
Rgds,
Jocelyn
Can you elaborate more about 1.
'Total' Table operation & result filed is amount field.
Input table:
1) 10, blank currency
2) 10, blank currency
Output element:
30, blank currency
on NW731.11
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jon,
from my point of view the second option is the one that should definitly work, However I tested it on our system and it does not. I get the same error as you.
When debugging the issue one will see that the problem is located in the class CL_FDT_FORMULA_PARSER method _CHECK_TABLE_FUNCTIONAL. Here the program tries to compare the column name that is entered in the formula expression vs. the available column names determined via the structure of the table:
IF lv_name EQ lv_colname.
lv_found = abap_true.
EXIT. ">>>>>>>>>>
ENDIF.
The problem is that the parameter lv_name contains the technical name of the column (e. g. AMOUNT) and the while the parameter lv_colname contains the GUID of the column (that is also the reson for the cryptical error message). As this check is done for all these functions, it is consistent that the error is raised as you describe it.
I did not find any note that solves that issue, so I would recommend that you open an OSS.
Best regards
Christian
P.S. I am on a NW740 with SP06
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.