Incorrect KONV-KBETR calculation.
I have to calculate the KBETR value and send it to an external system. The value is being calculated in two place, once in user exit and other in custom program.
DATA: l_discount_pct TYPE P LENGTH 9 DECIMALS 3,
lt_komv type table of komv.
The code written in the user exit is:
lt_xkomv = xkomv.
LOOP AT lt_tab.
READ TABLE lt_xkomv WITH KEY kschl = lt_tab-zfield.
IF sy-subrc = 0.
l_discount_pct = ( lt_xkomv-kbetr * -1 ).
In the above code the value of lt_xkomv-kbetr is -150.00 and it is getting converted to 15.000 which is correct.
The code written in custom program is:
CALL FUNCTION 'RV_KONV_SELECT'
comm_head_i = ls_komk
general_read = 'X'
tkomv = lt_komv.
LOOP AT lt_komv INTO ls_komv.
l_discount_pct = ( ls_komv-kbetr * -1 ).
In konv table the value is stored as 150.00 which is standard SAP Conversion.
In the above code the value of lt_xkomv-kbetr is -150.00 and it is getting converted to 150.00.The conversion did not take place like in user exit.
The issue is that kbetr value is calculated correctly in user exit and the same code is returning the different value in the custom program. Initially, I thought it may be a data type issue, However all the data types used in the both the places are same. Does SAP behave differently while converting values in user exits and custom program. Please provide your inputs on this.